frames: Refactor control handling with a switch statement

This commit is contained in:
Jasper St. Pierre 2015-03-08 20:18:13 -07:00
parent d9d83abae2
commit 85452aff4f

View File

@ -935,19 +935,23 @@ static gboolean
meta_frame_left_click_event (MetaUIFrame *frame,
ClutterButtonEvent *event)
{
if (control == META_FRAME_CONTROL_MAXIMIZE ||
control == META_FRAME_CONTROL_UNMAXIMIZE ||
control == META_FRAME_CONTROL_MINIMIZE ||
control == META_FRAME_CONTROL_DELETE ||
control == META_FRAME_CONTROL_SHADE ||
control == META_FRAME_CONTROL_UNSHADE ||
control == META_FRAME_CONTROL_ABOVE ||
control == META_FRAME_CONTROL_UNABOVE ||
control == META_FRAME_CONTROL_STICK ||
control == META_FRAME_CONTROL_UNSTICK ||
control == META_FRAME_CONTROL_MENU ||
control == META_FRAME_CONTROL_APPMENU)
Display *display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
MetaFrameControl control = get_control (frame, event->x, event->y);
switch (control)
{
case META_FRAME_CONTROL_MAXIMIZE:
case META_FRAME_CONTROL_UNMAXIMIZE:
case META_FRAME_CONTROL_MINIMIZE:
case META_FRAME_CONTROL_DELETE:
case META_FRAME_CONTROL_SHADE:
case META_FRAME_CONTROL_UNSHADE:
case META_FRAME_CONTROL_ABOVE:
case META_FRAME_CONTROL_UNABOVE:
case META_FRAME_CONTROL_STICK:
case META_FRAME_CONTROL_UNSTICK:
case META_FRAME_CONTROL_MENU:
case META_FRAME_CONTROL_APPMENU:
frame->grab_button = event->button;
frame->button_state = META_BUTTON_STATE_PRESSED;
frame->prelit_control = control;
@ -995,15 +999,14 @@ meta_frame_left_click_event (MetaUIFrame *frame,
}
return TRUE;
}
else if (control == META_FRAME_CONTROL_RESIZE_SE ||
control == META_FRAME_CONTROL_RESIZE_S ||
control == META_FRAME_CONTROL_RESIZE_SW ||
control == META_FRAME_CONTROL_RESIZE_NE ||
control == META_FRAME_CONTROL_RESIZE_N ||
control == META_FRAME_CONTROL_RESIZE_NW ||
control == META_FRAME_CONTROL_RESIZE_E ||
control == META_FRAME_CONTROL_RESIZE_W)
case META_FRAME_CONTROL_RESIZE_SE:
case META_FRAME_CONTROL_RESIZE_S:
case META_FRAME_CONTROL_RESIZE_SW:
case META_FRAME_CONTROL_RESIZE_NE:
case META_FRAME_CONTROL_RESIZE_N:
case META_FRAME_CONTROL_RESIZE_NW:
case META_FRAME_CONTROL_RESIZE_E:
case META_FRAME_CONTROL_RESIZE_W:
{
MetaGrabOp op;
@ -1043,10 +1046,10 @@ meta_frame_left_click_event (MetaUIFrame *frame,
meta_frames_try_grab_op (frame, op,
event->x, event->y,
event->time);
}
return TRUE;
}
else if (control == META_FRAME_CONTROL_TITLE)
case META_FRAME_CONTROL_TITLE:
{
MetaFrameFlags flags = meta_frame_get_flags (frame->meta_window->frame);
@ -1057,11 +1060,12 @@ meta_frame_left_click_event (MetaUIFrame *frame,
event->x, event->y,
event->time);
}
return TRUE;
}
return FALSE;
return TRUE;
default:
g_assert_not_reached ();
}
}
static gboolean