mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
cursor: handle alt + mouse button (issue #40)
Move view on alt + left mouse button Resize view on alt + right mouse button
This commit is contained in:
parent
b19eecbbd4
commit
b194881ac2
1 changed files with 27 additions and 0 deletions
27
src/cursor.c
27
src/cursor.c
|
|
@ -1,4 +1,5 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <linux/input-event-codes.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
|
|
@ -270,6 +271,23 @@ cursor_motion_absolute(struct wl_listener *listener, void *data)
|
||||||
process_cursor_motion(seat->server, event->time_msec);
|
process_cursor_motion(seat->server, event->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_cursor_button_with_meta_key(struct view *view, uint32_t button,
|
||||||
|
double lx, double ly)
|
||||||
|
{
|
||||||
|
/* move */
|
||||||
|
if (button == BTN_LEFT) {
|
||||||
|
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* resize */
|
||||||
|
uint32_t edges;
|
||||||
|
edges = lx < view->x + view->w / 2 ? WLR_EDGE_LEFT : WLR_EDGE_RIGHT;
|
||||||
|
edges |= ly < view->y + view->h / 2 ? WLR_EDGE_TOP : WLR_EDGE_BOTTOM;
|
||||||
|
interactive_begin(view, LAB_INPUT_STATE_RESIZE, edges);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cursor_button(struct wl_listener *listener, void *data)
|
cursor_button(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -318,6 +336,15 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle alt + _press_ on view */
|
||||||
|
struct wlr_input_device *device = seat->keyboard_group->input_device;
|
||||||
|
uint32_t modifiers = wlr_keyboard_get_modifiers(device->keyboard);
|
||||||
|
if (modifiers & XKB_KEY_Alt_L) {
|
||||||
|
handle_cursor_button_with_meta_key(view, event->button,
|
||||||
|
server->seat.cursor->x, server->seat.cursor->y);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
/* Handle _press_ on view */
|
/* Handle _press_ on view */
|
||||||
desktop_focus_view(&server->seat, view);
|
desktop_focus_view(&server->seat, view);
|
||||||
damage_all_outputs(server);
|
damage_all_outputs(server);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue