From 9fc51818f7e30218b6753aae2fa6ea512d70ba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Bie=C5=84kowski?= Date: Sun, 28 Jan 2018 22:20:49 +0100 Subject: [PATCH 1/2] Use the preview plugin for showing previews above the dock --- lib/DockController.vala | 2 ++ lib/HideManager.vala | 13 +++++++--- lib/Widgets/DockWindow.vala | 49 +++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/lib/DockController.vala b/lib/DockController.vala index 5b694765..58913133 100644 --- a/lib/DockController.vala +++ b/lib/DockController.vala @@ -43,6 +43,8 @@ namespace Plank public DockItemProvider? default_provider { get; private set; } + public bool PreviewMode { get; set; default = false; } + DBusManager dbus_manager; Gee.ArrayList visible_items; Gee.ArrayList items; diff --git a/lib/HideManager.vala b/lib/HideManager.vala index 6c9e3fb9..257e379a 100644 --- a/lib/HideManager.vala +++ b/lib/HideManager.vala @@ -231,7 +231,7 @@ namespace Plank Hovered = hovered; update_needed = true; } - + // disable hiding if menu is visible or drags are active var disabled = (window.menu_is_visible () || drag_manager.InternalDragActive || drag_manager.ExternalDragActive); if (Disabled != disabled) { @@ -244,6 +244,13 @@ namespace Plank thaw_notify (); } + + public void update_hovered_force () + { + freeze_notify (); + update_hidden (); + thaw_notify (); + } void prefs_changed (Object prefs, ParamSpec prop) { @@ -277,12 +284,12 @@ namespace Plank void update_hidden () { - if (Disabled) { + if (Disabled || controller.PreviewMode) { if (Hidden) Hidden = false; return; } - + switch (controller.prefs.HideMode) { default: case HideType.NONE: diff --git a/lib/Widgets/DockWindow.vala b/lib/Widgets/DockWindow.vala index a6ad9a83..99bc4ffd 100644 --- a/lib/Widgets/DockWindow.vala +++ b/lib/Widgets/DockWindow.vala @@ -19,6 +19,13 @@ namespace Plank { + [DBus (name = "org.pantheon.gala.plank")] + interface GalaPlugin : Object { + public signal void disable_preview_mode (); + public abstract bool get_preview_is_hovered (); + public abstract bool show_window_preview (string launcher, int x, int y); + } + /** * The main window for all docks. */ @@ -54,6 +61,8 @@ namespace Plank */ Gtk.Menu? menu; + GalaPlugin? plugin; + uint hover_reposition_timer_id = 0U; uint long_press_timer_id = 0U; @@ -91,6 +100,16 @@ namespace Plank Gdk.EventMask.STRUCTURE_MASK); controller.prefs.notify["HideMode"].connect (set_struts); + + try { + plugin = Bus.get_proxy_sync (BusType.SESSION, "org.pantheon.gala.plank", "/org/pantheon/gala/plank"); + plugin.disable_preview_mode.connect (() => { + controller.PreviewMode = false; + controller.hide_manager.update_hovered_force (); + }); + } catch (Error e) { + warning (e.message); + } } ~DockWindow () @@ -214,6 +233,16 @@ namespace Plank if (!menu_is_visible ()) { set_hovered_provider (null); set_hovered (null); + + Timeout.add (500, () => { + if (controller.PreviewMode && HoveredItem == null + && plugin != null && !plugin.get_preview_is_hovered ()) { + plugin.show_window_preview ("", -1, -1); + plugin.disable_preview_mode (); + } + + return false; + }); } else controller.hover.hide (); @@ -366,6 +395,21 @@ namespace Plank controller.hover.hide (); + if (plugin != null) { + if (HoveredItem != null) { + int x, y; + controller.position_manager.get_hover_position (HoveredItem, out x, out y); + + bool shown = plugin.show_window_preview (HoveredItem.Launcher, x, y); + controller.PreviewMode = shown; + controller.hide_manager.update_hovered_force (); + } else if (!controller.PreviewMode) { + bool shown = plugin.show_window_preview ("", -1, -1); + controller.PreviewMode = shown; + controller.hide_manager.update_hovered_force (); + } + } + if (HoveredItem == null || !controller.prefs.TooltipsEnabled || controller.drag_manager.InternalDragActive) @@ -600,6 +644,11 @@ namespace Plank menu = null; } + if (plugin != null) { + plugin.show_window_preview ("", -1, -1); + plugin.disable_preview_mode (); + } + Gee.ArrayList? menu_items = null; Gtk.MenuPositionFunc? position_func = null; var button = PopupButton.from_event_button (event); From f6503d763c91961f6ac4a4c62d004c2146e07157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Bie=C5=84kowski?= Date: Sun, 28 Jan 2018 23:05:32 +0100 Subject: [PATCH 2/2] Do not show hover window if in preview mode --- lib/Widgets/DockWindow.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Widgets/DockWindow.vala b/lib/Widgets/DockWindow.vala index 99bc4ffd..53562fd0 100644 --- a/lib/Widgets/DockWindow.vala +++ b/lib/Widgets/DockWindow.vala @@ -412,7 +412,8 @@ namespace Plank if (HoveredItem == null || !controller.prefs.TooltipsEnabled - || controller.drag_manager.InternalDragActive) + || controller.drag_manager.InternalDragActive + || controller.PreviewMode) return; // don't be that demanding this delay is still fast enough