Split out code for different kinds of click into separate functions. Fixes

2007-02-17  Linus Torvalds  <torvalds@woody.linux-foundation.org>

        * src/frames.c (meta_frames_button_press_event): Split out
        code for different kinds of click into separate functions.
        Fixes #408899.
        * src/frames.c (meta_frame_titlebar_event,
         meta_frame_double_click_event, meta_frame_middle_click_event,
         meta_frame_right_click_event): new functions.



svn path=/trunk/; revision=3061
This commit is contained in:
Linus Torvalds 2007-02-17 21:15:59 +00:00 committed by Thomas James Alexander Thurman
parent c1fcc4bb6b
commit 85e43a402f
2 changed files with 104 additions and 62 deletions

View File

@ -1,3 +1,12 @@
2007-02-17 Linus Torvalds <torvalds@woody.linux-foundation.org>
* src/frames.c (meta_frames_button_press_event): Split out
code for different kinds of click into separate functions.
Fixes #408899.
* src/frames.c (meta_frame_titlebar_event,
meta_frame_double_click_event, meta_frame_middle_click_event,
meta_frame_right_click_event): new functions.
2007-01-27 Bruno Boaventura <brunobol@gnome.org> 2007-01-27 Bruno Boaventura <brunobol@gnome.org>
* src/metacity-dialog.c (kill_window_question): Change dialog * src/metacity-dialog.c (kill_window_question): Change dialog

View File

@ -1187,6 +1187,98 @@ redraw_control (MetaFrames *frames,
invalidate_cache (frames, frame); invalidate_cache (frames, frame);
} }
static gboolean
meta_frame_titlebar_event (MetaUIFrame *frame,
GdkEventButton *event,
int action)
{
MetaFrameFlags flags;
switch (action)
{
case META_ACTION_DOUBLE_CLICK_TITLEBAR_TOGGLE_SHADE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_SHADE)
{
if (flags & META_FRAME_SHADED)
meta_core_unshade (gdk_display,
frame->xwindow,
event->time);
else
meta_core_shade (gdk_display,
frame->xwindow,
event->time);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_TOGGLE_MAXIMIZE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_MAXIMIZE)
{
meta_core_toggle_maximize (gdk_display, frame->xwindow);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_MINIMIZE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_MINIMIZE)
{
meta_core_minimize (gdk_display, frame->xwindow);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_NONE:
/* Yaay, a sane user that doesn't use that other weird crap! */
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_LAST:
break;
}
return TRUE;
}
static gboolean
meta_frame_double_click_event (MetaUIFrame *frame,
GdkEventButton *event)
{
int action = meta_prefs_get_action_double_click_titlebar ();
return meta_frame_titlebar_event (frame, event, action);
}
static gboolean
meta_frame_middle_click_event (MetaUIFrame *frame,
GdkEventButton *event)
{
meta_core_user_lower_and_unfocus (gdk_display,
frame->xwindow,
event->time);
return TRUE;
}
static gboolean
meta_frame_right_click_event(MetaUIFrame *frame,
GdkEventButton *event)
{
meta_core_show_window_menu (gdk_display,
frame->xwindow,
event->x_root,
event->y_root,
event->button,
event->time);
return TRUE;
}
static gboolean static gboolean
meta_frames_button_press_event (GtkWidget *widget, meta_frames_button_press_event (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
@ -1233,59 +1325,7 @@ meta_frames_button_press_event (GtkWidget *widget,
event->button == 1 && event->button == 1 &&
event->type == GDK_2BUTTON_PRESS) event->type == GDK_2BUTTON_PRESS)
{ {
MetaFrameFlags flags; return meta_frame_double_click_event (frame, event);
switch (meta_prefs_get_action_double_click_titlebar ())
{
case META_ACTION_DOUBLE_CLICK_TITLEBAR_TOGGLE_SHADE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_SHADE)
{
if (flags & META_FRAME_SHADED)
meta_core_unshade (gdk_display,
frame->xwindow,
event->time);
else
meta_core_shade (gdk_display,
frame->xwindow,
event->time);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_TOGGLE_MAXIMIZE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_MAXIMIZE)
{
meta_core_toggle_maximize (gdk_display, frame->xwindow);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_MINIMIZE:
{
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
if (flags & META_FRAME_ALLOWS_MINIMIZE)
{
meta_core_minimize (gdk_display, frame->xwindow);
}
}
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_NONE:
/* Yaay, a sane user that doesn't use that other weird crap! */
break;
case META_ACTION_DOUBLE_CLICK_TITLEBAR_LAST:
break;
}
return TRUE;
} }
if (meta_core_get_grab_op (gdk_display) != if (meta_core_get_grab_op (gdk_display) !=
@ -1474,18 +1514,11 @@ meta_frames_button_press_event (GtkWidget *widget,
} }
else if (event->button == 2) else if (event->button == 2)
{ {
meta_core_user_lower_and_unfocus (gdk_display, return meta_frame_middle_click_event (frame, event);
frame->xwindow,
event->time);
} }
else if (event->button == 3) else if (event->button == 3)
{ {
meta_core_show_window_menu (gdk_display, return meta_frame_right_click_event (frame, event);
frame->xwindow,
event->x_root,
event->y_root,
event->button,
event->time);
} }
return TRUE; return TRUE;