From 85e43a402f5d1c5397ff51561c51c94ffd35e285 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 17 Feb 2007 21:15:59 +0000 Subject: [PATCH] Split out code for different kinds of click into separate functions. Fixes 2007-02-17 Linus Torvalds * 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 --- ChangeLog | 9 +++ src/frames.c | 157 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 104 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe70d6a2a..98938cdda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-17 Linus Torvalds + + * 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 * src/metacity-dialog.c (kill_window_question): Change dialog diff --git a/src/frames.c b/src/frames.c index 37b1e79e4..d6e953b8f 100644 --- a/src/frames.c +++ b/src/frames.c @@ -1187,6 +1187,98 @@ redraw_control (MetaFrames *frames, 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 meta_frames_button_press_event (GtkWidget *widget, GdkEventButton *event) @@ -1233,59 +1325,7 @@ meta_frames_button_press_event (GtkWidget *widget, event->button == 1 && event->type == GDK_2BUTTON_PRESS) { - MetaFrameFlags flags; - - 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; + return meta_frame_double_click_event (frame, event); } if (meta_core_get_grab_op (gdk_display) != @@ -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;