core: Delete now unused code
Since MetaWindowDrag took a lot of this code to handle window drags internally with less interactions with the rest of the stack, this code in display/window/keybindings is unused. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:

committed by
Marge Bot

parent
bec8a5860a
commit
39f1b6dca0
@ -1086,7 +1086,6 @@ meta_window_constructed (GObject *object)
|
||||
window->unmanaging = FALSE;
|
||||
window->keys_grabbed = FALSE;
|
||||
window->grab_on_frame = FALSE;
|
||||
window->all_keys_grabbed = FALSE;
|
||||
window->withdrawn = FALSE;
|
||||
window->initial_workspace_set = FALSE;
|
||||
window->initial_timestamp_set = FALSE;
|
||||
@ -3184,17 +3183,6 @@ meta_window_unmaximize (MetaWindow *window,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
target_rect);
|
||||
|
||||
/* When we unmaximize, if we're doing a mouse move also we could
|
||||
* get the window suddenly jumping to the upper left corner of
|
||||
* the workspace, since that's where it was when the grab op
|
||||
* started. So we need to update the grab anchor position.
|
||||
*/
|
||||
if (meta_grab_op_is_moving (window->display->grab_op) &&
|
||||
window->display->grab_window == window)
|
||||
{
|
||||
window->display->grab_anchor_window_pos = target_rect;
|
||||
}
|
||||
|
||||
meta_window_recalc_features (window);
|
||||
set_net_wm_state (window);
|
||||
if (!window->monitor->in_fullscreen)
|
||||
@ -4661,8 +4649,7 @@ meta_window_focus (MetaWindow *window,
|
||||
backend = backend_from_window (window);
|
||||
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
|
||||
|
||||
if (window->display->grab_op == META_GRAB_OP_NONE &&
|
||||
clutter_stage_get_grab_actor (stage) == NULL)
|
||||
if (clutter_stage_get_grab_actor (stage) == NULL)
|
||||
clutter_stage_set_key_focus (stage, NULL);
|
||||
|
||||
if (window->close_dialog &&
|
||||
@ -5797,590 +5784,6 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
|
||||
return is_onscreen;
|
||||
}
|
||||
|
||||
static void
|
||||
update_move_maybe_tile (MetaWindow *window,
|
||||
int shake_threshold,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
MetaBackend *backend = backend_from_window (window);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
MetaDisplay *display = window->display;
|
||||
MetaRectangle work_area;
|
||||
|
||||
/* For side-by-side tiling we are interested in the inside vertical
|
||||
* edges of the work area of the monitor where the pointer is located,
|
||||
* and in the outside top edge for maximized tiling.
|
||||
*
|
||||
* For maximized tiling we use the outside edge instead of the
|
||||
* inside edge, because we don't want to force users to maximize
|
||||
* windows they are placing near the top of their screens.
|
||||
*
|
||||
* The "current" idea of meta_window_get_work_area_current_monitor() and
|
||||
* meta_screen_get_current_monitor() is slightly different: the former
|
||||
* refers to the monitor which contains the largest part of the window,
|
||||
* the latter to the one where the pointer is located.
|
||||
*/
|
||||
logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
|
||||
if (!logical_monitor)
|
||||
return;
|
||||
|
||||
meta_window_get_work_area_for_monitor (window,
|
||||
logical_monitor->number,
|
||||
&work_area);
|
||||
|
||||
/* Check if the cursor is in a position which triggers tiling
|
||||
* and set tile_mode accordingly.
|
||||
*/
|
||||
if (meta_window_can_tile_side_by_side (window) &&
|
||||
x >= logical_monitor->rect.x && x < (work_area.x + shake_threshold))
|
||||
display->preview_tile_mode = META_TILE_LEFT;
|
||||
else if (meta_window_can_tile_side_by_side (window) &&
|
||||
x >= work_area.x + work_area.width - shake_threshold &&
|
||||
x < (logical_monitor->rect.x + logical_monitor->rect.width))
|
||||
display->preview_tile_mode = META_TILE_RIGHT;
|
||||
else if (meta_window_can_tile_maximized (window) &&
|
||||
y >= logical_monitor->rect.y && y <= work_area.y)
|
||||
display->preview_tile_mode = META_TILE_MAXIMIZED;
|
||||
else
|
||||
display->preview_tile_mode = META_TILE_NONE;
|
||||
|
||||
if (display->preview_tile_mode != META_TILE_NONE)
|
||||
window->tile_monitor_number = logical_monitor->number;
|
||||
}
|
||||
|
||||
static void
|
||||
update_move (MetaWindow *window,
|
||||
MetaEdgeResistanceFlags flags,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int dx, dy;
|
||||
int new_x, new_y;
|
||||
MetaRectangle old;
|
||||
int shake_threshold;
|
||||
MetaDisplay *display = window->display;
|
||||
|
||||
display->grab_latest_motion_x = x;
|
||||
display->grab_latest_motion_y = y;
|
||||
|
||||
meta_display_clear_grab_move_resize_later (display);
|
||||
|
||||
dx = x - display->grab_anchor_root_x;
|
||||
dy = y - display->grab_anchor_root_y;
|
||||
|
||||
new_x = display->grab_anchor_window_pos.x + dx;
|
||||
new_y = display->grab_anchor_window_pos.y + dy;
|
||||
|
||||
meta_verbose ("x,y = %d,%d anchor ptr %d,%d anchor pos %d,%d dx,dy %d,%d",
|
||||
x, y,
|
||||
display->grab_anchor_root_x,
|
||||
display->grab_anchor_root_y,
|
||||
display->grab_anchor_window_pos.x,
|
||||
display->grab_anchor_window_pos.y,
|
||||
dx, dy);
|
||||
|
||||
/* Don't bother doing anything if no move has been specified. (This
|
||||
* happens often, even in keyboard moving, due to the warping of the
|
||||
* pointer.
|
||||
*/
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
/* Originally for detaching maximized windows, but we use this
|
||||
* for the zones at the sides of the monitor where trigger tiling
|
||||
* because it's about the right size
|
||||
*/
|
||||
#define DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR 6
|
||||
shake_threshold = meta_prefs_get_drag_threshold () *
|
||||
DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR;
|
||||
|
||||
if (flags & META_EDGE_RESISTANCE_SNAP)
|
||||
{
|
||||
/* We don't want to tile while snapping. Also, clear any previous tile
|
||||
request. */
|
||||
display->preview_tile_mode = META_TILE_NONE;
|
||||
window->tile_monitor_number = -1;
|
||||
}
|
||||
else if (meta_prefs_get_edge_tiling () &&
|
||||
!META_WINDOW_MAXIMIZED (window) &&
|
||||
!META_WINDOW_TILED_SIDE_BY_SIDE (window))
|
||||
{
|
||||
update_move_maybe_tile (window, shake_threshold, x, y);
|
||||
}
|
||||
|
||||
/* shake loose (unmaximize) maximized or tiled window if dragged beyond
|
||||
* the threshold in the Y direction. Tiled windows can also be pulled
|
||||
* loose via X motion.
|
||||
*/
|
||||
|
||||
if ((META_WINDOW_MAXIMIZED (window) && ABS (dy) >= shake_threshold) ||
|
||||
(META_WINDOW_TILED_SIDE_BY_SIDE (window) && (MAX (ABS (dx), ABS (dy)) >= shake_threshold)))
|
||||
{
|
||||
double prop;
|
||||
|
||||
/* Shake loose, so that the window snaps back to maximized
|
||||
* when dragged near the top; do not snap back if tiling
|
||||
* is enabled, as top edge tiling can be used in that case
|
||||
*/
|
||||
window->shaken_loose = !meta_prefs_get_edge_tiling ();
|
||||
window->tile_mode = META_TILE_NONE;
|
||||
|
||||
/* move the unmaximized window to the cursor */
|
||||
prop =
|
||||
((double)(x - display->grab_initial_window_pos.x)) /
|
||||
((double)display->grab_initial_window_pos.width);
|
||||
|
||||
display->grab_initial_window_pos.x = x - window->saved_rect.width * prop;
|
||||
|
||||
/* If we started dragging the window from above the top of the window,
|
||||
* pretend like we started dragging from the middle of the titlebar
|
||||
* instead, as the "correct" anchoring looks wrong. */
|
||||
if (display->grab_anchor_root_y < display->grab_initial_window_pos.y)
|
||||
{
|
||||
MetaRectangle titlebar_rect;
|
||||
meta_window_get_titlebar_rect (window, &titlebar_rect);
|
||||
display->grab_anchor_root_y = display->grab_initial_window_pos.y + titlebar_rect.height / 2;
|
||||
}
|
||||
|
||||
window->saved_rect.x = display->grab_initial_window_pos.x;
|
||||
window->saved_rect.y = display->grab_initial_window_pos.y;
|
||||
|
||||
meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
|
||||
return;
|
||||
}
|
||||
|
||||
/* remaximize window on another monitor if window has been shaken
|
||||
* loose or it is still maximized (then move straight)
|
||||
*/
|
||||
else if ((window->shaken_loose || META_WINDOW_MAXIMIZED (window)) &&
|
||||
window->tile_mode != META_TILE_LEFT && window->tile_mode != META_TILE_RIGHT)
|
||||
{
|
||||
MetaBackend *backend = backend_from_window (window);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
int n_logical_monitors;
|
||||
const MetaLogicalMonitor *wmonitor;
|
||||
MetaRectangle work_area;
|
||||
int monitor;
|
||||
|
||||
window->tile_mode = META_TILE_NONE;
|
||||
wmonitor = window->monitor;
|
||||
n_logical_monitors =
|
||||
meta_monitor_manager_get_num_logical_monitors (monitor_manager);
|
||||
|
||||
for (monitor = 0; monitor < n_logical_monitors; monitor++)
|
||||
{
|
||||
meta_window_get_work_area_for_monitor (window, monitor, &work_area);
|
||||
|
||||
/* check if cursor is near the top of a monitor work area */
|
||||
if (x >= work_area.x &&
|
||||
x < (work_area.x + work_area.width) &&
|
||||
y >= work_area.y &&
|
||||
y < (work_area.y + shake_threshold))
|
||||
{
|
||||
/* move the saved rect if window will become maximized on an
|
||||
* other monitor so user isn't surprised on a later unmaximize
|
||||
*/
|
||||
if (wmonitor->number != monitor)
|
||||
{
|
||||
window->saved_rect.x = work_area.x;
|
||||
window->saved_rect.y = work_area.y;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
window->saved_rect.x += window->frame->child_x;
|
||||
window->saved_rect.y += window->frame->child_y;
|
||||
}
|
||||
|
||||
window->unconstrained_rect.x = window->saved_rect.x;
|
||||
window->unconstrained_rect.y = window->saved_rect.y;
|
||||
|
||||
meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
|
||||
|
||||
display->grab_initial_window_pos = work_area;
|
||||
display->grab_anchor_root_x = x;
|
||||
display->grab_anchor_root_y = y;
|
||||
window->shaken_loose = FALSE;
|
||||
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Delay showing the tile preview slightly to make it more unlikely to
|
||||
* trigger it unwittingly, e.g. when shaking loose the window or moving
|
||||
* it to another monitor.
|
||||
*/
|
||||
meta_display_update_tile_preview (window->display,
|
||||
window->tile_mode != META_TILE_NONE);
|
||||
|
||||
meta_window_get_frame_rect (window, &old);
|
||||
|
||||
/* Don't allow movement in the maximized directions or while tiled */
|
||||
if (window->maximized_horizontally || META_WINDOW_TILED_SIDE_BY_SIDE (window))
|
||||
new_x = old.x;
|
||||
if (window->maximized_vertically)
|
||||
new_y = old.y;
|
||||
|
||||
/* Do any edge resistance/snapping */
|
||||
meta_window_edge_resistance_for_move (window,
|
||||
&new_x,
|
||||
&new_y,
|
||||
flags);
|
||||
|
||||
meta_window_move_frame (window, TRUE, new_x, new_y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_move_cb (gpointer user_data)
|
||||
{
|
||||
MetaWindow *window = user_data;
|
||||
|
||||
window->display->grab_move_resize_later_id = 0;
|
||||
|
||||
update_move (window,
|
||||
window->display->grab_last_edge_resistance_flags,
|
||||
window->display->grab_latest_motion_x,
|
||||
window->display->grab_latest_motion_y);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
queue_update_move (MetaWindow *window,
|
||||
MetaEdgeResistanceFlags flags,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
MetaCompositor *compositor;
|
||||
MetaLaters *laters;
|
||||
|
||||
window->display->grab_last_edge_resistance_flags = flags;
|
||||
window->display->grab_latest_motion_x = x;
|
||||
window->display->grab_latest_motion_y = y;
|
||||
|
||||
if (window->display->grab_move_resize_later_id)
|
||||
return;
|
||||
|
||||
compositor = meta_display_get_compositor (window->display);
|
||||
laters = meta_compositor_get_laters (compositor);
|
||||
window->display->grab_move_resize_later_id =
|
||||
meta_laters_add (laters,
|
||||
META_LATER_BEFORE_REDRAW,
|
||||
update_move_cb,
|
||||
window, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
update_resize (MetaWindow *window,
|
||||
MetaEdgeResistanceFlags flags,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int dx, dy;
|
||||
MetaGravity gravity;
|
||||
MetaRectangle new_rect;
|
||||
MetaRectangle old_rect;
|
||||
|
||||
window->display->grab_latest_motion_x = x;
|
||||
window->display->grab_latest_motion_y = y;
|
||||
|
||||
meta_display_clear_grab_move_resize_later (window->display);
|
||||
|
||||
dx = x - window->display->grab_anchor_root_x;
|
||||
dy = y - window->display->grab_anchor_root_y;
|
||||
|
||||
/* Attached modal dialogs are special in that size
|
||||
* changes apply to both sides, so that the dialog
|
||||
* remains centered to the parent.
|
||||
*/
|
||||
if (meta_window_is_attached_dialog (window))
|
||||
{
|
||||
dx *= 2;
|
||||
dy *= 2;
|
||||
}
|
||||
|
||||
new_rect.width = window->display->grab_anchor_window_pos.width;
|
||||
new_rect.height = window->display->grab_anchor_window_pos.height;
|
||||
|
||||
/* Don't bother doing anything if no move has been specified. (This
|
||||
* happens often, even in keyboard resizing, due to the warping of the
|
||||
* pointer.
|
||||
*/
|
||||
if (dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
if (window->display->grab_op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)
|
||||
{
|
||||
MetaGrabOp op = META_GRAB_OP_WINDOW_BASE | META_GRAB_OP_WINDOW_FLAG_KEYBOARD;
|
||||
|
||||
if (dx > 0)
|
||||
op |= META_GRAB_OP_WINDOW_DIR_EAST;
|
||||
else if (dx < 0)
|
||||
op |= META_GRAB_OP_WINDOW_DIR_WEST;
|
||||
|
||||
if (dy > 0)
|
||||
op |= META_GRAB_OP_WINDOW_DIR_SOUTH;
|
||||
else if (dy < 0)
|
||||
op |= META_GRAB_OP_WINDOW_DIR_NORTH;
|
||||
|
||||
window->display->grab_op = op;
|
||||
|
||||
meta_window_update_keyboard_resize (window, TRUE);
|
||||
}
|
||||
|
||||
if (window->display->grab_op & META_GRAB_OP_WINDOW_DIR_EAST)
|
||||
new_rect.width += dx;
|
||||
else if (window->display->grab_op & META_GRAB_OP_WINDOW_DIR_WEST)
|
||||
new_rect.width -= dx;
|
||||
|
||||
if (window->display->grab_op & META_GRAB_OP_WINDOW_DIR_SOUTH)
|
||||
new_rect.height += dy;
|
||||
else if (window->display->grab_op & META_GRAB_OP_WINDOW_DIR_NORTH)
|
||||
new_rect.height -= dy;
|
||||
|
||||
meta_window_maybe_apply_size_hints (window, &new_rect);
|
||||
|
||||
/* If we're waiting for a request for _NET_WM_SYNC_REQUEST, we'll
|
||||
* resize the window when the window responds, or when we time
|
||||
* the response out.
|
||||
*/
|
||||
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 &&
|
||||
meta_window_x11_is_awaiting_sync_response (window))
|
||||
return;
|
||||
|
||||
meta_window_get_frame_rect (window, &old_rect);
|
||||
|
||||
/* One sided resizing ought to actually be one-sided, despite the fact that
|
||||
* aspect ratio windows don't interact nicely with the above stuff. So,
|
||||
* to avoid some nasty flicker, we enforce that.
|
||||
*/
|
||||
|
||||
if ((window->display->grab_op & (META_GRAB_OP_WINDOW_DIR_WEST | META_GRAB_OP_WINDOW_DIR_EAST)) == 0)
|
||||
new_rect.width = old_rect.width;
|
||||
|
||||
if ((window->display->grab_op & (META_GRAB_OP_WINDOW_DIR_NORTH | META_GRAB_OP_WINDOW_DIR_SOUTH)) == 0)
|
||||
new_rect.height = old_rect.height;
|
||||
|
||||
/* compute gravity of client during operation */
|
||||
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
|
||||
g_assert (gravity >= 0);
|
||||
|
||||
/* Do any edge resistance/snapping */
|
||||
meta_window_edge_resistance_for_resize (window,
|
||||
&new_rect.width,
|
||||
&new_rect.height,
|
||||
gravity,
|
||||
flags);
|
||||
|
||||
meta_window_resize_frame_with_gravity (window, TRUE,
|
||||
new_rect.width, new_rect.height,
|
||||
gravity);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_resize_cb (gpointer user_data)
|
||||
{
|
||||
MetaWindow *window = user_data;
|
||||
|
||||
window->display->grab_move_resize_later_id = 0;
|
||||
|
||||
update_resize (window,
|
||||
window->display->grab_last_edge_resistance_flags,
|
||||
window->display->grab_latest_motion_x,
|
||||
window->display->grab_latest_motion_y);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
queue_update_resize (MetaWindow *window,
|
||||
MetaEdgeResistanceFlags flags,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
MetaCompositor *compositor;
|
||||
MetaLaters *laters;
|
||||
|
||||
window->display->grab_last_edge_resistance_flags = flags;
|
||||
window->display->grab_latest_motion_x = x;
|
||||
window->display->grab_latest_motion_y = y;
|
||||
|
||||
if (window->display->grab_move_resize_later_id)
|
||||
return;
|
||||
|
||||
compositor = meta_display_get_compositor (window->display);
|
||||
laters = meta_compositor_get_laters (compositor);
|
||||
window->display->grab_move_resize_later_id =
|
||||
meta_laters_add (laters,
|
||||
META_LATER_BEFORE_REDRAW,
|
||||
update_resize_cb,
|
||||
window, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_maximize_tiled_window (MetaWindow *window)
|
||||
{
|
||||
MetaRectangle work_area;
|
||||
gint shake_threshold;
|
||||
|
||||
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
|
||||
return;
|
||||
|
||||
shake_threshold = meta_prefs_get_drag_threshold ();
|
||||
|
||||
meta_window_get_work_area_for_monitor (window,
|
||||
window->tile_monitor_number,
|
||||
&work_area);
|
||||
if (window->rect.width >= work_area.width - shake_threshold)
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_update_resize (MetaWindow *window,
|
||||
MetaEdgeResistanceFlags flags,
|
||||
int x, int y)
|
||||
{
|
||||
update_resize (window, flags, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
end_grab_op (MetaWindow *window,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
ClutterModifierType modifiers;
|
||||
MetaEdgeResistanceFlags last_flags;
|
||||
gfloat x, y;
|
||||
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
modifiers = clutter_event_get_state (event);
|
||||
meta_display_check_threshold_reached (window->display, x, y);
|
||||
|
||||
/* If the user was snap moving then ignore the button
|
||||
* release because they may have let go of shift before
|
||||
* releasing the mouse button and they almost certainly do
|
||||
* not want a non-snapped movement to occur from the button
|
||||
* release.
|
||||
*/
|
||||
last_flags = window->display->grab_last_edge_resistance_flags;
|
||||
if ((last_flags & META_EDGE_RESISTANCE_SNAP) == 0)
|
||||
{
|
||||
MetaEdgeResistanceFlags flags = META_EDGE_RESISTANCE_DEFAULT;
|
||||
|
||||
if (modifiers & CLUTTER_SHIFT_MASK)
|
||||
flags |= META_EDGE_RESISTANCE_SNAP;
|
||||
|
||||
if (modifiers & CLUTTER_CONTROL_MASK)
|
||||
flags |= META_EDGE_RESISTANCE_WINDOWS;
|
||||
|
||||
if (meta_grab_op_is_moving (window->display->grab_op))
|
||||
{
|
||||
if (window->display->preview_tile_mode != META_TILE_NONE)
|
||||
meta_window_tile (window, window->display->preview_tile_mode);
|
||||
else
|
||||
update_move (window, flags, x, y);
|
||||
}
|
||||
else if (meta_grab_op_is_resizing (window->display->grab_op))
|
||||
{
|
||||
if (window->tile_match != NULL)
|
||||
flags |= (META_EDGE_RESISTANCE_SNAP | META_EDGE_RESISTANCE_WINDOWS);
|
||||
|
||||
update_resize (window, flags, x, y);
|
||||
maybe_maximize_tiled_window (window);
|
||||
}
|
||||
}
|
||||
window->display->preview_tile_mode = META_TILE_NONE;
|
||||
meta_display_end_grab_op (window->display, clutter_event_get_time (event));
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_window_handle_mouse_grab_op_event (MetaWindow *window,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
||||
ClutterModifierType modifier_state;
|
||||
MetaEdgeResistanceFlags flags;
|
||||
gfloat x, y;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_TOUCH_BEGIN:
|
||||
if (!meta_display_is_pointer_emulating_sequence (window->display, sequence))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_BUTTON_PRESS:
|
||||
{
|
||||
/* This is the keybinding or menu case where we've
|
||||
* been dragging around the window without the button
|
||||
* pressed, or the case of pressing extra mouse buttons
|
||||
* while a grab op is ongoing.
|
||||
*/
|
||||
end_grab_op (window, event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case CLUTTER_TOUCH_END:
|
||||
if (!meta_display_is_pointer_emulating_sequence (window->display, sequence))
|
||||
return FALSE;
|
||||
|
||||
end_grab_op (window, event);
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_BUTTON_RELEASE:
|
||||
if (event->button.button == 1 ||
|
||||
event->button.button == (unsigned int) meta_prefs_get_mouse_button_resize ())
|
||||
end_grab_op (window, event);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_TOUCH_UPDATE:
|
||||
if (!meta_display_is_pointer_emulating_sequence (window->display, sequence))
|
||||
return FALSE;
|
||||
|
||||
/* Fall through */
|
||||
case CLUTTER_MOTION:
|
||||
modifier_state = clutter_event_get_state (event);
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
flags = META_EDGE_RESISTANCE_DEFAULT;
|
||||
|
||||
if (modifier_state & CLUTTER_SHIFT_MASK)
|
||||
flags |= META_EDGE_RESISTANCE_SNAP;
|
||||
|
||||
if (modifier_state & CLUTTER_CONTROL_MASK)
|
||||
flags |= META_EDGE_RESISTANCE_WINDOWS;
|
||||
|
||||
meta_display_check_threshold_reached (window->display, x, y);
|
||||
if (meta_grab_op_is_moving (window->display->grab_op))
|
||||
{
|
||||
queue_update_move (window, flags, x, y);
|
||||
}
|
||||
else if (meta_grab_op_is_resizing (window->display->grab_op))
|
||||
{
|
||||
if (window->tile_match != NULL)
|
||||
flags |= (META_EDGE_RESISTANCE_SNAP | META_EDGE_RESISTANCE_WINDOWS);
|
||||
|
||||
queue_update_resize (window, flags, x, y);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case CLUTTER_TOUCH_CANCEL:
|
||||
end_grab_op (window, event);
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_get_work_area_for_logical_monitor (MetaWindow *window,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
@ -6683,72 +6086,6 @@ meta_window_is_ancestor_of_transient (MetaWindow *window,
|
||||
return d.found;
|
||||
}
|
||||
|
||||
/* Warp pointer to location appropriate for grab,
|
||||
* return root coordinates where pointer ended up.
|
||||
*/
|
||||
static gboolean
|
||||
warp_grab_pointer (MetaWindow *window,
|
||||
MetaGrabOp grab_op,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
MetaRectangle rect;
|
||||
MetaRectangle display_rect = { 0 };
|
||||
MetaDisplay *display;
|
||||
ClutterSeat *seat;
|
||||
|
||||
display = window->display;
|
||||
meta_display_get_size (display,
|
||||
&display_rect.width,
|
||||
&display_rect.height);
|
||||
|
||||
/* We may not have done begin_grab_op yet, i.e. may not be in a grab
|
||||
*/
|
||||
|
||||
meta_window_get_frame_rect (window, &rect);
|
||||
|
||||
if (grab_op & META_GRAB_OP_WINDOW_DIR_WEST)
|
||||
*x = 0;
|
||||
else if (grab_op & META_GRAB_OP_WINDOW_DIR_EAST)
|
||||
*x = rect.width - 1;
|
||||
else
|
||||
*x = rect.width / 2;
|
||||
|
||||
if (grab_op & META_GRAB_OP_WINDOW_DIR_NORTH)
|
||||
*y = 0;
|
||||
else if (grab_op & META_GRAB_OP_WINDOW_DIR_SOUTH)
|
||||
*y = rect.height - 1;
|
||||
else
|
||||
*y = rect.height / 2;
|
||||
|
||||
*x += rect.x;
|
||||
*y += rect.y;
|
||||
|
||||
/* Avoid weird bouncing at the screen edge; see bug 154706 */
|
||||
*x = CLAMP (*x, 0, display_rect.width - 1);
|
||||
*y = CLAMP (*y, 0, display_rect.height - 1);
|
||||
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Warping pointer to %d,%d with window at %d,%d",
|
||||
*x, *y, rect.x, rect.y);
|
||||
|
||||
/* Need to update the grab positions so that the MotionNotify and other
|
||||
* events generated by the XWarpPointer() call below don't cause complete
|
||||
* funkiness. See bug 124582 and bug 122670.
|
||||
*/
|
||||
display->grab_anchor_root_x = *x;
|
||||
display->grab_anchor_root_y = *y;
|
||||
display->grab_latest_motion_x = *x;
|
||||
display->grab_latest_motion_y = *y;
|
||||
meta_window_get_frame_rect (window,
|
||||
&display->grab_anchor_window_pos);
|
||||
|
||||
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
clutter_seat_warp_pointer (seat, *x, *y);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_window_begin_grab_op (MetaWindow *window,
|
||||
MetaGrabOp op,
|
||||
@ -6759,30 +6096,6 @@ meta_window_begin_grab_op (MetaWindow *window,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_update_keyboard_resize (MetaWindow *window,
|
||||
gboolean update_cursor)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
warp_grab_pointer (window,
|
||||
window->display->grab_op,
|
||||
&x, &y);
|
||||
|
||||
if (update_cursor)
|
||||
meta_display_update_cursor (window->display);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_update_keyboard_move (MetaWindow *window)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
warp_grab_pointer (window,
|
||||
window->display->grab_op,
|
||||
&x, &y);
|
||||
}
|
||||
|
||||
MetaStackLayer
|
||||
meta_window_get_default_layer (MetaWindow *window)
|
||||
{
|
||||
|
Reference in New Issue
Block a user