Commit be5b6460 authored by Lionel Landwerlin's avatar Lionel Landwerlin Committed by Matthias Clasen

menushell/toolbar/window: implement toggle maximize on double click

https://bugzilla.gnome.org/show_bug.cgi?id=700419
parent 9def8c20
......@@ -70,6 +70,7 @@
#include "gtkmenushellprivate.h"
#include "gtkmnemonichash.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkprivate.h"
#include "gtkmain.h"
#include "gtkintl.h"
......@@ -646,6 +647,9 @@ gtk_menu_shell_button_press (GtkWidget *widget,
GtkWidget *menu_item;
GtkWidget *parent;
if (event->type == GDK_2BUTTON_PRESS)
return _gtk_window_handle_button_press_for_widget (widget, event);
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
......@@ -701,21 +705,8 @@ gtk_menu_shell_button_press (GtkWidget *widget,
{
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);
}
if (_gtk_window_handle_button_press_for_widget (widget, event))
gtk_menu_shell_deactivate (menu_shell);
}
}
}
......
......@@ -56,6 +56,7 @@
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
/**
......@@ -2672,7 +2673,7 @@ gtk_toolbar_arrow_button_press (GtkWidget *button,
{
show_menu (toolbar, event);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
return TRUE;
}
......@@ -2680,8 +2681,6 @@ static gboolean
gtk_toolbar_button_press (GtkWidget *toolbar,
GdkEventButton *event)
{
GtkWidget *window;
if (gdk_event_triggers_context_menu ((GdkEvent *) event))
{
gboolean return_value;
......@@ -2693,32 +2692,7 @@ gtk_toolbar_button_press (GtkWidget *toolbar,
return return_value;
}
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
window = gtk_widget_get_toplevel (toolbar);
if (window)
{
gboolean window_drag = FALSE;
gtk_widget_style_get (toolbar,
"window-dragging", &window_drag,
NULL);
if (window_drag)
{
gtk_window_begin_move_drag (GTK_WINDOW (window),
event->button,
event->x_root,
event->y_root,
event->time);
return TRUE;
}
}
return FALSE;
return _gtk_window_handle_button_press_for_widget (toolbar, event);
}
static gboolean
......
......@@ -3450,7 +3450,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_class_install_style_property (klass,
g_param_spec_boolean ("window-dragging",
P_("Window dragging"),
P_("Whether windows can be dragged by clicking on empty areas"),
P_("Whether windows can be dragged and maximized by clicking on empty areas"),
FALSE,
GTK_PARAM_READABLE));
......
......@@ -11667,3 +11667,54 @@ ensure_state_flag_backdrop (GtkWidget *widget)
gtk_widget_queue_draw (widget);
}
gboolean
_gtk_window_handle_button_press_for_widget (GtkWidget *widget,
GdkEventButton *event)
{
gboolean processed = FALSE;
gboolean window_drag = FALSE;
GtkWindow *window;
gtk_widget_style_get (GTK_WIDGET (widget),
"window-dragging", &window_drag,
NULL);
if (!window_drag)
return FALSE;
if (event->button != GDK_BUTTON_PRIMARY)
return FALSE;
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
switch (event->type)
{
case GDK_BUTTON_PRESS:
gtk_window_begin_move_drag (window,
event->button,
event->x_root,
event->y_root,
event->time);
processed = TRUE;
break;
case GDK_2BUTTON_PRESS:
{
GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
if (gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED)
gdk_window_unmaximize (gdk_window);
else
gdk_window_maximize (gdk_window);
processed = TRUE;
}
break;
default:
break;
}
return processed;
}
......@@ -65,6 +65,9 @@ void _gtk_window_set_allocation (GtkWindow *window,
const GtkAllocation *allocation,
GtkAllocation *allocation_out);
gboolean _gtk_window_handle_button_press_for_widget (GtkWidget *widget,
GdkEventButton *event);
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
guint keyval,
GdkModifierType modifiers,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment