fix for bug #104018 from David Santiago, change button state to normal

2003-05-16  Havoc Pennington  <hp@redhat.com>

	* src/frames.c (meta_frames_paint_to_drawable): fix for
	bug #104018 from David Santiago, change button state to
	normal while it's being pressed if you move the mouse
	outside it. Do this by tracking prelit_control for whether
	to draw a button as active, not just for whether to draw
	it as prelit.
	(meta_frames_motion_notify_event): also update prelit_control
	while clicking a button
This commit is contained in:
Havoc Pennington 2003-05-16 23:09:49 +00:00 committed by Havoc Pennington
parent 4b02b0ddf1
commit 3ad5618596
2 changed files with 68 additions and 34 deletions

View File

@ -1,3 +1,14 @@
2003-05-16 Havoc Pennington <hp@redhat.com>
* src/frames.c (meta_frames_paint_to_drawable): fix for
bug #104018 from David Santiago, change button state to
normal while it's being pressed if you move the mouse
outside it. Do this by tracking prelit_control for whether
to draw a button as active, not just for whether to draw
it as prelit.
(meta_frames_motion_notify_event): also update prelit_control
while clicking a button
2003-05-16 Havoc Pennington <hp@redhat.com> 2003-05-16 Havoc Pennington <hp@redhat.com>
* src/window.c (meta_window_new): fill in window->desc sooner * src/window.c (meta_window_new): fill in window->desc sooner

View File

@ -1577,6 +1577,7 @@ meta_frames_motion_notify_event (GtkWidget *widget,
{ {
MetaUIFrame *frame; MetaUIFrame *frame;
MetaFrames *frames; MetaFrames *frames;
MetaGrabOp grab_op;
frames = META_FRAMES (widget); frames = META_FRAMES (widget);
@ -1587,16 +1588,43 @@ meta_frames_motion_notify_event (GtkWidget *widget,
clear_tip (frames); clear_tip (frames);
frames->last_motion_frame = frame; frames->last_motion_frame = frame;
grab_op = meta_core_get_grab_op (gdk_display);
switch (meta_core_get_grab_op (gdk_display)) switch (grab_op)
{ {
case META_GRAB_OP_CLICKING_MENU: case META_GRAB_OP_CLICKING_MENU:
case META_GRAB_OP_CLICKING_DELETE: case META_GRAB_OP_CLICKING_DELETE:
case META_GRAB_OP_CLICKING_MINIMIZE: case META_GRAB_OP_CLICKING_MINIMIZE:
case META_GRAB_OP_CLICKING_MAXIMIZE: case META_GRAB_OP_CLICKING_MAXIMIZE:
case META_GRAB_OP_CLICKING_UNMAXIMIZE: case META_GRAB_OP_CLICKING_UNMAXIMIZE:
{
MetaFrameControl control;
int x, y;
gdk_window_get_pointer (frame->window, &x, &y, NULL);
/* Control is set to none unless it matches
* the current grab
*/
control = get_control (frames, frame, x, y);
if (! ((control == META_FRAME_CONTROL_MENU &&
grab_op == META_GRAB_OP_CLICKING_MENU) ||
(control == META_FRAME_CONTROL_DELETE &&
grab_op == META_GRAB_OP_CLICKING_DELETE) ||
(control == META_FRAME_CONTROL_MINIMIZE &&
grab_op == META_GRAB_OP_CLICKING_MINIMIZE) ||
(control == META_FRAME_CONTROL_MAXIMIZE &&
(grab_op == META_GRAB_OP_CLICKING_MAXIMIZE ||
grab_op == META_GRAB_OP_CLICKING_UNMAXIMIZE))))
control = META_FRAME_CONTROL_NONE;
/* Update prelit control and cursor */
meta_frames_update_prelit_control (frames, frame, control);
/* No tooltip while in the process of clicking */
}
break; break;
case META_GRAB_OP_NONE: case META_GRAB_OP_NONE:
{ {
MetaFrameControl control; MetaFrameControl control;
@ -1684,6 +1712,7 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
int n_areas; int n_areas;
int screen_width, screen_height; int screen_width, screen_height;
MetaButtonLayout button_layout; MetaButtonLayout button_layout;
MetaGrabOp grab_op;
widget = GTK_WIDGET (frames); widget = GTK_WIDGET (frames);
@ -1695,53 +1724,47 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
++i; ++i;
} }
grab_frame = meta_core_get_grab_frame (gdk_display);
grab_op = meta_core_get_grab_op (gdk_display);
if (grab_frame != frame->xwindow)
grab_op = META_GRAB_OP_NONE;
/* Set prelight state */ /* Set prelight state */
switch (frame->prelit_control) switch (frame->prelit_control)
{ {
case META_FRAME_CONTROL_MENU: case META_FRAME_CONTROL_MENU:
button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRELIGHT; if (grab_op == META_GRAB_OP_CLICKING_MENU)
button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRELIGHT;
break; break;
case META_FRAME_CONTROL_MINIMIZE: case META_FRAME_CONTROL_MINIMIZE:
button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRELIGHT; if (grab_op == META_GRAB_OP_CLICKING_MINIMIZE)
button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRELIGHT;
break; break;
case META_FRAME_CONTROL_MAXIMIZE: case META_FRAME_CONTROL_MAXIMIZE:
if (grab_op == META_GRAB_OP_CLICKING_MAXIMIZE)
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_UNMAXIMIZE: case META_FRAME_CONTROL_UNMAXIMIZE:
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT; if (grab_op == META_GRAB_OP_CLICKING_UNMAXIMIZE)
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_MAXIMIZE] = META_BUTTON_STATE_PRELIGHT;
break; break;
case META_FRAME_CONTROL_DELETE: case META_FRAME_CONTROL_DELETE:
button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRELIGHT; if (grab_op == META_GRAB_OP_CLICKING_DELETE)
button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_CLOSE] = META_BUTTON_STATE_PRELIGHT;
break; break;
default: default:
break; break;
} }
grab_frame = meta_core_get_grab_frame (gdk_display);
if (frame->xwindow == grab_frame)
{
switch (meta_core_get_grab_op (gdk_display))
{
case META_GRAB_OP_CLICKING_MENU:
button_states[META_BUTTON_TYPE_MENU] =
META_BUTTON_STATE_PRESSED;
break;
case META_GRAB_OP_CLICKING_DELETE:
button_states[META_BUTTON_TYPE_CLOSE] =
META_BUTTON_STATE_PRESSED;
break;
case META_GRAB_OP_CLICKING_MAXIMIZE:
case META_GRAB_OP_CLICKING_UNMAXIMIZE:
button_states[META_BUTTON_TYPE_MAXIMIZE] =
META_BUTTON_STATE_PRESSED;
break;
case META_GRAB_OP_CLICKING_MINIMIZE:
button_states[META_BUTTON_TYPE_MINIMIZE] =
META_BUTTON_STATE_PRESSED;
break;
default:
break;
}
}
/* Map button function states to button position states */ /* Map button function states to button position states */
button_states[META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND] = button_states[META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND] =