diff options
| author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2014-02-14 13:17:46 +0100 |
|---|---|---|
| committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2014-02-17 20:15:50 +0100 |
| commit | ee57ae33024d5cf18190dba888317494238d5e4f (patch) | |
| tree | 84ba4ff78d72bb7d4fe422731bef26a52f0a325e /shell/gtk-shell.c | |
| parent | f41d2f201cb50ab9fab3477d5d1914740254c8bf (diff) | |
| download | graynard-ee57ae33024d5cf18190dba888317494238d5e4f.tar.gz graynard-ee57ae33024d5cf18190dba888317494238d5e4f.zip | |
shell: hide panel depending on where the cursor is
Diffstat (limited to 'shell/gtk-shell.c')
| -rw-r--r-- | shell/gtk-shell.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/shell/gtk-shell.c b/shell/gtk-shell.c index 8b3381b..355a73a 100644 --- a/shell/gtk-shell.c +++ b/shell/gtk-shell.c @@ -37,12 +37,35 @@ struct desktop { struct element *background; struct element *panel; struct element *launcher_grid; + + guint initial_panel_timeout_id; + guint hide_panel_idle_id; }; /* TODO: guessed from the mockups, it'd be nice to have this in stone * somewhere. */ #define PANEL_HEIGHT_RATIO 0.73 +static gboolean panel_window_enter_cb (GtkWidget *widget, + GdkEventCrossing *event, + struct desktop *desktop); +static gboolean panel_window_leave_cb (GtkWidget *widget, + GdkEventCrossing *event, + struct desktop *desktop); + +static gboolean +connect_enter_leave_signals (gpointer data) +{ + struct desktop *desktop = data; + + g_signal_connect (desktop->panel->window, "enter-notify-event", + G_CALLBACK (panel_window_enter_cb), desktop); + g_signal_connect (desktop->panel->window, "leave-notify-event", + G_CALLBACK (panel_window_leave_cb), desktop); + + return FALSE; +} + static void desktop_shell_configure(void *data, struct desktop_shell *desktop_shell, @@ -75,6 +98,11 @@ desktop_shell_configure(void *data, 0, (height - window_height) / 2); desktop_shell_desktop_ready(desktop->shell); + + /* TODO: why does the panel signal leave on drawing for + * startup? we don't want to have to have this silly + * timeout. */ + g_timeout_add_seconds (1, connect_enter_leave_signals, desktop); } static void @@ -129,6 +157,72 @@ launcher_grid_toggle (GtkWidget *widget, struct desktop *desktop) gtk_widget_set_visible (desktop->launcher_grid->window, !grid_visible); } +static gboolean +panel_window_enter_cb (GtkWidget *widget, + GdkEventCrossing *event, + struct desktop *desktop) +{ + if (desktop->initial_panel_timeout_id > 0) { + g_source_remove (desktop->initial_panel_timeout_id); + desktop->initial_panel_timeout_id = 0; + } + + if (desktop->hide_panel_idle_id > 0) { + g_source_remove (desktop->hide_panel_idle_id); + desktop->hide_panel_idle_id = 0; + return; + } + + shell_helper_slide_surface_back(desktop->helper, + desktop->panel->surface); + + return FALSE; +} + +static gboolean +leave_panel_idle_cb (gpointer data) +{ + struct desktop *desktop = data; + gint width; + + desktop->hide_panel_idle_id = 0; + + gtk_window_get_size (GTK_WINDOW (desktop->clock->window), + &width, NULL); + + shell_helper_slide_surface(desktop->helper, + desktop->panel->surface, + -31, 0); + + return FALSE; +} + +static gboolean +panel_window_leave_cb (GtkWidget *widget, + GdkEventCrossing *event, + struct desktop *desktop) +{ + if (desktop->initial_panel_timeout_id > 0) { + g_source_remove (desktop->initial_panel_timeout_id); + desktop->initial_panel_timeout_id = 0; + } + + if (desktop->hide_panel_idle_id > 0) + return; + + desktop->hide_panel_idle_id = g_idle_add (leave_panel_idle_cb, desktop); + + return FALSE; +} + +static gboolean +panel_hide_timeout_cb (gpointer data) +{ + struct desktop *desktop = data; + + panel_window_leave_cb (NULL, NULL, desktop); +} + static void panel_create(struct desktop *desktop) { @@ -146,6 +240,10 @@ panel_create(struct desktop *desktop) gtk_window_set_decorated(GTK_WINDOW(panel->window), FALSE); gtk_widget_realize(panel->window); + desktop->initial_panel_timeout_id = g_timeout_add_seconds(2, + panel_hide_timeout_cb, + desktop); + gtk_style_context_add_class (gtk_widget_get_style_context (panel->window), "wgs-panel"); |
