Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session management #638

Merged
merged 6 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dialogs/power/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ namespace Budgie {

private bool grabbed = false;

private ShellShim? shim;

public PowerApplication() {
Object(application_id: "org.buddiesofbudgie.PowerDialog", flags: 0);

/* we need a separate process to connect budgie session with our
endsessiondialog in budgie-daemon via dbus to allow the confirmation dialog
to be displayed; connecting via the same process introduces a 30sec - 1 min delay
In v10.9.2 this was budgie_wm. Under wayland the power app is the replacement choice
*/
shim = new ShellShim();
shim.serve();
}

public override void activate() {
Expand Down
1 change: 1 addition & 0 deletions src/dialogs/power/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ powerdialog_sources = [
'dbus.vala',
'dialog_button.vala',
'main.vala',
'shim.vala',
'window.vala'
]

Expand Down
119 changes: 119 additions & 0 deletions src/dialogs/power/shim.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* This file is part of budgie-desktop
*
* Copyright Budgie Desktop Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/

namespace Budgie {
[DBus (name="org.budgie_desktop.Session.EndSessionDialog")]
public interface EndSessionRemote : GLib.Object {
public abstract signal void ConfirmedLogout();
public abstract signal void ConfirmedReboot();
public abstract signal void ConfirmedShutdown();
public abstract signal void Canceled();
public abstract signal void Closed();
public abstract void Open(uint type, uint timestamp, uint open_length, ObjectPath[] inhibiters) throws Error;
public abstract void Close() throws Error;
}

[DBus (name="org.gnome.SessionManager.EndSessionDialog")]
public class SessionHandler : GLib.Object {
public signal void ConfirmedLogout();
public signal void ConfirmedReboot();
public signal void ConfirmedShutdown();
public signal void Canceled();
public signal void Closed();

private EndSessionRemote? proxy = null;

public SessionHandler() {
Bus.watch_name(BusType.SESSION, "org.budgie_desktop.Session.EndSessionDialog",
BusNameWatcherFlags.NONE, has_dialog, lost_dialog);
}

void on_dialog_get(Object? o, AsyncResult? res) {
try {
proxy = Bus.get_proxy.end(res);
proxy.ConfirmedLogout.connect(() => {
this.ConfirmedLogout();
});
proxy.ConfirmedReboot.connect(() => {
this.ConfirmedReboot();
});
proxy.ConfirmedShutdown.connect(() => {
this.ConfirmedShutdown();
});
proxy.Canceled.connect(() => {
this.Canceled();
});
proxy.Closed.connect(() => {
this.Closed();
});
} catch (Error e) {
proxy = null;
}
}

void has_dialog() {
if (proxy != null) {
return;
}
Bus.get_proxy.begin<EndSessionRemote>(BusType.SESSION, "org.budgie_desktop.Session.EndSessionDialog", "/org/budgie_desktop/Session/EndSessionDialog", 0, null, on_dialog_get);
}

void lost_dialog() {
proxy = null;
}

public void Open(uint type, uint timestamp, uint open_length, ObjectPath[] inhibiters) throws DBusError, IOError {
if (proxy == null) {
return;
}
try {
proxy.Open(type, timestamp, open_length, inhibiters);
} catch (Error e) {
message(e.message);
}
}

public void Close() throws DBusError, IOError {
if (proxy == null) {
try {
proxy.Close();
} catch (Error e) {
message(e.message);
}
}
}
}

[DBus (name="org.gnome.Shell")]
public class ShellShim : GLib.Object {
private SessionHandler? handler = null;

[DBus (visible=false)]
public ShellShim() {
handler = new SessionHandler();
}

void on_bus_acquired(DBusConnection conn) {
try {
conn.register_object("/org/gnome/SessionManager/EndSessionDialog", handler);
} catch (Error e) {
message("Unable to register ShellShim: %s", e.message);
}
}

[DBus (visible=false)]
public void serve() {
Bus.own_name(BusType.SESSION, "org.gnome.Shell",
BusNameOwnerFlags.ALLOW_REPLACEMENT|BusNameOwnerFlags.REPLACE,
on_bus_acquired, null, null);
}
}
}
8 changes: 8 additions & 0 deletions src/session/budgie-desktop-labwc.desktop.in.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
_Name=Budgie Desktop (labwc)
_Comment=This session logs you into the Budgie Desktop using labwc as the window manager
Exec=@prefix@/bin/labwc -S /usr/bin/budgie-desktop
TryExec=@prefix@/bin/labwc
Icon=
Type=Application
DesktopNames=Budgie;GNOME
4 changes: 2 additions & 2 deletions src/session/budgie-desktop.desktop.in.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Desktop Entry]
_Name=Budgie Desktop
_Comment=This session logs you into the Budgie Desktop
Exec=@prefix@/bin/budgie-desktop
TryExec=@prefix@/bin/budgie-desktop
Exec=@prefix@/bin/magpie-wm -s /usr/bin/budgie-desktop
TryExec=@prefix@/bin/magpie-wm
Icon=
Type=Application
DesktopNames=Budgie;GNOME
27 changes: 20 additions & 7 deletions src/session/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gnome_session_324_components = [
'org.gnome.SettingsDaemon.Power',
'org.gnome.SettingsDaemon.PrintNotifications',
'org.gnome.SettingsDaemon.Rfkill',
'org.gnome.SettingsDaemon.ScreensaverProxy',
'org.gnome.SettingsDaemon.Sharing',
'org.gnome.SettingsDaemon.Smartcard',
'org.gnome.SettingsDaemon.Sound',
Expand All @@ -44,7 +43,6 @@ gsd_324_max = [

# Always in Budgie
budgie_components = [
'org.buddiesofbudgie.BudgieWm',
'org.buddiesofbudgie.BudgieDaemon',
'org.buddiesofbudgie.BudgiePanel',
'org.buddiesofbudgie.BudgiePowerDialog'
Expand Down Expand Up @@ -97,22 +95,37 @@ configure_file(
install_dir: join_paths(get_option('prefix'), get_option('bindir')),
)

# Configure the xsession file
xsession_conf = configure_file(
# Configure the default wayland-session file
waylandsession_conf = configure_file(
input: 'budgie-desktop.desktop.in.in',
output: 'budgie-desktop.desktop.in',
configuration: session_data,
)

# Now merge the translations of the .desktop.in to a .desktop
custom_target('desktop-file-xsession',
input : xsession_conf,
custom_target('desktop-file-waylandsession',
input : waylandsession_conf,
output : 'budgie-desktop.desktop',
command : [intltool, '--desktop-style', podir, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : join_paths(datadir, 'xsessions'),
install_dir : join_paths(datadir, 'wayland-sessions'),
)

# Configure the labwc wayland-session file
waylandlabwcsession_conf = configure_file(
input: 'budgie-desktop-labwc.desktop.in.in',
output: 'budgie-desktop-labwc.desktop.in',
configuration: session_data,
)

# Now merge the translations of the .desktop.in to a .desktop
custom_target('desktop-file-waylandlabwcsession',
input : waylandlabwcsession_conf,
output : 'budgie-desktop-labwc.desktop',
command : [intltool, '--desktop-style', podir, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : join_paths(datadir, 'wayland-sessions'),
)

# Merge + install nm-applet
custom_target('desktop-file-nm-applet',
Expand Down
93 changes: 0 additions & 93 deletions src/wm/meson.build
Original file line number Diff line number Diff line change
@@ -1,96 +1,3 @@
custom_target('desktop-file-wm',
input : 'budgie-wm.desktop.in',
output : 'org.buddiesofbudgie.BudgieWm.desktop',
command : [intltool, '--desktop-style', podir, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : join_paths(datadir, 'applications'))


budgie_wm_sources = [
'background.vala',
'ibus.vala',
'keyboard.vala',
'main.vala',
'shim.vala',
'wm.vala',
'screenshot.vala',
]

budgie_wm_status_vala_args = []

zenity = find_program('zenity', required: false)
assert(zenity.found(), 'Zenity is a required program at build and run-time for dialog support in budgie-wm. Please include it in both build and run deps, as well as check if you need to set use-old-zenity.')

use_old_zenity = get_option('use-old-zenity')

if use_old_zenity == false
message('Using new zenity flags')
budgie_wm_status_vala_args += ['-D', 'HAVE_NEW_ZENITY']
else
message('Using old zenity flags')
endif

dep_graphene = dependency('graphene-gobject-1.0', version: '>= 1.10')
dep_wm = dependency('libmagpie-0', version: '>= 0.9', required: false)

if dep_wm.found()
message('Using libmagpie-0 ABI')
vapi_wm = 'libmagpie-0'
else
dep_wm = dependency('libmutter-12', version: '>= 44', required: false)
if dep_wm.found()
message('Using libmutter-12 ABI from GNOME 44')
vapi_wm = 'libmutter-12'
else
dep_wm = dependency('libmutter-11', version: '>= 43', required: false)
if dep_wm.found()
message('Using libmutter-11 ABI from GNOME 43')
vapi_wm = 'libmutter-11'
else
dep_wm = dependency('libmutter-10', version: gnome_minimum_version)
if dep_wm.found()
message('Using libmutter-10 ABI from GNOME 42')
vapi_wm = 'libmutter-10'
endif
endif
endif
endif

budgie_wm_deps = [
link_libconfig,
dep_giounix,
dep_wm,
dep_xfce4windowing,
dep_gnomedesktop,
dep_ibus,
]

budgie_wm_vala_args = [
'--pkg', 'gio-unix-2.0',
'--pkg', 'ibus-1.0',
'--pkg', 'gnome-desktop-3.0',
'--pkg', vapi_wm,
'--pkg', 'budgie-config',
'--vapidir', join_paths(meson.source_root(), 'vapi'),
'--vapidir', dir_libconfig,
budgie_wm_status_vala_args,
]

rpath = dep_wm.get_pkgconfig_variable('typelibdir')
budgie_wm_vala_args += ['--girdir', rpath]

executable(
'budgie-wm', budgie_wm_sources,
dependencies: budgie_wm_deps,
include_directories: extra_includes,
install: true,
vala_args: budgie_wm_vala_args,
c_args: [
'-DGNOME_DESKTOP_USE_UNSTABLE_API',
],
install_rpath: rpath,
)

# gschemas
install_data(
files('com.solus-project.budgie.wm.gschema.xml',
Expand Down
Loading