From f29b705ebb1610f5c21c0d4799f5fa359ec344dd Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 25 Nov 2019 13:54:01 -0800 Subject: [PATCH] Allow autohide style to be slide(animated) or collapse(instant) --- NEWS | 2 +- panel/panel-application.c | 1 + panel/panel-preferences-dialog.c | 19 +++++++-- panel/panel-preferences-dialog.glade | 61 +++++++++++++++++++++++++++- panel/panel-window.c | 56 ++++++++++++++++++++++--- 5 files changed, 128 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index b3b8c791f..85d6f29fe 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ - Drop Gtk2/4.6-only references from the docs - Don't show or try to load Gtk2 plugins anymore - Add dark mode preference - - autohide: Add sliding out animation + - autohide: Add optional sliding out animation - Draw panel border based on position and length - appmenu: Listen to icon theme changes (Bug #15861) - appmenu: Use panel's icon size diff --git a/panel/panel-application.c b/panel/panel-application.c index 2bcb05a09..b5bc61963 100644 --- a/panel/panel-application.c +++ b/panel/panel-application.c @@ -288,6 +288,7 @@ panel_application_xfconf_window_bindings (PanelApplication *application, { { "position-locked", G_TYPE_BOOLEAN }, { "autohide-behavior", G_TYPE_UINT }, + { "autohide-style", G_TYPE_UINT }, { "span-monitors", G_TYPE_BOOLEAN }, { "mode", G_TYPE_UINT }, { "size", G_TYPE_UINT }, diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c index 375dfff11..57d0d277d 100644 --- a/panel/panel-preferences-dialog.c +++ b/panel/panel-preferences-dialog.c @@ -476,6 +476,7 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog) panel_preferences_dialog_bindings_add (dialog, "span-monitors", "active", 0); panel_preferences_dialog_bindings_add (dialog, "position-locked", "active", 0); panel_preferences_dialog_bindings_add (dialog, "autohide-behavior", "active", 0); + panel_preferences_dialog_bindings_add (dialog, "autohide-style", "active", 0); panel_preferences_dialog_bindings_add (dialog, "disable-struts", "active", 0); panel_preferences_dialog_bindings_add (dialog, "size", "value", 0); panel_preferences_dialog_bindings_add (dialog, "nrows", "value", 0); @@ -667,6 +668,7 @@ panel_preferences_dialog_autohide_changed (GtkComboBox *combobox, PanelPreferencesDialog *dialog) { GObject *object; + GObject *styleobj; panel_return_if_fail (GTK_IS_COMBO_BOX (combobox)); panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog)); @@ -675,11 +677,22 @@ panel_preferences_dialog_autohide_changed (GtkComboBox *combobox, object = gtk_builder_get_object (GTK_BUILDER (dialog), "disable-struts"); panel_return_if_fail (GTK_IS_WIDGET (object)); - /* make "don't reserve space on borders" sensitive only when autohide is disabled */ + styleobj = gtk_builder_get_object (GTK_BUILDER (dialog), "autohide-style"); + panel_return_if_fail (GTK_IS_COMBO_BOX (styleobj)); + + /* make "don't reserve space on borders" sensitive only when autohide is disabled, + * and vice versa for auto hide style + */ if (gtk_combo_box_get_active (combobox) == 0) - gtk_widget_set_sensitive (GTK_WIDGET (object), TRUE); + { + gtk_widget_set_sensitive (GTK_WIDGET (object), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (styleobj), FALSE); + } else - gtk_widget_set_sensitive (GTK_WIDGET (object), FALSE); + { + gtk_widget_set_sensitive (GTK_WIDGET (object), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (styleobj), TRUE); + } } diff --git a/panel/panel-preferences-dialog.glade b/panel/panel-preferences-dialog.glade index c9392dc93..60e2ec3a5 100644 --- a/panel/panel-preferences-dialog.glade +++ b/panel/panel-preferences-dialog.glade @@ -20,6 +20,20 @@ + + + + + + + + Slide + + + Collapse + + + @@ -443,7 +457,7 @@ 0 - 6 + 7 2 @@ -524,6 +538,51 @@ 2 + + + True + False + 12 + + + True + False + Panel-hiding style: + True + 0 + + + False + True + 0 + + + + + True + False + autohide-style-store + + + + 0 + + + + + True + True + end + 1 + + + + + 0 + 6 + 2 + + False diff --git a/panel/panel-window.c b/panel/panel-window.c index 364397438..2dc08913f 100644 --- a/panel/panel-window.c +++ b/panel/panel-window.c @@ -76,6 +76,7 @@ typedef enum _StrutsEgde StrutsEgde; typedef enum _AutohideBehavior AutohideBehavior; +typedef enum _AutohideStyle AutohideStyle; typedef enum _AutohideState AutohideState; typedef enum _SnapPosition SnapPosition; typedef enum _PluginProp PluginProp; @@ -162,6 +163,8 @@ static void panel_window_autohide_queue (PanelWind static gboolean panel_window_autohide_slideout (gpointer data); static void panel_window_set_autohide_behavior (PanelWindow *window, AutohideBehavior behavior); +static void panel_window_set_autohide_style (PanelWindow *window, + AutohideStyle style); static void panel_window_update_autohide_window (PanelWindow *window, WnckScreen *screen, WnckWindow *active_window); @@ -196,6 +199,7 @@ enum PROP_LENGTH_ADJUST, PROP_POSITION_LOCKED, PROP_AUTOHIDE_BEHAVIOR, + PROP_AUTOHIDE_STYLE, PROP_SPAN_MONITORS, PROP_OUTPUT_NAME, PROP_POSITION, @@ -221,6 +225,12 @@ enum _AutohideBehavior AUTOHIDE_BEHAVIOR_ALWAYS, }; +enum _AutohideStyle +{ + AUTOHIDE_STYLE_SLIDE = 0, + AUTOHIDE_STYLE_COLLAPSE, +}; + enum _AutohideState { AUTOHIDE_DISABLED = 0, /* autohide is disabled */ @@ -338,6 +348,7 @@ struct _PanelWindow WnckWindow *wnck_active_window; GtkWidget *autohide_window; AutohideBehavior autohide_behavior; + AutohideStyle autohide_style; AutohideState autohide_state; guint autohide_timeout_id; guint autohide_fade_id; @@ -475,6 +486,14 @@ panel_window_class_init (PanelWindowClass *klass) AUTOHIDE_BEHAVIOR_NEVER, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_AUTOHIDE_STYLE, + g_param_spec_uint ("autohide-style", NULL, NULL, + AUTOHIDE_STYLE_SLIDE, + AUTOHIDE_STYLE_COLLAPSE, + AUTOHIDE_STYLE_SLIDE, + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_SPAN_MONITORS, g_param_spec_boolean ("span-monitors", NULL, NULL, @@ -555,6 +574,7 @@ panel_window_init (PanelWindow *window) window->span_monitors = FALSE; window->position_locked = FALSE; window->autohide_behavior = AUTOHIDE_BEHAVIOR_NEVER; + window->autohide_style = AUTOHIDE_STYLE_SLIDE; window->autohide_state = AUTOHIDE_DISABLED; window->autohide_timeout_id = 0; window->autohide_fade_id = 0; @@ -635,6 +655,10 @@ panel_window_get_property (GObject *object, g_value_set_uint (value, window->autohide_behavior); break; + case PROP_AUTOHIDE_STYLE: + g_value_set_uint(value, window->autohide_style); + break; + case PROP_SPAN_MONITORS: g_value_set_boolean (value, window->span_monitors); break; @@ -783,6 +807,11 @@ panel_window_set_property (GObject *object, AUTOHIDE_BEHAVIOR_ALWAYS)); break; + case PROP_AUTOHIDE_STYLE: + panel_window_set_autohide_style (window, MIN (g_value_get_uint (value), + AUTOHIDE_STYLE_COLLAPSE)); + break; + case PROP_SPAN_MONITORS: val_bool = g_value_get_boolean (value); if (window->span_monitors != val_bool) @@ -2578,18 +2607,27 @@ panel_window_autohide_slideout (gpointer data) { PanelWindow *window = PANEL_WINDOW (data); PanelBorders borders; - gint x, y, w, h; + gint x, y, xinc, yinc, w, h; gtk_window_get_position (GTK_WINDOW (window), &x, &y); w = gdk_screen_get_width (window->screen); h = gdk_screen_get_height (window->screen); borders = panel_base_window_get_borders (PANEL_BASE_WINDOW (window)); + if (window->autohide_style == AUTOHIDE_STYLE_SLIDE) + { + xinc = 1; yinc = 1; + } + else + { + xinc = window->alloc.width; yinc = window->alloc.height; + } + if (IS_HORIZONTAL (window)) { if (PANEL_HAS_FLAG (borders, PANEL_BORDER_BOTTOM)) { - y--; + y -= yinc; if (y < (0 - window->alloc.height - 1)) { @@ -2599,7 +2637,7 @@ panel_window_autohide_slideout (gpointer data) } else if (PANEL_HAS_FLAG (borders, PANEL_BORDER_TOP)) { - y++; + y += yinc; if (y > (h + window->alloc.height + 1)) { window->autohide_fade_id = 0; @@ -2614,7 +2652,7 @@ panel_window_autohide_slideout (gpointer data) { if (PANEL_HAS_FLAG (borders, PANEL_BORDER_RIGHT)) { - x--; + x -= xinc; if (x < (0 - window->alloc.width + 1)) { window->autohide_fade_id = 0; @@ -2623,7 +2661,7 @@ panel_window_autohide_slideout (gpointer data) } else if (PANEL_HAS_FLAG (borders, PANEL_BORDER_LEFT)) { - x++; + x += xinc; if (x > (w + window->alloc.width + 1)) { window->autohide_fade_id = 0; @@ -2640,7 +2678,13 @@ panel_window_autohide_slideout (gpointer data) return TRUE; } - +static void +panel_window_set_autohide_style (PanelWindow *window, + AutohideStyle style) +{ + /* Doesn't actually seem to be anything to do other than remember the style */ + window->autohide_style = style; +} static void panel_window_set_autohide_behavior (PanelWindow *window,