Commit graph

140 commits

Author SHA1 Message Date
Joshua Ashton
a74060381b cursor: Fix crash when creating a cursor constraint
Fix crash when creating a cursor constraint and there is no currently
focused view.

Fixes a crash starting Warhammer 40,000: Dawn of War II (15620)
2022-07-14 05:16:26 +02:00
Consolatis
5a4c5de332 src/menu: Attach view to menu and use it when executing actions
This fixes #380
2022-06-09 22:09:40 +01:00
Consolatis
ca9226a7a6 src/ssd: Convert button node descriptors to struct ssd_button
This allows for way easier button hover detection and future
features like toggling rounded corner buttons on maximize.
2022-06-09 22:04:35 +01:00
Consolatis
163179dda1 Chase wlroots: wlr_scene_surface
To update the wlroots subproject use
meson subprojects update wlroots
2022-05-26 06:48:00 +01:00
Consolatis
499df78531 src/cursor.c: Ignore out-of-surface movement for surfaces without views 2022-05-25 21:32:48 +01:00
Consolatis
b24b9d2d23 src/cursor.c: Ensure we send a release event for out-of-surface scrolling 2022-05-25 21:32:48 +01:00
Johan Malm
81810db3b6 cursor: offset xdg invisible border when dragging outside view
Note: view->padding was deleted in commit b279550 as the wlroots
scene-graph xdg-surface commit handler offsets the CSD invisible border.
If view->padding still existed, we could have used that, but considering
that this is probably the only place where this offset will now be
needed (because we're generating surface local coordinates), it's simpler
to just do it locally.

Related to issue #340

Written-by: @Consolatis
2022-05-24 17:49:21 +01:00
Consolatis
6dd290afc9 src/cursor.c: Fix branch condition for out-of-view selecting/dragging
Instead of using the stored view for comparison use the actual surface.

Before this patch, there were situations where the branch intended for
out-of-window text selection / scrollbar dragging was used even though
the cursor never left the surface.

Partly fixes #340
2022-05-24 17:35:32 +01:00
yizixiao
8b45ff6829 cursor.c:func is_double_click add check view 2022-04-28 22:05:39 +01:00
Consolatis
519375a7f8 Revert "config: support <mouse><default />"
This reverts commit 3d337857b7.

Revert for now until we have some infrastructure in place to
selectively replace default {key,mouse}binds with custom ones.

Fixes #304
Reported-by: @01micko
2022-04-26 19:56:06 +02:00
Johan Malm
3d337857b7 config: support <mouse><default />
This loads default mousebinds and provides a way to keep config files
simpler whilst allowing user specific binds.

Note that if no rc.xml is found, or if no <mouse><mousebind> entries
exist, the same default mousebinds will be loaded even if the <default />
element is not provided.

Example usage:

  <mouse>
    <default />
    <context name="Root">
      <mousebind button="Right" action="Press">
        <action name="Execute" command="my-menu-application" />
      </mousebind>
    </context>
  </mouse>
2022-04-22 17:52:01 +01:00
Johan Malm
5b34c81768 Fix trivial coding style breaches 2022-04-04 20:53:36 +01:00
John Lindgren
8e1f115486 cursor: Fix "jumping opposite edges" issue when resizing
Commit 08c537e ("xwayland: Honor size increments from
WM_SIZE_HINTS") adjusted only the window width/height according
to the size hints.  If resizing from the top or left edge of the
window, we also need to adjust the window position to keep the
bottom or right edge from jumping around.
2022-04-04 17:28:52 +01:00
Consolatis
47912aebb6 cursor.c: Do not segfault on missing drag icon
Observed by moving tabs in chromium wayland native
(started with --ozone-platform-hint=wayland).
2022-03-30 18:22:48 +01:00
Johan Malm
a2a2e093ef cursor.c: fix bad cherry-pick in previous commit (64f7b9d) 2022-03-21 20:33:10 +00:00
Consolatis
64f7b9dd2b Restore Drag mouse bindings and proper double click
Fixes #258 and #259

Reported-by: @ahmadraniri1994
Reported-by: @01micko
Suggested-by: bi4k8 <bi4k8@github>
2022-03-21 18:08:04 +00:00
Johan Malm
97846ae45b cursor: add cursor_update_focus()
...and call it from desktop_move_to_front() in order force an enter event
on the surface below the cursor when cycling views.

Fixes #162 and #225
Inspired by PR #164 - just restructured it a bit.

Suggested-by: @bi4k8
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
2022-03-21 17:57:20 +00:00
Consolatis
befe66d93f cursor.c: Keep sending adjusted motion events while button is pressed
This allows to keep dragging a scrollbar or selecting text even when
moving outside of the window. Fixes #241
2022-03-21 17:56:48 +00:00
Johan Malm
d844f6798b Chase wlroots wlr-device-input refactoring
Rename wlroots input device events, for example
's/wlr_event_pointer_motion/wlr_pointer_motion_event/'

seat.c:
- In configure_libinput() use wlr_input_device->type rather than width_mm
- In new_pointer() use wlr_input_device->type rather than output_name to
  check that device is pointer.
2022-03-19 11:34:11 +00:00
Consolatis
8444ba4075 Convert menu to node_descriptors 2022-03-03 17:49:54 +00:00
Johan Malm
bd9ac3478a Remove src/damage.c 2022-03-01 20:54:52 +00:00
Consolatis
953e8a4f9d [style] rename action() to actions_run() 2022-02-24 21:17:51 +00:00
Johan Malm
581a2bb2f1 cursor+keyboard: chase wlroots master
Use wlr_input_device from input device base.
Use wlr_keyboard where possible.
2022-02-23 22:19:16 +00:00
Consolatis
a2523081e2 Handle 'lost' unmanaged xsurfaces + improve cursor handling 2022-02-23 21:47:01 +00:00
Consolatis
5862b65f89 Convert SSD to scene nodes 2022-02-23 21:47:01 +00:00
Consolatis
f2d40a8d69 Scene Menu 2022-02-23 21:47:01 +00:00
Consolatis
7ea733761b Use view->scene_tree as toplevel for view + some legwork:
desktop.c move_to_front() calls wlr_scene_node_raise_to_top
desktop.c, ssd/include.h add LAB_SSD_{OSD, MENU, LAYER_SURFACE} enums
desktop.c desktop_surface_and_view_at() -> desktop_node_and_view_at()
cursor.c reenable cursor_rebase()
cursor.c reenable button click on layer surface
2022-02-23 21:47:01 +00:00
Johan Malm
532656ad5b Use wlroots scene-graph API
Move xdg-shell and xwayland-shell surfaces to new API

Also render alt-tab on-screen-display by converting cairo-surface to
wlr_buffer
2022-02-23 21:46:48 +00:00
Consolatis
fb09bbdd2f src/cursor.c: Reduce damage on button hover detection 2022-01-30 21:23:15 +00:00
Consolatis
413811f3a2 Use proper enum argument type for desktop_surface_and_view_at 2022-01-30 21:23:15 +00:00
Consolatis
759b26b5c1 Add window menu 2022-01-26 06:17:41 +00:00
Johan Malm
8dd3dc3e3b cursor: cursor_rebase() on mouse scroll
...to ensure that the surface under the mouse gets the focus even
if the mouse pointer has not moved.

Issue #162
2022-01-24 17:54:06 +00:00
Johan Malm
2652522a70 cursor: revert 6651d; remove cursor_update_focus()
...to ensure new windows receive keyboard focus even if the cursor is
over an existing window.

Fix issue #210
2022-01-24 17:51:54 +00:00
Consolatis
d9cef42721 CodeStyle 2022-01-09 06:37:39 +00:00
Consolatis
87f4a60e38 Allow mouse movements to trigger SnapToEdge 2022-01-08 10:30:03 +00:00
John Lindgren
4e3a03586a cursor: More reliably clear "pressed" status of mouse bindings
The "pressed" status of the mouse button is stored per-binding, and
the first binding activated causes us to break out of the loop that
cleared the "pressed" status -- as a result, some statused weren't
cleared when another binding was activated.

The bug could be seen when clicking the maximize button on a window
and then moving the mouse: the DRAG action would continue to move
the window (unmaximizing it) even though the mouse button was no
longer held.
2022-01-08 09:31:53 +00:00
John Lindgren
7f8b7f0a56 cursor: Don't allow a DRAG action to start from a double-click
By moving the cursor slightly after the second press (but before
the second release) it was possible to accidentally trigger both a
DOUBLECLICK and a DRAG action.  Doing this on the titlebar would
cause the window to maximize and then immediately unmaximize, which
feels very "glitchy".

As a simple fix, don't allow a press event that is triggering a
DOUBLECLICK to also trigger a DRAG (or CLICK) on the following
release event.

Note: Openbox avoids the issue by processing DOUBLECLICK on the
second release event.  If the cursor moves before that, the DRAG
wins out and the DOUBLECLICK isn't processed.
2022-01-08 09:31:53 +00:00
ARDiDo
a6a923c506 mousebindings: use available resize edges first in drag actions 2022-01-07 22:05:07 +00:00
ARDiDo
5935a78fb4 mouse: add support for drag mouse event 2022-01-07 22:05:07 +00:00
Johan Malm
3c92cc4dd0 Move action() prototype from labwc.h to action.h 2022-01-05 21:27:47 +00:00
Consolatis
0b45cce648 Rewrite action handling to allow multiple actions at once 2022-01-05 16:22:41 +00:00
Johan Malm
f7b63f264e cursor.c: fix coding style
Open brace '{' following function definitions go on the next line
2022-01-02 15:51:40 +00:00
bi4k8
80315295d2 cursor: support pointer gestures (pinch/swipe) 2022-01-01 19:24:27 +00:00
bi4k8
58f5e8d16a factor keyboard/cursor cleanup into own functions 2022-01-01 19:24:27 +00:00
Johan Malm
310c36c86d Fix build on Alpine Linux
Issue #144

Add `#define _POSIX_C_SOURCE 200809L` to avoid the error below:

../src/cursor.c: In function 'cursor_update_focus':
../src/cursor.c:271:2: warning: implicit declaration of function
'clock_gettime' [-Wimplicit-function-declaration]
  271 |  clock_gettime(CLOCK_MONOTONIC, &now);
      |  ^~~~~~~~~~~~~
../src/cursor.c:271:16: error: 'CLOCK_MONOTONIC' undeclared (first use in
this function)
  271 |  clock_gettime(CLOCK_MONOTONIC, &now);
      |                ^~~~~~~~~~~~~~~
../src/cursor.c:271:16: note: each undeclared identifier is reported only
once for each function it appears in
../src/cursor.c: In function 'is_double_click':
../src/cursor.c:486:16: error: 'CLOCK_MONOTONIC' undeclared (first use in
this function)
  486 |  clock_gettime(CLOCK_MONOTONIC, &now);
      |                ^~~~~~~~~~~~~~~
2021-12-28 15:06:33 +00:00
Johan Malm
34a12b3515 Fix coding style 2021-12-26 23:29:01 +00:00
Johan Malm
6651d45ed4 cursor: add cursor_update_focus()
...and call it from desktop_move_to_front() in order force an enter event
on the surface below the cursor when cycling views.

Inspired by PR #164 - just restructured it a bit.

Suggested-by: @bi4k8
2021-12-26 22:09:41 +00:00
Johan Malm
8d070ab2f4 cursor: fix setting of resize_edges
Only calculate nearest `resize_edges` if not clear from the server-side
deco under the cursor.
2021-12-26 21:35:37 +00:00
bi4k8
26d3d13a82 move edge resizing from hard-coded to configuration 2021-12-26 21:31:11 +00:00
Johan Malm
238062a859 desktop: rename functions to increase consistency
...from
- desktop_raise_view()
- desktop_move_view_to_end_of_cycle()

to
- desktop_move_to_front()
- desktop_move_to_back()
2021-12-06 21:23:49 +00:00