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>
* src/metacity-dialog.c (kill_window_question): Change dialog

View File

@ -1188,54 +1188,13 @@ redraw_control (MetaFrames *frames,
}
static gboolean
meta_frames_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
MetaUIFrame *frame;
MetaFrames *frames;
MetaFrameControl control;
frames = META_FRAMES (widget);
/* Remember that the display may have already done something with this event.
* If so there's probably a GrabOp in effect.
*/
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
if (frame == NULL)
return FALSE;
clear_tip (frames);
control = get_control (frames, frame, event->x, event->y);
/* focus on click, even if click was on client area */
if (event->button == 1 &&
!(control == META_FRAME_CONTROL_MINIMIZE ||
control == META_FRAME_CONTROL_DELETE))
{
meta_topic (META_DEBUG_FOCUS,
"Focusing window with frame 0x%lx due to button 1 press\n",
frame->xwindow);
meta_core_user_focus (gdk_display,
frame->xwindow,
event->time);
}
/* don't do the rest of this if on client area */
if (control == META_FRAME_CONTROL_CLIENT_AREA)
return FALSE; /* not on the frame, just passed through from client */
/* We want to shade even if we have a GrabOp, since we'll have a move grab
* if we double click the titlebar.
*/
if (control == META_FRAME_CONTROL_TITLE &&
event->button == 1 &&
event->type == GDK_2BUTTON_PRESS)
meta_frame_titlebar_event (MetaUIFrame *frame,
GdkEventButton *event,
int action)
{
MetaFrameFlags flags;
switch (meta_prefs_get_action_double_click_titlebar ())
switch (action)
{
case META_ACTION_DOUBLE_CLICK_TITLEBAR_TOGGLE_SHADE:
{
@ -1288,6 +1247,87 @@ meta_frames_button_press_event (GtkWidget *widget,
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
meta_frames_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
MetaUIFrame *frame;
MetaFrames *frames;
MetaFrameControl control;
frames = META_FRAMES (widget);
/* Remember that the display may have already done something with this event.
* If so there's probably a GrabOp in effect.
*/
frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->window));
if (frame == NULL)
return FALSE;
clear_tip (frames);
control = get_control (frames, frame, event->x, event->y);
/* focus on click, even if click was on client area */
if (event->button == 1 &&
!(control == META_FRAME_CONTROL_MINIMIZE ||
control == META_FRAME_CONTROL_DELETE))
{
meta_topic (META_DEBUG_FOCUS,
"Focusing window with frame 0x%lx due to button 1 press\n",
frame->xwindow);
meta_core_user_focus (gdk_display,
frame->xwindow,
event->time);
}
/* don't do the rest of this if on client area */
if (control == META_FRAME_CONTROL_CLIENT_AREA)
return FALSE; /* not on the frame, just passed through from client */
/* We want to shade even if we have a GrabOp, since we'll have a move grab
* if we double click the titlebar.
*/
if (control == META_FRAME_CONTROL_TITLE &&
event->button == 1 &&
event->type == GDK_2BUTTON_PRESS)
{
return meta_frame_double_click_event (frame, event);
}
if (meta_core_get_grab_op (gdk_display) !=
META_GRAB_OP_NONE)
return FALSE; /* already up to something */
@ -1474,18 +1514,11 @@ meta_frames_button_press_event (GtkWidget *widget,
}
else if (event->button == 2)
{
meta_core_user_lower_and_unfocus (gdk_display,
frame->xwindow,
event->time);
return meta_frame_middle_click_event (frame, event);
}
else if (event->button == 3)
{
meta_core_show_window_menu (gdk_display,
frame->xwindow,
event->x_root,
event->y_root,
event->button,
event->time);
return meta_frame_right_click_event (frame, event);
}
return TRUE;