diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-07-16 01:15:47 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-07-16 01:15:47 -0400 |
commit | 7491e9e97aa6b0f9950897c4f1282b470c79d451 (patch) | |
tree | ecda1a41a4360d3ec379945d6e8f723516e1ad5d /gtk/gtkmenushell.c | |
parent | 89d09554315addbd639ffc4a112386257a858ace (diff) | |
download | gtk+-7491e9e97aa6b0f9950897c4f1282b470c79d451.tar.gz |
Allow windows to be dragged by clicking on empty areas
Allow windows to be dragged by clicking on empty areas in menubars
and toolbars. This is under theme control, via the GtkWidget::window-dragging
style property. The idea is that it makes sense to turn this on if a
theme makes the window frame and the menubar/toolbar appear visually
contiguous.
The main patch was written by Cody Russell, with a contribution by
Ayan George. See bug 611313.
Diffstat (limited to 'gtk/gtkmenushell.c')
-rw-r--r-- | gtk/gtkmenushell.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 1a8b80d686..3fb8ee6a96 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -596,18 +596,45 @@ gtk_menu_shell_button_press (GtkWidget *widget, if (!menu_shell->active || !menu_shell->button) { - _gtk_menu_shell_activate (menu_shell); + gboolean initially_active = menu_shell->active; menu_shell->button = event->button; - if (menu_item && _gtk_menu_item_is_selectable (menu_item) && - menu_item->parent == widget && - menu_item != menu_shell->active_menu_item) + if (menu_item) { - if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM) + if (_gtk_menu_item_is_selectable (menu_item) && + menu_item->parent == widget && + menu_item != menu_shell->active_menu_item) { - menu_shell->activate_time = event->time; - gtk_menu_shell_select_item (menu_shell, menu_item); + _gtk_menu_shell_activate (menu_shell); + menu_shell->button = event->button; + + if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM) + { + menu_shell->activate_time = event->time; + gtk_menu_shell_select_item (menu_shell, menu_item); + } + } + } + else + { + if (!initially_active) + { + gboolean window_drag = FALSE; + + gtk_widget_style_get (widget, + "window-dragging", &window_drag, + NULL); + + if (window_drag) + { + gtk_menu_shell_deactivate (menu_shell); + gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + event->button, + event->x_root, + event->y_root, + event->time); + } } } } |