Skip to content

Commit

Permalink
Fix #26, ensure Budgie Desktop View updates position and geometry on …
Browse files Browse the repository at this point in the history
…root window workarea change.

Ew, X11 code being added at this point?
  • Loading branch information
JoshStrobl committed Oct 10, 2023
1 parent 6ec5656 commit 6283dcb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gnome_stack = '>= 3.24.0'
dep_glib = dependency('glib-2.0', version: glib_dep)
dep_gio = dependency('gio-unix-2.0', version: glib_dep)
dep_gdk = dependency('gdk-3.0', version: gnome_stack)
dep_gdk_x11 = dependency('gdk-x11-3.0', version: gnome_stack)
dep_gtk = dependency('gtk+-3.0', version: gnome_stack)
dep_vala = dependency('vapigen', version: '>= 0.48.0')

Expand Down
24 changes: 21 additions & 3 deletions src/budgie_desktop_view.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class DesktopView : Gtk.ApplicationWindow {
Screen default_screen;
Display default_display;
Monitor primary_monitor;
Rectangle primary_monitor_geo;
Rectangle? primary_monitor_geo = null;
UnifiedProps shared_props;
Raven? raven = null;

Expand Down Expand Up @@ -161,6 +161,8 @@ public class DesktopView : Gtk.ApplicationWindow {
default_screen.monitors_changed.connect(on_resolution_change);
default_screen.size_changed.connect(on_resolution_change);

setup_root_window_event_handler();

add(flow);

shared_props.icon_theme = Gtk.IconTheme.get_default(); // Get the current icon theme
Expand All @@ -187,6 +189,7 @@ public class DesktopView : Gtk.ApplicationWindow {

if (visible_setting) {
show();
get_display_geo();
}

Bus.watch_name(BusType.SESSION, RAVEN_DBUS_NAME, BusNameWatcherFlags.NONE, has_raven, on_raven_lost);
Expand Down Expand Up @@ -516,7 +519,6 @@ public class DesktopView : Gtk.ApplicationWindow {

primary_monitor_geo = primary_monitor.get_workarea(); // Get the working area of this monitor
shared_props.s_factor = primary_monitor.get_scale_factor(); // Get the current scaling factor
flow.set_size_request(primary_monitor_geo.width, primary_monitor_geo.height);
update_window_position();
}

Expand Down Expand Up @@ -992,6 +994,22 @@ public class DesktopView : Gtk.ApplicationWindow {
enforce_content_limit(); // Update our flowbox content limit based on icon / item sizing
}

public void setup_root_window_event_handler() {
Gdk.Window root_window = default_screen.get_root_window();
root_window.set_events(EventMask.ALL_EVENTS_MASK);

root_window.add_filter((xevent, e) => {
X.Event xev = *((X.Event*) xevent);

if (xev.type != X.EventType.PropertyNotify) return FilterReturn.CONTINUE;
if (xev.xproperty.atom == Gdk.X11.get_xatom_by_name("_NET_WORKAREA")) {
get_display_geo();
}

return FilterReturn.CONTINUE;
});
}

// create_fileitem_sorter will create our fileitem sorter
// Folders should go before files, with the values of each being collated
private void create_fileitem_sorter() {
Expand Down Expand Up @@ -1070,7 +1088,7 @@ public class DesktopView : Gtk.ApplicationWindow {

private void update_window_position() {
set_default_size(primary_monitor_geo.width, primary_monitor_geo.height);
set_size_request(primary_monitor_geo.width, primary_monitor_geo.height);
flow.set_size_request(primary_monitor_geo.width, primary_monitor_geo.height);
move(primary_monitor_geo.x, primary_monitor_geo.y); // Move the window to the x/y of our primary monitor
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ desktop_view_sources = [

desktop_view_deps = [
dep_gdk,
dep_gdk_x11,
dep_glib,
dep_gio,
dep_gtk
Expand Down

0 comments on commit 6283dcb

Please sign in to comment.