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 93e2f384..37a32ab3 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,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', @@ -41,7 +37,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 c30b17d2..a5ca6de2 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..abff5fc4 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; @@ -34,25 +29,16 @@ 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 ); 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); - - update_visual (); - - popover_manager = new Services.PopoverManager (this); + popover_manager = new Services.PopoverManager (); panel = new Widgets.Panel (popover_manager); panel.realize.connect (on_realize); @@ -68,18 +54,30 @@ 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; + remove_css_class (Granite.STYLE_CLASS_BACKGROUND); - 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 (); + } - key_controller = new Gtk.EventControllerKey (this); - key_controller.key_pressed.connect (on_key_pressed); + 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); + } + }); - panel.size_allocate.connect (update_panel_dimensions); + var key_controller = new Gtk.EventControllerKey (); + ((Gtk.Widget) this).add_controller (key_controller); + key_controller.key_pressed.connect (on_key_pressed); } private void on_realize () { @@ -87,8 +85,7 @@ 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 - Idle.add_once (init_wl); + init_wl (); } else { init_x (); } @@ -98,7 +95,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 (); @@ -107,20 +104,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)); - } - - 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); - } + this.set_size_request (monitor_dimensions.width, -1); } private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { @@ -131,39 +115,8 @@ public class Wingpanel.PanelWindow : Gtk.Window { return Gdk.EVENT_PROPAGATE; } - public void set_expanded (bool expand) { - 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.resize (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 () { @@ -171,26 +124,27 @@ 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); - 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 } } 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); - 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 cd387bbe..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.GestureMultiPress 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 @@ -51,47 +51,26 @@ public class Wingpanel.Services.PopoverManager : Object { 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 (); + 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 (); } } } - 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.GestureMultiPress (owner) { - window = owner.get_window () - }; - 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/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..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.EventBox { +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; } @@ -37,7 +41,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 +66,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { }; revealer.get_style_context ().add_class ("composited-indicator"); - add (revealer); + revealer.set_parent (this); if (base_indicator.visible) { popover_manager.register_indicator (this); @@ -92,24 +96,17 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { } }); - add_events (Gdk.EventMask.SCROLL_MASK); - add_events (Gdk.EventMask.SMOOTH_SCROLL_MASK); - - 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.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 @@ -121,6 +118,10 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { 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); diff --git a/src/Widgets/IndicatorPopover.vala b/src/Widgets/IndicatorPopover.vala index 20fdb0e7..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; @@ -47,7 +46,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..8b1c8dff 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.Widget { private static Settings panel_settings = new Settings ("io.elementary.desktop.wingpanel"); public Services.PopoverManager popover_manager { get; construct; } @@ -26,10 +26,12 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { private IndicatorBar left_menubar; private IndicatorBar center_menubar; + private Gtk.CenterBox box; + 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; @@ -39,6 +41,7 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { class construct { set_css_name ("panel"); + set_layout_manager_type (typeof (Gtk.BinLayout)); } construct { @@ -57,12 +60,12 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { halign = END }; - var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - box.pack_start (left_menubar); + box = new Gtk.CenterBox (); + 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); + box.set_parent (this); unowned IndicatorManager indicator_manager = IndicatorManager.get_default (); indicator_manager.indicator_added.connect (add_indicator); @@ -78,18 +81,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) { @@ -104,13 +109,17 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { }); } + ~Panel () { + box.unparent (); + } + 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 (); @@ -126,9 +135,9 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { 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) { @@ -136,112 +145,38 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } } - private IndicatorEntry? get_next_sibling (IndicatorEntry current) { - IndicatorEntry? sibling = null; + private IndicatorEntry? get_next_indicator (IndicatorEntry current) { + 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; + private IndicatorEntry? get_previous_indicator (IndicatorEntry current) { + 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 +185,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) { @@ -283,11 +216,7 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } """.printf (animation_duration); - try { - style_provider.load_from_data (css, css.length); - } catch (Error e) { - warning ("Parsing own style configuration failed: %s", e.message); - } + style_provider.load_from_string (css); switch (state) { case Services.BackgroundState.DARK : 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