Commit graph

171 commits

Author SHA1 Message Date
Arnaudv6
063a26ae9d Scroll-Bindings: Add support for mouse wheel bindings 2022-11-06 22:03:50 +01:00
Johan Malm
e45e2c7e60 Fix coding style 2022-11-03 23:01:52 +01:00
Consolatis
deb658b672 cursor: Restore drag icon after the move to scene-graph
Also move everything DnD related to src/dnd.c
2022-10-17 21:22:12 +01:00
John Lindgren
cd970945f4 cursor: Call wlr_seat_pointer_notify_clear_focus() only if needed
@Consolatis determined that apparently the extra "clear focus"
event confuses the drag source during drag-and-drop.

Fixes drag-and-drop of files into folders within the same Thunar
window.
2022-10-14 21:56:34 +01:00
Consolatis
2c83a5fcb8 cursor: Prevent setting cursor icon on drag
Partly fixes #549
2022-09-21 21:55:28 +01:00
John Lindgren
a54d378e6c common: Add znew/znew_n() macros 2022-09-18 15:25:19 -04:00
John Lindgren
cb40cdc36c common: Add additional memory utilities (xzalloc() etc.) 2022-09-17 10:57:30 -04:00
Consolatis
e30fce6c34 cursor: Use enum for server set cursor names
This mainly prevents having to use strcmp() on every mouse move.
2022-09-16 21:30:40 +01:00
John Lindgren
bbc6c6bb94 action: Select resize edges for Resize triggered by keybind 2022-09-16 01:42:04 +02:00
John Lindgren
f112fb636e cursor: Split out cursor_button_press() and cursor_button_release() 2022-09-16 01:36:07 +02:00
John Lindgren
1fafb89cba cursor: Store view + resize edges for move/resize in press event
v2: Restore previous behavior for keybinds
2022-09-15 06:13:27 +02:00
John Lindgren
429c388333 cursor: Add struct cursor_context and clean up code
v2:
 - Add surface to cursor_context, rename c -> ctx
 - Factor out determine_resize_edges()
2022-09-15 03:12:38 +02:00
John Lindgren
e18f7a32ba cursor: Allow leave/enter events within the same XDG toplevel
Attempting to open a GTK3 menu and activate a menu item in it,
using a single mouse motion (press-move-release), was broken due
to GTK apparently expecting to receive leave/enter events when the
cursor enters the menu (XDG popup).

To fix the issue, allow leave/enter events when the cursor is
moved between an XDG toplevel and popups of the same.

v2:
 - Use (struct view *) as proxy for toplevel in comparisons
 - Update seat->pressed.surface when entering/leaving popups
v3:
 - Go back to using get_toplevel() rather than (struct view *)
2022-09-13 15:57:20 -04:00
John Lindgren
b8c3fdaef9 seat: Listen for destroy signal of pressed.surface 2022-09-13 15:57:20 -04:00
John Lindgren
6c6e406507 cursor: Factor out cursor_update_common() and fix some glitches
Fix a couple of glitches seen when exiting interactive move/resize:

 - Cursor briefly set to left_ptr rather than the correct cursor image
 - Cursor not updated if the view being moved/resized is destroyed

Also make sure to exit interactive mode if the view is going fullscreen
(labwc gets very confused otherwise).

Code changes in detail:

 - Factor out set_server_cursor() which will set the correct cursor
   image for non-client areas (either XCURSOR_DEFAULT or one of the
   resize cursors).
 - Unify the logic from cursor_rebase() and process_cursor_motion by
   factoring out cursor_update_common().  This corrects some logic
   discrepancies between the two, which should be a good thing(TM).
 - Remove the extra cursor_set(XCURSOR_DEFAULT) from interactive_end()
   and instead rely on cursor_update_focus() to do the right thing.
 - Simplify cursor_button() by just calling interactive_end() when we
   want to exit interactive mode.
 - Call cursor_update_focus() from view_destroy() if the view had mouse
   focus or was being interactively moved/resized.

v2: Eliminate force_reenter parameters and figure out automatically
    when we need to re-enter the surface.
