From dcef402d6812115a878c7e4ea63c6b46640a023b Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 7 Aug 2006 21:04:44 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20from=20Bj=C3=B6rn=20Lindqvist=20to=20fi?= =?UTF-8?q?x=20button=20lighting=20with=20dragged=20clicks.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-08-07 Elijah Newren Patch from Björn Lindqvist to fix button lighting with dragged clicks. #321474. * src/frames.c (meta_frames_button_press_event): update the prelit_control, (meta_frames_button_release_event): some code refactoring to simplify things a bit, and make sure to update the prelit_control --- ChangeLog | 10 ++++++++ src/frames.c | 70 +++++++++++++++++++--------------------------------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e70c625c..1fc17f8e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-08-07 Elijah Newren + + Patch from Björn Lindqvist to fix button lighting with dragged + clicks. #321474. + + * src/frames.c (meta_frames_button_press_event): update the + prelit_control, (meta_frames_button_release_event): some code + refactoring to simplify things a bit, and make sure to update the + prelit_control + 2006-08-07 Elijah Newren * src/keybindings.c (process_keyboard_move_grab): Patch from diff --git a/src/frames.c b/src/frames.c index d14d8415a..6b740d9a9 100644 --- a/src/frames.c +++ b/src/frames.c @@ -46,6 +46,9 @@ static void meta_frames_style_set (GtkWidget *widget, static void meta_frames_realize (GtkWidget *widget); static void meta_frames_unrealize (GtkWidget *widget); +static void meta_frames_update_prelit_control (MetaFrames *frames, + MetaUIFrame *frame, + MetaFrameControl control); static gboolean meta_frames_button_press_event (GtkWidget *widget, GdkEventButton *event); static gboolean meta_frames_button_release_event (GtkWidget *widget, @@ -1193,15 +1196,6 @@ redraw_control (MetaFrames *frames, invalidate_cache (frames, frame); } -static gboolean -point_in_control (MetaFrames *frames, - MetaUIFrame *frame, - MetaFrameControl control, - int x, int y) -{ - return control == get_control (frames, frame, x, y); -} - static gboolean meta_frames_button_press_event (GtkWidget *widget, GdkEventButton *event) @@ -1342,6 +1336,7 @@ meta_frames_button_press_event (GtkWidget *widget, event->x_root, event->y_root); + frame->prelit_control = control; redraw_control (frames, frame, control); if (op == META_GRAB_OP_CLICKING_MENU) @@ -1525,67 +1520,54 @@ meta_frames_button_release_event (GtkWidget *widget, if (frame->xwindow == meta_core_get_grab_frame (gdk_display) && ((int) event->button) == meta_core_get_grab_button (gdk_display)) { - gboolean end_grab; - - end_grab = FALSE; + MetaFrameControl control; + control = get_control (frames, frame, event->x, event->y); + switch (op) { case META_GRAB_OP_CLICKING_MINIMIZE: - if (point_in_control (frames, frame, - META_FRAME_CONTROL_MINIMIZE, - event->x, event->y)) + if (control == META_FRAME_CONTROL_MINIMIZE) meta_core_minimize (gdk_display, frame->xwindow); - - redraw_control (frames, frame, - META_FRAME_CONTROL_MINIMIZE); - end_grab = TRUE; + + meta_core_end_grab_op (gdk_display, event->time); break; case META_GRAB_OP_CLICKING_MAXIMIZE: - if (point_in_control (frames, frame, - META_FRAME_CONTROL_MAXIMIZE, - event->x, event->y)) + if (control == META_FRAME_CONTROL_MAXIMIZE) meta_core_maximize (gdk_display, frame->xwindow); - - redraw_control (frames, frame, - META_FRAME_CONTROL_MAXIMIZE); - end_grab = TRUE; + + meta_core_end_grab_op (gdk_display, event->time); break; case META_GRAB_OP_CLICKING_UNMAXIMIZE: - if (point_in_control (frames, frame, - META_FRAME_CONTROL_UNMAXIMIZE, - event->x, event->y)) + if (control == META_FRAME_CONTROL_UNMAXIMIZE) meta_core_unmaximize (gdk_display, frame->xwindow); - - redraw_control (frames, frame, - META_FRAME_CONTROL_MAXIMIZE); - end_grab = TRUE; + + meta_core_end_grab_op (gdk_display, event->time); break; case META_GRAB_OP_CLICKING_DELETE: - if (point_in_control (frames, frame, - META_FRAME_CONTROL_DELETE, - event->x, event->y)) + if (control == META_FRAME_CONTROL_DELETE) meta_core_delete (gdk_display, frame->xwindow, event->time); - redraw_control (frames, frame, - META_FRAME_CONTROL_DELETE); - end_grab = TRUE; + + meta_core_end_grab_op (gdk_display, event->time); break; case META_GRAB_OP_CLICKING_MENU: - redraw_control (frames, frame, - META_FRAME_CONTROL_MENU); - end_grab = TRUE; + meta_core_end_grab_op (gdk_display, event->time); break; default: break; } - if (end_grab) - meta_core_end_grab_op (gdk_display, event->time); + /* Update the prelit control regardless of what button the mouse + * was released over; needed so that the new button can become + * prelit so to let the user know that it can now be pressed. + * :) + */ + meta_frames_update_prelit_control (frames, frame, control); } return TRUE;