mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
display: get button number from helper input event function
This commit is contained in:
parent
33c829ee39
commit
0c317e8ced
@ -1730,6 +1730,7 @@ event_callback (XEvent *event,
|
|||||||
{
|
{
|
||||||
Window xwindow = meta_input_event_get_window (display, event);
|
Window xwindow = meta_input_event_get_window (display, event);
|
||||||
Time evtime = meta_input_event_get_time (display, event);
|
Time evtime = meta_input_event_get_time (display, event);
|
||||||
|
guint n_button;
|
||||||
|
|
||||||
if (window && !window->override_redirect &&
|
if (window && !window->override_redirect &&
|
||||||
((evtype == KeyPress) || (evtype == ButtonPress)))
|
((evtype == KeyPress) || (evtype == ButtonPress)))
|
||||||
@ -1768,16 +1769,18 @@ event_callback (XEvent *event,
|
|||||||
filter_out_event = bypass_compositor = TRUE;
|
filter_out_event = bypass_compositor = TRUE;
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
|
meta_input_event_get_button (display, event, &n_button);
|
||||||
|
|
||||||
if (display->grab_op == META_GRAB_OP_COMPOSITOR)
|
if (display->grab_op == META_GRAB_OP_COMPOSITOR)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (event->xbutton.button == 4 || event->xbutton.button == 5)
|
if (n_button == 4 || n_button == 5)
|
||||||
/* Scrollwheel event, do nothing and deliver event to compositor below */
|
/* Scrollwheel event, do nothing and deliver event to compositor below */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((window &&
|
if ((window &&
|
||||||
grab_op_is_mouse (display->grab_op) &&
|
grab_op_is_mouse (display->grab_op) &&
|
||||||
display->grab_button != (int) event->xbutton.button &&
|
display->grab_button != (int) n_button &&
|
||||||
display->grab_window == window) ||
|
display->grab_window == window) ||
|
||||||
grab_op_is_keyboard (display->grab_op))
|
grab_op_is_keyboard (display->grab_op))
|
||||||
{
|
{
|
||||||
@ -1818,8 +1821,7 @@ event_callback (XEvent *event,
|
|||||||
*/
|
*/
|
||||||
unmodified = (event->xbutton.state & grab_mask) == 0;
|
unmodified = (event->xbutton.state & grab_mask) == 0;
|
||||||
|
|
||||||
if (unmodified ||
|
if (unmodified || n_button == 1)
|
||||||
event->xbutton.button == 1)
|
|
||||||
{
|
{
|
||||||
/* don't focus if frame received, will be lowered in
|
/* don't focus if frame received, will be lowered in
|
||||||
* frames.c or special-cased if the click was on a
|
* frames.c or special-cased if the click was on a
|
||||||
@ -1840,7 +1842,7 @@ event_callback (XEvent *event,
|
|||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_FOCUS,
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
"Focusing %s due to unmodified button %u press (display.c)\n",
|
"Focusing %s due to unmodified button %u press (display.c)\n",
|
||||||
window->desc, event->xbutton.button);
|
window->desc, n_button);
|
||||||
meta_window_focus (window, evtime);
|
meta_window_focus (window, evtime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1856,7 +1858,7 @@ event_callback (XEvent *event,
|
|||||||
if (!unmodified)
|
if (!unmodified)
|
||||||
begin_move = TRUE;
|
begin_move = TRUE;
|
||||||
}
|
}
|
||||||
else if (!unmodified && event->xbutton.button == meta_prefs_get_mouse_button_resize())
|
else if (!unmodified && n_button == meta_prefs_get_mouse_button_resize())
|
||||||
{
|
{
|
||||||
if (window->has_resize_func)
|
if (window->has_resize_func)
|
||||||
{
|
{
|
||||||
@ -1898,21 +1900,21 @@ event_callback (XEvent *event,
|
|||||||
op,
|
op,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
FALSE,
|
||||||
event->xbutton.button,
|
n_button,
|
||||||
0,
|
0,
|
||||||
evtime,
|
evtime,
|
||||||
event->xbutton.x_root,
|
event->xbutton.x_root,
|
||||||
event->xbutton.y_root);
|
event->xbutton.y_root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event->xbutton.button == meta_prefs_get_mouse_button_menu())
|
else if (n_button == meta_prefs_get_mouse_button_menu())
|
||||||
{
|
{
|
||||||
if (meta_prefs_get_raise_on_click ())
|
if (meta_prefs_get_raise_on_click ())
|
||||||
meta_window_raise (window);
|
meta_window_raise (window);
|
||||||
meta_window_show_menu (window,
|
meta_window_show_menu (window,
|
||||||
event->xbutton.x_root,
|
event->xbutton.x_root,
|
||||||
event->xbutton.y_root,
|
event->xbutton.y_root,
|
||||||
event->xbutton.button,
|
n_button,
|
||||||
evtime);
|
evtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1955,7 +1957,7 @@ event_callback (XEvent *event,
|
|||||||
META_GRAB_OP_MOVING,
|
META_GRAB_OP_MOVING,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
FALSE,
|
||||||
event->xbutton.button,
|
n_button,
|
||||||
0,
|
0,
|
||||||
evtime,
|
evtime,
|
||||||
event->xbutton.x_root,
|
event->xbutton.x_root,
|
||||||
|
@ -495,3 +495,48 @@ meta_input_event_get_keycode (MetaDisplay *display,
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_input_event_get_button (MetaDisplay *display,
|
||||||
|
XEvent *ev,
|
||||||
|
guint *button)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XINPUT2
|
||||||
|
if (ev->type == GenericEvent &&
|
||||||
|
ev->xcookie.extension == display->xinput2_opcode)
|
||||||
|
{
|
||||||
|
XIEvent *xev;
|
||||||
|
|
||||||
|
g_assert (display->have_xinput2 == TRUE);
|
||||||
|
|
||||||
|
xev = (XIEvent *) ev->xcookie.data;
|
||||||
|
|
||||||
|
if (xev->evtype == XI_ButtonPress ||
|
||||||
|
xev->evtype == XI_ButtonRelease)
|
||||||
|
{
|
||||||
|
if (button)
|
||||||
|
{
|
||||||
|
/* The detail field contains
|
||||||
|
* button number for button events
|
||||||
|
*/
|
||||||
|
*button = ((XIDeviceEvent *) xev)->detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* HAVE_XINPUT2 */
|
||||||
|
{
|
||||||
|
if (ev->type == ButtonPress ||
|
||||||
|
ev->type == ButtonRelease)
|
||||||
|
{
|
||||||
|
if (button)
|
||||||
|
*button = ev->xbutton.button;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
@ -60,5 +60,8 @@ gboolean meta_input_event_get_state (MetaDisplay *display,
|
|||||||
gboolean meta_input_event_get_keycode (MetaDisplay *display,
|
gboolean meta_input_event_get_keycode (MetaDisplay *display,
|
||||||
XEvent *ev,
|
XEvent *ev,
|
||||||
guint *keycode);
|
guint *keycode);
|
||||||
|
gboolean meta_input_event_get_button (MetaDisplay *display,
|
||||||
|
XEvent *event,
|
||||||
|
guint *button);
|
||||||
|
|
||||||
#endif /* META_EVENT_H */
|
#endif /* META_EVENT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user