v3: Rename wlseat -> wlr_seat.
v4: Simplify client/server cursor logic.
2022-09-13 13:29:36 -04:00
Consolatis
baf555edd0 cursor: Handle missing cursor theme
Temporary fix for #246

This should be reverted once wlroots MR !3651 is merged.
2022-09-11 21:20:00 +01:00
Consolatis
0deaeceb72 cursor: Prevent setting the same cursor image twice
Possibly fixes #512

Reported-by: @Flrian
2022-09-11 13:30:10 +01:00
Consolatis
7af74c88a8 cursor: Prevent resetting cursor icon during Move or Resize
Reported-by: @Flrian
2022-09-11 13:24:27 +01:00
Consolatis
c0f0e0c46e cursor: Allow re-enter for cursor_update_focus()
This allows forcing an application to re-set their desired cursor image.
2022-09-11 13:24:27 +01:00
Consolatis
2bbd882df9 cursor: Update cursor focus on scroll events 2022-09-08 01:32:22 +02:00
Consolatis
f057235a1f cursor: Make cursor_rebase() private
Also allow to re-use node, surface, sx and sy.
2022-09-08 01:32:22 +02:00
Consolatis
601a6250b7 cursor: Allow cursor button events to trigger cursor_rebase() 2022-09-08 01:32:22 +02:00
John Lindgren
ec2522fec8 cursor: Update SSD hover state in cursor_rebase()
Fixes an issue where the maximize button would remain highlighted
after maximized a window.
2022-09-06 18:22:17 -04:00
John Lindgren
469adc46d6 cursor: Update focus at various additional points
- When XDG and XWayland views are positioned (view_moved()).
- When unmanaged XWayland surfaces are mapped, unmapped, or moved.

Do not update cursor focus during an out-of-surface drag.

Along with the existing call in desktop_move_to_front(), this
should hopefully cover the majority of cases where the cursor focus
could get out-of-date, with the possible exception of layer-shell
surfaces.
2022-09-06 18:22:17 -04:00
John Lindgren
7c6c018f43 cursor: Fix out-of-surface movement for unmanaged surfaces 2022-09-02 05:12:34 +02:00
Consolatis
99237cc232 src/config/mousebind.c: Fix mousebind ordering 2022-08-30 16:39:09 +01:00
Johan Malm
0b0e438adb src/cursor.c: refactor nested if-statements 2022-08-17 14:03:38 +02:00
Johan Malm
f19645aa25 cursor: do not clamp motion coordinates for xdg-shell surfaces
...when pointer moves off the xdg-shell surface which is possible when
for example grabbing a scroll-bar or selecting text.

Clamping results in undetected pointer motion when applied in the
direction of movement (for example clamping at view->y masks vertical
movement when the y-coordinate is greater than view->y), which in turn
can appear as sporadic to the end-user.
2022-08-17 14:03:38 +02:00
Consolatis
921c877f79 src/cursor.c: Keep sending motion events for out-of-layer-surface
Previously, motion events for a cursor which had been pressed on a surface
and then moved out of the surface were only sent for XDG and X11 surfaces.

This patch includes layer surfaces as well.

Fixes #483
2022-08-16 19:31:16 +01:00
John Lindgren
8e6d37772e cursor: Do not clamp motion coordinates for XWayland surfaces.
X11 apps expect to be able to receive motion events outside
the window area (this is necessary for client-side move/resize
handles to work properly).  So do not clamp the motion
coordinates for XWayland surfaces.

Before this change, attempting to enlarge an XWayland window
using a client-side resize handle resulted in the window size
lagging behind the mouse cursor quite severely, since each
motion event was in effect allowed to expand the window by
only a few pixels.  The closer the initial button-press was
to the edge of the window, the worse the lag would be.
2022-08-16 19:31:16 +01:00
John Lindgren
2b7be71254 cursor: Move resistance_resize_apply() before view_adjust_size()
This ensures that screen edge resistance does not result in sizes
that violate WM_SIZE_HINTS constraints.

Also correct a coding style issue nearby.
2022-07-18 22:06:12 +01:00
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