mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
Prevent cursor based region-snapping when starting a move with A-Left
When wanting to snap to a region when starting the move operation with A-Left (or a similar mousebind which includes a modifier), the modifier - or another one - must be pressed again. Fixes #761
This commit is contained in:
parent
a0b5a80ce1
commit
a4fb5b093b
6 changed files with 40 additions and 28 deletions
|
|
@ -164,6 +164,8 @@ struct seat {
|
|||
/* Private use by regions.c */
|
||||
struct region *region_active;
|
||||
struct region_overlay region_overlay;
|
||||
/* Used to prevent region snapping when starting a move with A-Left */
|
||||
bool region_prevent_snap;
|
||||
|
||||
struct wl_client *active_client_while_inhibited;
|
||||
struct wl_list inputs;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ struct region_overlay {
|
|||
};
|
||||
};
|
||||
|
||||
/* Can be used as a cheap check to detect if there are any regions configured */
|
||||
bool regions_available(void);
|
||||
/* Returns true if we should show the region overlay or snap to region */
|
||||
bool regions_should_snap(struct server *server);
|
||||
|
||||
/**
|
||||
* regions_reconfigure*() - re-initializes all regions from struct rc.
|
||||
|
|
|
|||
15
src/cursor.c
15
src/cursor.c
|
|
@ -190,17 +190,14 @@ process_cursor_move(struct server *server, uint32_t time)
|
|||
view_move(view, dx, dy);
|
||||
|
||||
/* Region overlay */
|
||||
if (!regions_available()) {
|
||||
if (!regions_should_snap(server)) {
|
||||
return;
|
||||
}
|
||||
struct wlr_keyboard *keyboard = &server->seat.keyboard_group->keyboard;
|
||||
if (keyboard_any_modifiers_pressed(keyboard)) {
|
||||
struct region *region = regions_from_cursor(server);
|
||||
if (region) {
|
||||
regions_show_overlay(view, &server->seat, region);
|
||||
} else {
|
||||
regions_hide_overlay(&server->seat);
|
||||
}
|
||||
struct region *region = regions_from_cursor(server);
|
||||
if (region) {
|
||||
regions_show_overlay(view, &server->seat, region);
|
||||
} else {
|
||||
regions_hide_overlay(&server->seat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
|
|||
/* Store natural geometry at start of move */
|
||||
view_store_natural_geometry(view);
|
||||
}
|
||||
|
||||
/* Prevent region snapping when just moving via A-Left mousebind */
|
||||
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
|
||||
seat->region_prevent_snap = keyboard_any_modifiers_pressed(keyboard);
|
||||
|
||||
cursor_set(seat, LAB_CURSOR_GRAB);
|
||||
break;
|
||||
case LAB_INPUT_STATE_RESIZE:
|
||||
|
|
@ -137,20 +142,15 @@ snap_to_edge(struct view *view)
|
|||
static bool
|
||||
snap_to_region(struct view *view)
|
||||
{
|
||||
if (!regions_available()) {
|
||||
if (!regions_should_snap(view->server)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_keyboard *keyboard =
|
||||
&view->server->seat.keyboard_group->keyboard;
|
||||
|
||||
if (keyboard_any_modifiers_pressed(keyboard)) {
|
||||
struct region *region = regions_from_cursor(view->server);
|
||||
if (region) {
|
||||
view_snap_to_region(view, region,
|
||||
/*store_natural_geometry*/ false);
|
||||
return true;
|
||||
}
|
||||
struct region *region = regions_from_cursor(view->server);
|
||||
if (region) {
|
||||
view_snap_to_region(view, region,
|
||||
/*store_natural_geometry*/ false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -159,11 +159,8 @@ void
|
|||
interactive_finish(struct view *view)
|
||||
{
|
||||
if (view->server->grabbed_view == view) {
|
||||
enum input_mode mode = view->server->input_mode;
|
||||
regions_hide_overlay(&view->server->seat);
|
||||
view->server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
||||
view->server->grabbed_view = NULL;
|
||||
if (mode == LAB_INPUT_STATE_MOVE) {
|
||||
if (view->server->input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
if (!snap_to_region(view)) {
|
||||
if (!snap_to_edge(view)) {
|
||||
/* Reset tiled state if not snapped */
|
||||
|
|
@ -171,6 +168,10 @@ interactive_finish(struct view *view)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
view->server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
|
||||
view->server->grabbed_view = NULL;
|
||||
|
||||
/* Update focus/cursor image */
|
||||
cursor_update_focus(view->server);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ keyboard_modifiers_notify(struct wl_listener *listener, void *data)
|
|||
struct wlr_keyboard_key_event *event = data;
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
|
||||
if (server->input_mode == LAB_INPUT_STATE_MOVE) {
|
||||
/* Any change to the modifier state re-enable region snap */
|
||||
seat->region_prevent_snap = false;
|
||||
}
|
||||
|
||||
if (server->osd_state.cycle_view || server->grabbed_view
|
||||
|| seat->workspace_osd_shown_by_modifier) {
|
||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED
|
||||
|
|
|
|||
|
|
@ -17,9 +17,16 @@
|
|||
#include "view.h"
|
||||
|
||||
bool
|
||||
regions_available(void)
|
||||
regions_should_snap(struct server *server)
|
||||
{
|
||||
return !wl_list_empty(&rc.regions);
|
||||
if (server->input_mode != LAB_INPUT_STATE_MOVE
|
||||
|| wl_list_empty(&rc.regions)
|
||||
|| server->seat.region_prevent_snap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_keyboard *keyboard = &server->seat.keyboard_group->keyboard;
|
||||
return keyboard_any_modifiers_pressed(keyboard);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue