Skip to content

Commit

Permalink
Merge branch 'sessionmanagement' of https://github.com/buddiesofbudgi…
Browse files Browse the repository at this point in the history
…e/budgie-desktop into sessionmanagement
  • Loading branch information
fossfreedom committed Dec 22, 2024
2 parents 34125db + 1638686 commit c14beb8
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 369 deletions.
117 changes: 117 additions & 0 deletions src/daemon/background.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* 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 {
public const string BACKGROUND_SCHEMA = "org.gnome.desktop.background";
public const string ACCOUNTS_SCHEMA = "org.freedesktop.Accounts";
public const string GNOME_COLOR_HACK = "budgie-control-center/pixmaps/noise-texture-light.png";

public class Background {
private Settings? settings = null;

const int BACKGROUND_TIMEOUT = 850;

/* Ensure we're efficient with changed queries and dont update
* a bunch of times
*/
Gnome.BG? gnome_bg;
Subprocess? bg = null;

/**
* Determine if the wallpaper is a colour wallpaper or not
*/
private bool is_color_wallpaper(string bg_filename) {
if (gnome_bg.get_placement() == GDesktop.BackgroundStyle.NONE || bg_filename.has_suffix(GNOME_COLOR_HACK)) {
return true;
}
return false;
}

public Background() {
settings = new Settings(BACKGROUND_SCHEMA);
gnome_bg = new Gnome.BG();

/* If the background keys change, proxy it to libgnomedesktop */
settings.change_event.connect(() => {
gnome_bg.load_from_preferences(this.settings);
return false;
});

gnome_bg.changed.connect(() => {
this.update();
});

/* Do the initial load */
gnome_bg.load_from_preferences(this.settings);
}

/**
* call accountsservice dbus with the background file name
* to update the greeter background if the display
* manager supports the dbus call.
*/
void set_accountsservice_user_bg(string background) {
DBusConnection bus;
Variant variant;

try {
bus = Bus.get_sync(BusType.SYSTEM);
} catch (IOError e) {
warning("Failed to get system bus: %s", e.message);
return;
}

try {
variant = bus.call_sync(ACCOUNTS_SCHEMA, "/org/freedesktop/Accounts", ACCOUNTS_SCHEMA, "FindUserByName",
new Variant("(s)", Environment.get_user_name()), new VariantType("(o)"), DBusCallFlags.NONE, -1, null);
} catch (Error e) {
warning("Could not contact accounts service to look up '%s': %s", Environment.get_user_name(), e.message);
return;
}

string object_path = variant.get_child_value(0).get_string();

try {
bus.call_sync(ACCOUNTS_SCHEMA, object_path, "org.freedesktop.DBus.Properties", "Set",
new Variant("(ssv)", "org.freedesktop.DisplayManager.AccountsService", "BackgroundFile",
new Variant.string(background)
), new VariantType("()"), DBusCallFlags.NONE, -1, null);
} catch (Error e) {
warning("Failed to set the background '%s': %s", background, e.message);
}
}

void update() {
string? bg_filename = gnome_bg.get_filename();;
/* Set background image when appropriate, and for now dont parse .xml files */
if (!this.is_color_wallpaper(bg_filename) && !bg_filename.has_suffix(".xml")) {
// we use swaybg to define the wallpaper - we need to keep track
// of what we create so that we kill it the next time a background is defined
string[] cmdline = { "swaybg", "-i", bg_filename };
Subprocess new_bg;
try {
new_bg = new Subprocess.newv(cmdline, SubprocessFlags.NONE);
Timeout.add(BACKGROUND_TIMEOUT, () => {
// use a delay to allow process termination to complete
if (bg != null) {
bg.force_exit();
}
bg = new_bg;
return false;
});
} catch (Error e) {
warning("Error starting swaybg: %s", e.message);
}
set_accountsservice_user_bg(bg_filename);
}
}
}
}
2 changes: 2 additions & 0 deletions src/daemon/manager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Budgie {
Budgie.TabSwitcher? switcher;
BudgieScr.ScreenshotServer? screenshotcontrol;
Budgie.XDGDirTracker? xdg_tracker;
Budgie.Background? background;

/* Screenlock */
Budgie.Screenlock? screenlock;
Expand All @@ -49,6 +50,7 @@ namespace Budgie {
menus.setup_dbus(replace);
switcher = new Budgie.TabSwitcher();
switcher.setup_dbus(replace);
background = new Budgie.Background();

try {
screenshotcontrol = new BudgieScr.ScreenshotServer();
Expand Down
5 changes: 4 additions & 1 deletion src/daemon/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ daemon_sources = [
'notifications/dbus.vala',
'notifications/popup.vala',
'screenshot.vala',
'background.vala',
'statusnotifier.vala',
'main.vala',
'manager.vala',
Expand All @@ -46,6 +47,7 @@ daemon_deps = [
dep_gtk3,
dep_gdkx11,
dep_notify,
dep_gnomedesktop,
dep_wnck,
dep_xfce4windowing,
dep_gst,
Expand All @@ -61,7 +63,7 @@ daemon_deps = [
# Need absolute path to gresource
gresource = join_paths(meson.current_source_dir(), 'budgie-daemon.gresource.xml')

daemon_vala_args = []
daemon_vala_args = ['--pkg', 'gnome-desktop-3.0']

dep_gsd_doubles = dependency('gnome-settings-daemon', version: '>=3.33.90', required: false)
if dep_gsd.found()
Expand Down Expand Up @@ -95,6 +97,7 @@ executable(
],
c_args: [
'-DWNCK_I_KNOW_THIS_IS_UNSTABLE',
'-DGNOME_DESKTOP_USE_UNSTABLE_API'
],
install: true,
)
Expand Down
11 changes: 3 additions & 8 deletions src/panel/applets/icon-tasklist/widgets/IconButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -641,17 +641,12 @@ public class IconButton : Gtk.ToggleButton {
icon.waiting = false;
}

Gdk.Pixbuf? pixbuf_icon = null;

if (window_group != null) {
var size = target_icon_size == 0 ? DEFAULT_ICON_SIZE : target_icon_size;
pixbuf_icon = window_group.get_icon(size, 1);
}

if (app?.icon != null) {
unowned var pixbuf = window_group.application.get_icon(size, get_scale_factor());
icon.set_from_pixbuf(pixbuf);
} else if (app?.icon != null) {
icon.set_from_gicon(app?.icon, Gtk.IconSize.INVALID);
} else if (pixbuf_icon != null) {
icon.set_from_pixbuf(pixbuf_icon);
} else {
icon.set_from_icon_name("image-missing", Gtk.IconSize.INVALID);
}
Expand Down
45 changes: 22 additions & 23 deletions src/windowing/meson.build
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
libwindowing_sources = [
'dbus.vala',
'windowing.vala',
'window_group.vala',
'window_mapper.vala',
'dbus.vala',
'windowing.vala',
'window_group.vala',
]

libwindowing_deps = [
dep_xfce4windowing,
dep_wnck,
dep_xfce4windowing,
dep_wnck,
]

libwindowing = static_library(
'windowing',
libwindowing_sources,
dependencies: libwindowing_deps,
c_args: [
'-DWNCK_I_KNOW_THIS_IS_UNSTABLE',
],
vala_args: [
'--pkg', 'gio-unix-2.0',
'--pkg', 'gtk+-3.0',
'--pkg', 'gdk-x11-3.0',
'--pkg', 'libxfce4windowing-0',
'--vapidir', join_paths(meson.source_root(), 'vapi'),
]
'windowing',
libwindowing_sources,
dependencies: libwindowing_deps,
c_args: [
'-DWNCK_I_KNOW_THIS_IS_UNSTABLE',
],
vala_args: [
'--pkg', 'gio-unix-2.0',
'--pkg', 'gtk+-3.0',
'--pkg', 'gdk-x11-3.0',
'--pkg', 'libxfce4windowing-0',
'--vapidir', join_paths(meson.source_root(), 'vapi'),
],
)

link_libwindowing = declare_dependency(
link_with: libwindowing,
include_directories: [
include_directories('.'),
],
link_with: libwindowing,
include_directories: [
include_directories('.'),
],
)

# Expose the current directory so that we can use vapidir
Expand Down
Loading

0 comments on commit c14beb8

Please sign in to comment.