From 745d10e35f52702b3b7961e8c77b093e795af164 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Tue, 17 Sep 2024 18:52:13 +0200 Subject: [PATCH 1/8] Port to GTK4 --- lib/meson.build | 12 +-- meson.build | 8 +- sample/SampleIndicator.vala | 4 +- src/Application.vala | 2 +- src/PanelWindow.vala | 46 +++++----- src/Services/PopoverManager.vala | 20 +++-- src/Widgets/IndicatorBar.vala | 7 +- src/Widgets/IndicatorEntry.vala | 24 ++--- src/Widgets/IndicatorPopover.vala | 4 +- src/Widgets/Panel.vala | 140 ++++++++---------------------- vapi/libmutter.deps | 2 - 11 files changed, 100 insertions(+), 169 deletions(-) diff --git a/lib/meson.build b/lib/meson.build index 93e2f384..14af195b 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,4 +1,4 @@ -indicators_dir = join_paths(get_option('prefix'), get_option('libdir'), 'wingpanel') +indicators_dir = join_paths(get_option('prefix'), get_option('libdir'), 'wingpanel-8') config_vapi = meson.get_compiler('vala').find_library('config', dirs: meson.current_source_dir()) @@ -22,10 +22,10 @@ libwingpanel_deps = [ libwingpanel_lib = library('wingpanel', 'Indicator.vala', 'IndicatorManager.vala', - 'Widgets/Container.vala', - 'Widgets/OverlayIcon.vala', - 'Widgets/Separator.vala', - 'Widgets/Switch.vala', + # 'Widgets/Container.vala', + # 'Widgets/OverlayIcon.vala', + # 'Widgets/Separator.vala', + # 'Widgets/Switch.vala', config_header, dependencies: [libwingpanel_deps, config_vapi], vala_header: 'wingpanel.h', @@ -41,7 +41,7 @@ pkg.generate( description: 'Wingpanel Indicators API', version: meson.project_version(), subdirs: 'wingpanel', - variables: ['indicatorsdir=${libdir}/wingpanel'], + variables: ['indicatorsdir=${libdir}/wingpanel-8'], requires: libwingpanel_deps ) diff --git a/meson.build b/meson.build index f37998de..e8449694 100644 --- a/meson.build +++ b/meson.build @@ -28,14 +28,14 @@ glib_dep = dependency('glib-2.0', version: '>=2.32') gio_dep = dependency('gio-2.0') gio_unix_dep = dependency('gio-unix-2.0') gmodule_dep = dependency('gmodule-2.0') -gdk_wl_dep = dependency('gdk-wayland-3.0') +gdk_wl_dep = dependency('gtk4-wayland') # GDK X11 dep is for detecting whether we're on Wayland or not ONLY, we don't actually have # a hard X11 dependency here -gdk_x11_dep = dependency('gdk-x11-3.0') +gdk_x11_dep = dependency('gtk4-x11') x11_dep = dependency('x11') -gtk_dep = dependency('gtk+-3.0', version: '>=3.10') +gtk_dep = dependency('gtk4') gee_dep = dependency('gee-0.8') -granite_dep = dependency('granite', version: '>=5.4.0') +granite_dep = dependency('granite-7') posix_dep = meson.get_compiler('vala').find_library('posix') wl_client_dep = dependency('wayland-client') diff --git a/sample/SampleIndicator.vala b/sample/SampleIndicator.vala index 807ef5b9..8051d3b4 100644 --- a/sample/SampleIndicator.vala +++ b/sample/SampleIndicator.vala @@ -57,8 +57,8 @@ public class Sample.Indicator : Wingpanel.Indicator { }; var hide_button = new Gtk.Button.with_label (_("Hide me!")); - hide_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); - hide_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM); + hide_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); + hide_button.get_style_context ().add_class (Granite.STYLE_CLASS_MENUITEM); var compositing_switch = new Granite.SwitchModelButton (_("Composited Icon")); diff --git a/src/Application.vala b/src/Application.vala index ffd871b0..f30ac9ea 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -113,7 +113,7 @@ public class Wingpanel.Application : Gtk.Application { base.startup (); panel_window = new PanelWindow (this); - panel_window.show_all (); + panel_window.present (); register_actions (); } diff --git a/src/PanelWindow.vala b/src/PanelWindow.vala index 1dc194b8..7a4b24db 100644 --- a/src/PanelWindow.vala +++ b/src/PanelWindow.vala @@ -34,21 +34,22 @@ public class Wingpanel.PanelWindow : Gtk.Window { public PanelWindow (Gtk.Application application) { Object ( application: application, - app_paintable: true, + // app_paintable: true, decorated: false, resizable: false, - skip_pager_hint: true, - skip_taskbar_hint: true, + // skip_pager_hint: true, + // skip_taskbar_hint: true, vexpand: false ); var app_provider = new Gtk.CssProvider (); app_provider.load_from_resource ("io/elementary/wingpanel/Application.css"); - Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - this.screen.size_changed.connect (update_panel_dimensions); - this.screen.monitors_changed.connect (update_panel_dimensions); - this.screen_changed.connect (update_visual); + // var display = Gdk.Display.get_default (); + // display.size_changed.connect (update_panel_dimensions); + // display.monitors_changed.connect (update_panel_dimensions); + // display.screen_changed.connect (update_visual); update_visual (); @@ -76,10 +77,11 @@ public class Wingpanel.PanelWindow : Gtk.Window { child = revealer; - key_controller = new Gtk.EventControllerKey (this); + key_controller = new Gtk.EventControllerKey (); + ((Gtk.Widget) this).add_controller (key_controller); key_controller.key_pressed.connect (on_key_pressed); - panel.size_allocate.connect (update_panel_dimensions); + // panel.size_allocate.connect (update_panel_dimensions); } private void on_realize () { @@ -88,7 +90,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { if (Gdk.Display.get_default () is Gdk.Wayland.Display) { // We have to wrap in Idle otherwise the Meta.Window of the WaylandSurface in Gala is still null - Idle.add_once (init_wl); + init_wl (); } else { init_x (); } @@ -98,7 +100,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { panel_height = panel.get_allocated_height (); // We just use our monitor because Gala makes sure we are always on the primary one - var monitor_dimensions = get_display ().get_monitor_at_window (get_window ()).get_geometry (); + var monitor_dimensions = get_display ().get_monitor_at_surface (get_surface ()).get_geometry (); if (!Services.DisplayConfig.is_logical_layout () && Gdk.Display.get_default () is Gdk.Wayland.Display) { monitor_dimensions.width /= get_scale_factor (); @@ -114,13 +116,13 @@ public class Wingpanel.PanelWindow : Gtk.Window { } private void update_visual () { - var visual = this.screen.get_rgba_visual (); + // var visual = this.screen.get_rgba_visual (); - if (visual == null) { - warning ("Compositing not available, things will Look Bad (TM)"); - } else { - this.set_visual (visual); - } + // if (visual == null) { + // warning ("Compositing not available, things will Look Bad (TM)"); + // } else { + // this.set_visual (visual); + // } } private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { @@ -146,7 +148,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { this.expanded = false; this.set_size_request (monitor_width, -1); - this.resize (monitor_width, 1); + this.set_default_size (monitor_width, 1); } } @@ -171,7 +173,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { if (display is Gdk.X11.Display) { unowned var xdisplay = ((Gdk.X11.Display) display).get_xdisplay (); - var window = ((Gdk.X11.Window) get_window ()).get_xid (); + var window = ((Gdk.X11.Surface) get_surface ()).get_xid (); var prop = xdisplay.intern_atom ("_MUTTER_HINTS", false); @@ -184,9 +186,9 @@ public class Wingpanel.PanelWindow : Gtk.Window { public void registry_handle_global (Wl.Registry wl_registry, uint32 name, string @interface, uint32 version) { if (@interface == "io_elementary_pantheon_shell_v1") { desktop_shell = wl_registry.bind (name, ref Pantheon.Desktop.Shell.iface, uint32.min (version, 1)); - unowned var window = get_window (); - if (window is Gdk.Wayland.Window) { - unowned var wl_surface = ((Gdk.Wayland.Window) window).get_wl_surface (); + unowned var window = get_surface (); + if (window is Gdk.Wayland.Surface) { + unowned var wl_surface = ((Gdk.Wayland.Surface) window).get_wl_surface (); desktop_panel = desktop_shell.get_panel (wl_surface); desktop_panel.set_anchor (TOP); desktop_panel.set_hide_mode (NEVER); diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index cd387bbe..fa6bb95f 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -20,7 +20,7 @@ public class Wingpanel.Services.PopoverManager : Object { private unowned Wingpanel.PanelWindow? owner; - private Gtk.GestureMultiPress owner_gesture_controller; + private Gtk.GestureClick owner_gesture_controller; private Gee.HashMap registered_indicators; private Wingpanel.Widgets.IndicatorPopover popover; @@ -49,17 +49,18 @@ public class Wingpanel.Services.PopoverManager : Object { _current_indicator = value; } + popover.unparent (); + if (_current_indicator != null) { popover.set_content (_current_indicator.indicator_widget); - popover.relative_to = _current_indicator; update_has_tooltip (_current_indicator.display_widget, false); - owner.set_expanded (true); - owner.present (); + // owner.set_expanded (true); + // owner.present (); + popover.set_parent (_current_indicator); popover.popup (); - popover.show_all (); _current_indicator.base_indicator.opened (); } else { - update_has_tooltip (((Wingpanel.Widgets.IndicatorEntry)popover.get_relative_to ()).display_widget); + update_has_tooltip (((Wingpanel.Widgets.IndicatorEntry)popover.parent).display_widget); popover.popdown (); } } @@ -85,13 +86,14 @@ public class Wingpanel.Services.PopoverManager : Object { }); }); - owner_gesture_controller = new Gtk.GestureMultiPress (owner) { - window = owner.get_window () + owner_gesture_controller = new Gtk.GestureClick () { + propagation_limit = SAME_NATIVE }; + ((Gtk.Widget) owner).add_controller (owner_gesture_controller); owner_gesture_controller.pressed.connect (() => current_indicator = null); //Replace with EventController propagation limit SAME_NATIVE in GTK 4 - owner.realize.connect (() => owner_gesture_controller.window = owner.get_window ()); + // owner.realize.connect (() => owner_gesture_controller.window = owner.get_window ()); } public void set_popover_visible (string code_name, bool visible) { diff --git a/src/Widgets/IndicatorBar.vala b/src/Widgets/IndicatorBar.vala index 63f39955..a7eba1cd 100644 --- a/src/Widgets/IndicatorBar.vala +++ b/src/Widgets/IndicatorBar.vala @@ -34,20 +34,19 @@ public class Wingpanel.Widgets.IndicatorBar : Gtk.Box { } if (item.base_indicator.visible) { - var index = 0; + Gtk.Widget? previous = null; foreach (var i in sorted_items) { if (i == item) { break; } if (i.base_indicator.visible) { - index++; + previous = i; } } if (item.get_parent () != this) { - add (item); - reorder_child (item, index); + insert_child_after (item, previous); } } } diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index d1fe84ba..fec267cc 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { +public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { public Indicator base_indicator { get; construct; } public Services.PopoverManager popover_manager { get; construct; } @@ -37,7 +37,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { private Gtk.Revealer revealer; - private Gtk.GestureMultiPress gesture_controller; + private Gtk.GestureClick gesture_controller; private Gtk.EventControllerMotion motion_controller; public IndicatorEntry (Indicator base_indicator, Services.PopoverManager popover_manager) { @@ -62,7 +62,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { }; revealer.get_style_context ().add_class ("composited-indicator"); - add (revealer); + append (revealer); if (base_indicator.visible) { popover_manager.register_indicator (this); @@ -92,24 +92,26 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { } }); - add_events (Gdk.EventMask.SCROLL_MASK); - add_events (Gdk.EventMask.SMOOTH_SCROLL_MASK); + // add_events (Gdk.EventMask.SCROLL_MASK); + // add_events (Gdk.EventMask.SMOOTH_SCROLL_MASK); - scroll_event.connect ((e) => { - return display_widget.scroll_event (e); - }); + // scroll_event.connect ((e) => { + // return display_widget.scroll_event (e); + // }); - button_press_event.connect ((e) => display_widget.button_press_event (e)); + // button_press_event.connect ((e) => display_widget.button_press_event (e)); - gesture_controller = new Gtk.GestureMultiPress (this); + gesture_controller = new Gtk.GestureClick (); + add_controller (gesture_controller); gesture_controller.pressed.connect (() => { popover_manager.current_indicator = this; gesture_controller.set_state (CLAIMED); }); - motion_controller = new Gtk.EventControllerMotion (this) { + motion_controller = new Gtk.EventControllerMotion () { propagation_phase = CAPTURE }; + add_controller (motion_controller); motion_controller.enter.connect (() => { // If something is open and it's not us, open us. This implements the scrubbing behavior diff --git a/src/Widgets/IndicatorPopover.vala b/src/Widgets/IndicatorPopover.vala index 20fdb0e7..c328369c 100644 --- a/src/Widgets/IndicatorPopover.vala +++ b/src/Widgets/IndicatorPopover.vala @@ -24,7 +24,7 @@ public class Wingpanel.Widgets.IndicatorPopover : Gtk.Popover { construct { width_request = 256; - modal = false; + // modal = false; name = name + "/popover"; position = Gtk.PositionType.BOTTOM; @@ -47,7 +47,7 @@ public class Wingpanel.Widgets.IndicatorPopover : Gtk.Popover { } if (content != null) { - container.add (content); + container.append (content); widget = content; } } diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index 19304f05..1e817c92 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.Panel : Gtk.EventBox { +public class Wingpanel.Widgets.Panel : Gtk.Box { private static Settings panel_settings = new Settings ("io.elementary.desktop.wingpanel"); public Services.PopoverManager popover_manager { get; construct; } @@ -29,7 +29,7 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { private unowned Gtk.StyleContext style_context; private Gtk.CssProvider? style_provider = null; - private Gtk.GestureMultiPress gesture_controller; + private Gtk.GestureClick gesture_controller; private Gtk.EventControllerScroll scroll_controller; private double current_scroll_delta = 0; @@ -57,12 +57,14 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { halign = END }; - var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - box.pack_start (left_menubar); + var box = new Gtk.CenterBox () { + hexpand = true + }; + box.set_start_widget (left_menubar); box.set_center_widget (center_menubar); - box.pack_end (right_menubar); + box.set_end_widget (right_menubar); - add (box); + append (box); unowned IndicatorManager indicator_manager = IndicatorManager.get_default (); indicator_manager.indicator_added.connect (add_indicator); @@ -78,18 +80,20 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { Services.BackgroundManager.get_default ().background_state_changed.connect (update_background); - gesture_controller = new Gtk.GestureMultiPress (this); + gesture_controller = new Gtk.GestureClick (); + add_controller (gesture_controller); gesture_controller.pressed.connect ((n_press, x, y) => { begin_drag (x, y); gesture_controller.set_state (CLAIMED); gesture_controller.reset (); }); - scroll_controller = new Gtk.EventControllerScroll (this, BOTH_AXES); + scroll_controller = new Gtk.EventControllerScroll (BOTH_AXES); + add_controller (scroll_controller); scroll_controller.scroll_end.connect (() => current_scroll_delta = 0); scroll_controller.scroll.connect ((dx, dy) => { if (!panel_settings.get_boolean ("scroll-to-switch-workspaces")) { - return; + return Gdk.EVENT_PROPAGATE; } if (current_scroll_delta == 0) { @@ -105,12 +109,12 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } private void begin_drag (double x, double y) { - var window = get_window (); + var window = get_root ().get_surface (); if (window == null) { return; } - window.get_display ().get_default_seat ().ungrab (); + // window.get_display ().get_default_seat ().ungrab (); popover_manager.close (); @@ -137,111 +141,37 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } private IndicatorEntry? get_next_sibling (IndicatorEntry current) { - IndicatorEntry? sibling = null; + Gtk.Widget? sibling = current.get_next_sibling (); + + if (sibling != null) { + return (IndicatorEntry) sibling; + } switch (current.base_indicator.code_name) { case Indicator.APP_LAUNCHER: - var children = left_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index < children.length () - 1) { // Has more than one indicator in the left menubar - sibling = children.nth_data (index + 1) as IndicatorEntry; - } else { // No more indicators on the left - var center_children = center_menubar.get_children (); - if (center_children.length () > 0) { - sibling = center_children.first ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) center_menubar.get_last_child (); case Indicator.DATETIME: - var children = center_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index < children.length () - 1) { // Has more than one indicator in the center menubar - sibling = children.nth_data (index + 1) as IndicatorEntry; - } else { // No more indicators on the center - var right_children = right_menubar.get_children (); - if (right_children.length () > 0) { - sibling = right_children.first ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) right_menubar.get_last_child (); default: - var children = right_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index < children.length () - 1) { // Has more than one indicator in the right menubar - sibling = children.nth_data (index + 1) as IndicatorEntry; - } else { // No more indicators on the right - var left_children = left_menubar.get_children (); - if (left_children.length () > 0) { - sibling = left_children.first ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) left_menubar.get_last_child (); } - - return sibling; } private IndicatorEntry? get_previous_sibling (IndicatorEntry current) { - IndicatorEntry? sibling = null; + Gtk.Widget? sibling = current.get_prev_sibling (); + + if (sibling != null) { + return (IndicatorEntry) sibling; + } switch (current.base_indicator.code_name) { case Indicator.APP_LAUNCHER: - var children = left_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index != 0) { // Is not the first indicator in the left menubar - sibling = children.nth_data (index - 1) as IndicatorEntry; - } else { // No more indicators on the left - var right_children = right_menubar.get_children (); - if (right_children.length () > 0) { - sibling = right_children.last ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) right_menubar.get_last_child (); case Indicator.DATETIME: - var children = center_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index != 0) { // Is not the first indicator in the center menubar - sibling = children.nth_data (index - 1) as IndicatorEntry; - } else { // No more indicators on the center - var left_children = left_menubar.get_children (); - if (left_children.length () > 0) { - sibling = left_children.last ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) left_menubar.get_last_child (); default: - var children = right_menubar.get_children (); - int index = children.index (current); - if (index == -1) { - break; - } else if (index != 0) { // Is not the first indicator in the right menubar - sibling = children.nth_data (index - 1) as IndicatorEntry; - } else { // No more indicators on the right - var center_children = center_menubar.get_children (); - if (center_children.length () > 0) { - sibling = center_children.last ().data as IndicatorEntry; - } - } - - break; + return (IndicatorEntry) center_menubar.get_last_child (); } - - return sibling; } private void add_indicator (Indicator indicator) { @@ -250,19 +180,17 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { switch (indicator.code_name) { case Indicator.APP_LAUNCHER: indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_RIGHT); - left_menubar.add (indicator_entry); + left_menubar.insert_sorted (indicator_entry); break; case Indicator.DATETIME: indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_DOWN); - center_menubar.add (indicator_entry); + center_menubar.insert_sorted (indicator_entry); break; default: indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_LEFT); right_menubar.insert_sorted (indicator_entry); break; } - - indicator_entry.show_all (); } private void remove_indicator (Indicator indicator) { @@ -284,7 +212,7 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { """.printf (animation_duration); try { - style_provider.load_from_data (css, css.length); + style_provider.load_from_string (css); } catch (Error e) { warning ("Parsing own style configuration failed: %s", e.message); } diff --git a/vapi/libmutter.deps b/vapi/libmutter.deps index 1c90561b..94d101b8 100644 --- a/vapi/libmutter.deps +++ b/vapi/libmutter.deps @@ -1,7 +1,5 @@ cairo gdesktopenums-3.0 -gdk-3.0 gdk-pixbuf-2.0 -gtk+-3.0 x11 xfixes-4.0 From ebe8ad3bb5c7727bbf9ee266b0b83ab225e58935 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Tue, 17 Sep 2024 19:05:28 +0200 Subject: [PATCH 2/8] Cleanup --- src/PanelWindow.vala | 27 +++++---------------------- src/Services/PopoverManager.vala | 4 ++-- src/Widgets/IndicatorPopover.vala | 1 - 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/PanelWindow.vala b/src/PanelWindow.vala index 7a4b24db..c66573ad 100644 --- a/src/PanelWindow.vala +++ b/src/PanelWindow.vala @@ -34,11 +34,8 @@ public class Wingpanel.PanelWindow : Gtk.Window { public PanelWindow (Gtk.Application application) { Object ( application: application, - // app_paintable: true, decorated: false, resizable: false, - // skip_pager_hint: true, - // skip_taskbar_hint: true, vexpand: false ); @@ -46,13 +43,6 @@ public class Wingpanel.PanelWindow : Gtk.Window { app_provider.load_from_resource ("io/elementary/wingpanel/Application.css"); Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - // var display = Gdk.Display.get_default (); - // display.size_changed.connect (update_panel_dimensions); - // display.monitors_changed.connect (update_panel_dimensions); - // display.screen_changed.connect (update_visual); - - update_visual (); - popover_manager = new Services.PopoverManager (this); panel = new Widgets.Panel (popover_manager); @@ -81,7 +71,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { ((Gtk.Widget) this).add_controller (key_controller); key_controller.key_pressed.connect (on_key_pressed); - // panel.size_allocate.connect (update_panel_dimensions); + panel.map.connect (update_panel_dimensions); } private void on_realize () { @@ -89,7 +79,6 @@ public class Wingpanel.PanelWindow : Gtk.Window { Services.BackgroundManager.initialize (panel_height); if (Gdk.Display.get_default () is Gdk.Wayland.Display) { - // We have to wrap in Idle otherwise the Meta.Window of the WaylandSurface in Gala is still null init_wl (); } else { init_x (); @@ -115,16 +104,6 @@ public class Wingpanel.PanelWindow : Gtk.Window { this.set_size_request (monitor_width, (popover_manager.current_indicator != null ? monitor_height : -1)); } - private void update_visual () { - // var visual = this.screen.get_rgba_visual (); - - // if (visual == null) { - // warning ("Compositing not available, things will Look Bad (TM)"); - // } else { - // this.set_visual (visual); - // } - } - private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { if (keyval == Gdk.Key.Escape) { popover_manager.close (); @@ -134,6 +113,10 @@ public class Wingpanel.PanelWindow : Gtk.Window { } public void set_expanded (bool expand) { + if (Gdk.Display.get_default () is Gdk.Wayland.Display) { + return; + } + if (expand && !this.expanded) { Services.BackgroundManager.get_default ().remember_window (); diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index fa6bb95f..2b7fa6ec 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -54,8 +54,8 @@ public class Wingpanel.Services.PopoverManager : Object { if (_current_indicator != null) { popover.set_content (_current_indicator.indicator_widget); update_has_tooltip (_current_indicator.display_widget, false); - // owner.set_expanded (true); - // owner.present (); + owner.set_expanded (true); + owner.present (); popover.set_parent (_current_indicator); popover.popup (); _current_indicator.base_indicator.opened (); diff --git a/src/Widgets/IndicatorPopover.vala b/src/Widgets/IndicatorPopover.vala index c328369c..771a5cc0 100644 --- a/src/Widgets/IndicatorPopover.vala +++ b/src/Widgets/IndicatorPopover.vala @@ -24,7 +24,6 @@ public class Wingpanel.Widgets.IndicatorPopover : Gtk.Popover { construct { width_request = 256; - // modal = false; name = name + "/popover"; position = Gtk.PositionType.BOTTOM; From 626b0e454d0853ccae206af4a4d571ea5be31147 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Tue, 17 Sep 2024 19:07:28 +0200 Subject: [PATCH 3/8] More cleanup --- lib/Widgets/Container.vala | 38 ---------------- lib/Widgets/OverlayIcon.vala | 84 ------------------------------------ lib/Widgets/Separator.vala | 29 ------------- lib/Widgets/Switch.vala | 80 ---------------------------------- lib/meson.build | 4 -- 5 files changed, 235 deletions(-) delete mode 100644 lib/Widgets/Container.vala delete mode 100644 lib/Widgets/OverlayIcon.vala delete mode 100644 lib/Widgets/Separator.vala delete mode 100644 lib/Widgets/Switch.vala diff --git a/lib/Widgets/Container.vala b/lib/Widgets/Container.vala deleted file mode 100644 index 68ab75c9..00000000 --- a/lib/Widgets/Container.vala +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011-2017 elementary LLC (https://elementary.io) - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - */ - -[Version (deprecated = true, deprecated_since = "3.0.0", replacement = "Gtk.ModelButton")] -public class Wingpanel.Widgets.Container : Gtk.Button { - public Gtk.Grid content_widget { owned get; construct; } - - public extern Gtk.Grid get_content_widget (); - - public Container () {} - - construct { - content_widget = new Gtk.Grid (); - content_widget.hexpand = true; - add (content_widget); - - var style_context = this.get_style_context (); - style_context.add_class (Gtk.STYLE_CLASS_MENUITEM); - style_context.remove_class (Gtk.STYLE_CLASS_BUTTON); - style_context.remove_class ("text-button"); - } -} diff --git a/lib/Widgets/OverlayIcon.vala b/lib/Widgets/OverlayIcon.vala deleted file mode 100644 index 69b3e1cd..00000000 --- a/lib/Widgets/OverlayIcon.vala +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011-2017 elementary LLC (https://elementary.io) - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - */ - -public class Wingpanel.Widgets.OverlayIcon : Gtk.Overlay { - private Gtk.Image main_image; - private Gtk.Image overlay_image; - - public OverlayIcon (string icon_name) { - set_main_icon_name (icon_name); - } - - public OverlayIcon.from_pixbuf (Gdk.Pixbuf pixbuf) { - set_main_pixbuf (pixbuf); - } - - construct { - main_image = new Gtk.Image (); - main_image.icon_size = 24; - main_image.pixel_size = 24; - - overlay_image = new Gtk.Image (); - overlay_image.icon_size = 24; - overlay_image.pixel_size = 24; - - add (main_image); - add_overlay (overlay_image); - } - - public void set_main_pixbuf (Gdk.Pixbuf? pixbuf) { - main_image.set_from_pixbuf (pixbuf); - } - - public Gdk.Pixbuf? get_main_pixbuf () { - return main_image.get_pixbuf (); - } - - public void set_overlay_pixbuf (Gdk.Pixbuf? pixbuf) { - overlay_image.set_from_pixbuf (pixbuf); - } - - public Gdk.Pixbuf? get_overlay_pixbuf () { - return overlay_image.get_pixbuf (); - } - - public void set_main_icon_name (string icon_name) { - main_image.icon_name = icon_name; - } - - public string get_main_icon_name () { - return main_image.icon_name; - } - - public void set_overlay_icon_name (string icon_name) { - overlay_image.icon_name = icon_name; - } - - public string get_overlay_icon_name () { - return overlay_image.icon_name; - } - - public Gtk.Image get_main_image () { - return main_image; - } - - public Gtk.Image get_overlay_image () { - return overlay_image; - } -} diff --git a/lib/Widgets/Separator.vala b/lib/Widgets/Separator.vala deleted file mode 100644 index 0d849ab0..00000000 --- a/lib/Widgets/Separator.vala +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2011-2017 elementary LLC (https://elementary.io) - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - */ - -[Version (deprecated = true, deprecated_since = "3.0.0", replacement = "Gtk.Separator")] -public class Wingpanel.Widgets.Separator : Gtk.Separator { - public Separator () { - Object ( - margin_bottom: 3, - margin_top: 3, - orientation: Gtk.Orientation.HORIZONTAL - ); - } -} diff --git a/lib/Widgets/Switch.vala b/lib/Widgets/Switch.vala deleted file mode 100644 index 341e3eda..00000000 --- a/lib/Widgets/Switch.vala +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011-2018 elementary, Inc. (https://elementary.io) - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - */ - -[Version (deprecated = true, deprecated_since = "3.0.0", replacement = "Granite.SwitchModelButton")] -public class Wingpanel.Widgets.Switch : Gtk.Bin { - public bool active { get; set; } - public string caption { owned get; set; } - - private Gtk.Label button_label; - private Gtk.Switch button_switch; - - public Switch (string caption, bool active = false) { - Object (caption: caption, active: active); - } - - public Switch.with_mnemonic (string caption, bool active = false) { - Object (caption: caption, active: active); - button_label.set_text_with_mnemonic (caption); - button_label.set_mnemonic_widget (this); - } - - construct { - button_switch = new Gtk.Switch (); - button_switch.active = active; - button_switch.halign = Gtk.Align.END; - button_switch.hexpand = true; - button_switch.valign = Gtk.Align.CENTER; - - button_label = new Gtk.Label (null); - button_label.halign = Gtk.Align.START; - - var grid = new Gtk.Grid (); - grid.column_spacing = 12; - grid.attach (button_label, 0, 0); - grid.attach (button_switch, 1, 0); - - var modelbutton = new Gtk.ModelButton (); - modelbutton.get_child ().destroy (); - modelbutton.add (grid); - - add (modelbutton); - - modelbutton.button_release_event.connect (() => { - toggle_switch (); - // Stop modelbutton from closing the popover - return Gdk.EVENT_STOP; - }); - - bind_property ("active", button_switch, "active", GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.BIDIRECTIONAL); - bind_property ("caption", button_label, "label", GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.BIDIRECTIONAL); - } - - public new Gtk.Label get_label () { - return button_label; - } - - public Gtk.Switch get_switch () { - return button_switch; - } - - public void toggle_switch () { - button_switch.activate (); - } -} diff --git a/lib/meson.build b/lib/meson.build index 14af195b..37a32ab3 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -22,10 +22,6 @@ libwingpanel_deps = [ libwingpanel_lib = library('wingpanel', 'Indicator.vala', 'IndicatorManager.vala', - # 'Widgets/Container.vala', - # 'Widgets/OverlayIcon.vala', - # 'Widgets/Separator.vala', - # 'Widgets/Switch.vala', config_header, dependencies: [libwingpanel_deps, config_vapi], vala_header: 'wingpanel.h', From 44fda80b69e66492ba76e62ca784dafee18e1ef3 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 18 Sep 2024 14:26:54 +0200 Subject: [PATCH 4/8] Fix X and cleanup --- src/PanelWindow.vala | 80 ++++++++++---------------------- src/Services/PopoverManager.vala | 33 ++----------- src/Widgets/Panel.vala | 15 ++++-- 3 files changed, 39 insertions(+), 89 deletions(-) diff --git a/src/PanelWindow.vala b/src/PanelWindow.vala index c66573ad..6d75134b 100644 --- a/src/PanelWindow.vala +++ b/src/PanelWindow.vala @@ -21,12 +21,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { public Services.PopoverManager popover_manager; private Widgets.Panel panel; - private Gtk.EventControllerKey key_controller; // For keeping in memory - private Gtk.Revealer revealer; - private int monitor_width; - private int monitor_height; private int panel_height; - private bool expanded = false; private Pantheon.Desktop.Shell? desktop_shell; private Pantheon.Desktop.Panel? desktop_panel; @@ -43,7 +38,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { app_provider.load_from_resource ("io/elementary/wingpanel/Application.css"); Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - popover_manager = new Services.PopoverManager (this); + popover_manager = new Services.PopoverManager (); panel = new Widgets.Panel (popover_manager); panel.realize.connect (on_realize); @@ -59,19 +54,29 @@ public class Wingpanel.PanelWindow : Gtk.Window { application.set_accels_for_action ("app.cycle", {"Tab"}); application.set_accels_for_action ("app.cycle-back", {"Tab"}); - revealer = new Gtk.Revealer () { - child = panel, - reveal_child = true, - transition_type = NONE - }; + child = panel; - child = revealer; + popover_manager.notify["indicator-open"].connect (() => { + if (!popover_manager.indicator_open) { + Services.BackgroundManager.get_default ().restore_window (); + return; + } else { + Services.BackgroundManager.get_default ().remember_window (); + } + + if (desktop_panel != null) { + desktop_panel.focus (); + } else if (Gdk.Display.get_default () is Gdk.X11.Display) { + var display = (Gdk.X11.Display) Gdk.Display.get_default (); + var surface = (Gdk.X11.Surface) get_surface (); + + display.get_xdisplay ().set_input_focus (surface.get_xid (), 0, 0); + } + }); - key_controller = new Gtk.EventControllerKey (); + var key_controller = new Gtk.EventControllerKey (); ((Gtk.Widget) this).add_controller (key_controller); key_controller.key_pressed.connect (on_key_pressed); - - panel.map.connect (update_panel_dimensions); } private void on_realize () { @@ -98,10 +103,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { monitor_dimensions.y /= get_scale_factor (); } - monitor_width = monitor_dimensions.width; - monitor_height = monitor_dimensions.height; - - this.set_size_request (monitor_width, (popover_manager.current_indicator != null ? monitor_height : -1)); + this.set_size_request (monitor_dimensions.width, -1); } private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { @@ -112,43 +114,8 @@ public class Wingpanel.PanelWindow : Gtk.Window { return Gdk.EVENT_PROPAGATE; } - public void set_expanded (bool expand) { - if (Gdk.Display.get_default () is Gdk.Wayland.Display) { - return; - } - - if (expand && !this.expanded) { - Services.BackgroundManager.get_default ().remember_window (); - - this.expanded = true; - this.set_size_request (monitor_width, monitor_height); - - if (desktop_panel != null) { - desktop_panel.focus (); - } - } else if (!expand) { - Services.BackgroundManager.get_default ().restore_window (); - - this.expanded = false; - this.set_size_request (monitor_width, -1); - this.set_default_size (monitor_width, 1); - } - } - public void toggle_indicator (string name) { popover_manager.toggle_popover_visible (name); - - if (desktop_panel != null) { - desktop_panel.focus (); - } - } - - private int get_actual_height () { - if (!Services.DisplayConfig.is_logical_layout () && Gdk.Display.get_default () is Gdk.Wayland.Display) { - return get_allocated_height () * get_scale_factor (); - } - - return get_allocated_height (); } private void init_x () { @@ -160,9 +127,11 @@ public class Wingpanel.PanelWindow : Gtk.Window { var prop = xdisplay.intern_atom ("_MUTTER_HINTS", false); - var value = "anchor=4:hide-mode=0:size=-1,%d".printf (get_actual_height ()); + var value = "anchor=4:hide-mode=0"; xdisplay.change_property (window, prop, X.XA_STRING, 8, 0, (uchar[]) value, value.length); + + Idle.add_once (update_panel_dimensions); // Update again since we now can be 100% sure that we are on the primary monitor } } @@ -175,7 +144,6 @@ public class Wingpanel.PanelWindow : Gtk.Window { desktop_panel = desktop_shell.get_panel (wl_surface); desktop_panel.set_anchor (TOP); desktop_panel.set_hide_mode (NEVER); - desktop_panel.set_size (-1, get_actual_height ()); Idle.add_once (update_panel_dimensions); // Update again since we now can be 100% sure that we are on the primary monitor } diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 2b7fa6ec..be5e4c59 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -18,9 +18,7 @@ */ public class Wingpanel.Services.PopoverManager : Object { - private unowned Wingpanel.PanelWindow? owner; - - private Gtk.GestureClick owner_gesture_controller; + public bool indicator_open { get; private set; default = false; } private Gee.HashMap registered_indicators; private Wingpanel.Widgets.IndicatorPopover popover; @@ -36,8 +34,10 @@ public class Wingpanel.Services.PopoverManager : Object { } if (_current_indicator == null && value != null) { // First open + indicator_open = true; _current_indicator = value; } else if (value == null && _current_indicator != null) { // Close requested + indicator_open = false; _current_indicator.base_indicator.closed (); _current_indicator = null; } else if (_current_indicator.base_indicator.code_name == value.base_indicator.code_name) { // Close due to toggle @@ -49,13 +49,9 @@ public class Wingpanel.Services.PopoverManager : Object { _current_indicator = value; } - popover.unparent (); - if (_current_indicator != null) { popover.set_content (_current_indicator.indicator_widget); update_has_tooltip (_current_indicator.display_widget, false); - owner.set_expanded (true); - owner.present (); popover.set_parent (_current_indicator); popover.popup (); _current_indicator.base_indicator.opened (); @@ -66,34 +62,15 @@ public class Wingpanel.Services.PopoverManager : Object { } } - public PopoverManager (Wingpanel.PanelWindow? owner) { + public PopoverManager () { registered_indicators = new Gee.HashMap (); - this.owner = owner; - popover = new Wingpanel.Widgets.IndicatorPopover (); popover.closed.connect (() => { current_indicator = null; - - // We have to wait for unmap otherwise the popover is confined to the panel space - // on X. But we also can't just connect to it because unmap gets emitted when repositioning - // for some reason. - ulong handler_id = 0; - handler_id = popover.unmap.connect (() => { - owner.set_expanded (false); - popover.disconnect (handler_id); - }); + popover.unparent (); }); - - owner_gesture_controller = new Gtk.GestureClick () { - propagation_limit = SAME_NATIVE - }; - ((Gtk.Widget) owner).add_controller (owner_gesture_controller); - owner_gesture_controller.pressed.connect (() => current_indicator = null); - - //Replace with EventController propagation limit SAME_NATIVE in GTK 4 - // owner.realize.connect (() => owner_gesture_controller.window = owner.get_window ()); } public void set_popover_visible (string code_name, bool visible) { diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index 1e817c92..629401ff 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.Panel : Gtk.Box { +public class Wingpanel.Widgets.Panel : Gtk.Widget { private static Settings panel_settings = new Settings ("io.elementary.desktop.wingpanel"); public Services.PopoverManager popover_manager { get; construct; } @@ -26,6 +26,8 @@ public class Wingpanel.Widgets.Panel : Gtk.Box { private IndicatorBar left_menubar; private IndicatorBar center_menubar; + private Gtk.CenterBox box; + private unowned Gtk.StyleContext style_context; private Gtk.CssProvider? style_provider = null; @@ -39,6 +41,7 @@ public class Wingpanel.Widgets.Panel : Gtk.Box { class construct { set_css_name ("panel"); + set_layout_manager_type (typeof (Gtk.BinLayout)); } construct { @@ -57,14 +60,12 @@ public class Wingpanel.Widgets.Panel : Gtk.Box { halign = END }; - var box = new Gtk.CenterBox () { - hexpand = true - }; + box = new Gtk.CenterBox (); box.set_start_widget (left_menubar); box.set_center_widget (center_menubar); box.set_end_widget (right_menubar); - append (box); + box.set_parent (this); unowned IndicatorManager indicator_manager = IndicatorManager.get_default (); indicator_manager.indicator_added.connect (add_indicator); @@ -108,6 +109,10 @@ public class Wingpanel.Widgets.Panel : Gtk.Box { }); } + ~Panel () { + box.unparent (); + } + private void begin_drag (double x, double y) { var window = get_root ().get_surface (); if (window == null) { From 1294670686ac6ffb4391e959922b06d6f7423a7c Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 18 Sep 2024 14:30:10 +0200 Subject: [PATCH 5/8] Cleanup --- src/Widgets/IndicatorEntry.vala | 3 --- src/Widgets/Panel.vala | 14 +++++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index fec267cc..19184932 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -92,9 +92,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { } }); - // add_events (Gdk.EventMask.SCROLL_MASK); - // add_events (Gdk.EventMask.SMOOTH_SCROLL_MASK); - // scroll_event.connect ((e) => { // return display_widget.scroll_event (e); // }); diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index 629401ff..8b1c8dff 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -135,9 +135,9 @@ public class Wingpanel.Widgets.Panel : Gtk.Widget { IndicatorEntry? sibling; if (forward) { - sibling = get_next_sibling (current); + sibling = get_next_indicator (current); } else { - sibling = get_previous_sibling (current); + sibling = get_previous_indicator (current); } if (sibling != null) { @@ -145,7 +145,7 @@ public class Wingpanel.Widgets.Panel : Gtk.Widget { } } - private IndicatorEntry? get_next_sibling (IndicatorEntry current) { + private IndicatorEntry? get_next_indicator (IndicatorEntry current) { Gtk.Widget? sibling = current.get_next_sibling (); if (sibling != null) { @@ -162,7 +162,7 @@ public class Wingpanel.Widgets.Panel : Gtk.Widget { } } - private IndicatorEntry? get_previous_sibling (IndicatorEntry current) { + private IndicatorEntry? get_previous_indicator (IndicatorEntry current) { Gtk.Widget? sibling = current.get_prev_sibling (); if (sibling != null) { @@ -216,11 +216,7 @@ public class Wingpanel.Widgets.Panel : Gtk.Widget { } """.printf (animation_duration); - try { - style_provider.load_from_string (css); - } catch (Error e) { - warning ("Parsing own style configuration failed: %s", e.message); - } + style_provider.load_from_string (css); switch (state) { case Services.BackgroundState.DARK : From 1c52f495b570327886c4576bd45fba64a404a122 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 18 Sep 2024 14:33:39 +0200 Subject: [PATCH 6/8] Cleanup --- src/Widgets/IndicatorEntry.vala | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index 19184932..c9b4851a 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -92,12 +92,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { } }); - // scroll_event.connect ((e) => { - // return display_widget.scroll_event (e); - // }); - - // button_press_event.connect ((e) => display_widget.button_press_event (e)); - gesture_controller = new Gtk.GestureClick (); add_controller (gesture_controller); gesture_controller.pressed.connect (() => { From 784d9642c750b4322817c2661bf8fb0bd79b210d Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 18 Sep 2024 16:11:26 +0200 Subject: [PATCH 7/8] Fix transparent --- src/PanelWindow.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PanelWindow.vala b/src/PanelWindow.vala index 6d75134b..abff5fc4 100644 --- a/src/PanelWindow.vala +++ b/src/PanelWindow.vala @@ -55,6 +55,7 @@ public class Wingpanel.PanelWindow : Gtk.Window { application.set_accels_for_action ("app.cycle-back", {"Tab"}); child = panel; + remove_css_class (Granite.STYLE_CLASS_BACKGROUND); popover_manager.notify["indicator-open"].connect (() => { if (!popover_manager.indicator_open) { From 1b417f0d8dc933da5802310e4ea1819e0f786ec7 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 18 Sep 2024 16:25:14 +0200 Subject: [PATCH 8/8] Subclass widget directly --- src/Widgets/IndicatorEntry.vala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index c9b4851a..4ab727c1 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -17,7 +17,11 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { +public class Wingpanel.Widgets.IndicatorEntry : Gtk.Widget { + class construct { + set_layout_manager_type (typeof (Gtk.BinLayout)); + } + public Indicator base_indicator { get; construct; } public Services.PopoverManager popover_manager { get; construct; } @@ -62,7 +66,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { }; revealer.get_style_context ().add_class ("composited-indicator"); - append (revealer); + revealer.set_parent (this); if (base_indicator.visible) { popover_manager.register_indicator (this); @@ -114,6 +118,10 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.Box { set_reveal (base_indicator.visible); } + ~IndicatorEntry () { + revealer.unparent (); + } + private void indicator_unmapped () { base_indicator.get_display_widget ().unmap.disconnect (indicator_unmapped); indicator_bar.remove (this);