Commit graph

381 commits

Author SHA1 Message Date
John Lindgren
f08e931a29 include: Break out view.h from labwc.h
IMHO it encourages better design (by making dependencies more obvious)
to have source file/header file pairs like view.c/view.h, rather than a
monolithic header like labwc.h with everything in it.

I don't think we need to break up all of labwc.h at once, but maybe we
can start pulling it apart bit by bit as it's convenient.

Also:

- Move "struct border" to ssd.h so that view.h can use it without pulling
  in all of labwc.h.
- Add a missing required #include within scaled_font_buffer.h (forward
  declaration of "struct font" is not enough).
2022-11-21 21:42:37 +00:00
John Lindgren
9021020f6e interactive: Refactor natural_geometry/tiled state handling
Currently, snapping to a screen edge and then snapping to maximize
results in both the natural_geometry and tiled state of the view
getting messed up. After unmaximize, the view ends up in a weird
state (tiled location but natural/untiled size).

There are also a couple of sketchy things going on in the code:

- interactive_begin() pokes its own values into view->natural_geometry
  to force view_maximize() to set a particular geometry.

- interactive_end() "fixes" view->natural_geometry after calling
  view_maximize() to save the original geometry from the start of the
  interactive move/resize.

To fix all this:

- Adjust/expand the API of view.c so that the interactive.c can
  avoid this "back door" of overwriting view->natural_geometry
  directly.

- Save the natural geometry and the tiled state of the view in
  interactive_begin() when starting to move the view.  When done,
  interactive_end() will update the tiled state if appropriate but
  *not* overwrite the natural geometry.
2022-11-20 20:45:50 +00:00
bi4k8
2b753a98b8 Support smooth scroll and horizontal scroll
note that this changes Scroll mousebinds from taking a "button"
attribute to taking a "direction" attribute
2022-11-15 21:57:36 +00:00
John Lindgren
3b55b31070 keyboard: Implement key repeat for keybindings
It seems that every Wayland client is expected to implement its own
key-repeat logic, rather than doing it server-side as in X11.  This
means that labwc also has to implement its own key-repeat logic for
compositor keybindings.

This is a very simplistic timer-based implementation.  It doesn't
attempt to synthesize accurate timestamps, and may lag depending
on system load, but it appears to get the job done.

v2: Use server->wl_event_loop
v3: Comments and formatting
2022-11-02 21:52:33 +00: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
Johan Malm
f2277c37c3 keyboard: put modifier/key listeners in keyboard struct
...so that it can be determined what wlr_keyboard events come from.

This is required to manage virtual keyboards alongside the keyboard_group
of physical keyboards.
2022-09-27 17:31:00 +01:00
Joshua Ashton
76d5fb1dda seat: implement virtual keyboard protocol 2022-09-27 17:31:00 +01:00
Joshua Ashton
4b8d0ba4b2 seat: implement virtual pointer protocol 2022-09-27 17:31:00 +01:00
John Lindgren
7233495c3a output: Call do_output_layout_change() at end of new_output_notify().
This fixes an issue with the wlr_output_cursor not being properly
initialized on new outputs, because wlr_output_layout.events.change
is triggered too soon, before the wlr_output_cursor exists.
2022-09-21 07:33:00 +02: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
Consolatis
f491942858 cursor: Move cursor specific function definitions into cursor.h 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
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
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
Johan Malm
62e9bb7236
Merge pull request #523 from jlindgren90/unmanaged-cursor-focus
cursor: Update focus when unmanaged surfaces are mapped/unmapped
2022-09-09 15:48:14 +01: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
a0afd443f5 src/xwayland.c: Keep view->surface in sync 2022-09-06 22:03:17 +02:00
John Lindgren
7c6c018f43 cursor: Fix out-of-surface movement for unmanaged surfaces 2022-09-02 05:12:34 +02:00
Consolatis
2550c984f8 Move OSD handler for view destruction to osd.c 2022-08-28 20:40:49 +02:00
Consolatis
ca3c83aafc src/osd.c: Integrate preview outline into OSD state 2022-08-28 20:40:44 +02:00
Consolatis
15a5b710db alt-tab preview: restore functionality after move to scene-graph 2022-08-28 20:40:36 +02:00
Consolatis
296e58079f Prepare OSD for reimplementation of the preview feature 2022-08-28 20:40:29 +02:00
John Lindgren
b7c4ba825a view/ssd: Refactor and fix visual indication for active windows
Partially fixes #494.

Co-Authored-by: Consolatis
2022-08-27 06:58:20 +01:00
Consolatis
36b2a93a69 Disconnect view from destroying output
Fixes #497

Reported-by @Flrian
2022-08-24 20:24:19 +01:00
Consolatis
b39020213a src/osd.c: Add preview outlines 2022-08-20 22:40:31 +01:00
Johan Malm
52d1e32b59 view: view_move() s/double/int/ for x and y 2022-08-18 19:50:25 +01: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
5d0faa2333 xwayland: Process unmanaged client configure requests more quickly
This is a similar fix to 065c37d3f5 but for unmanaged windows.  The issue
could be seen for example when moving the undocked Search Tool window in
Audacious.  For unmanaged windows, we don't track any pending move/resizes,
so just process all client configure requests immediately.
2022-07-23 20:37:59 +02:00
Consolatis
819404c43b xwayland: (Re)set seat when xwayland is ready
For some reason wlroots will reset the seat assigned to xwayland
to NULL whenever Xwayland terminates. This patch restores the seat
whenever Xwayland is ready again.

Fixes #166
Fixes #444

Thanks @droc12345 for figuring out the actual issue.
2022-07-21 03:57:42 +02:00
John Lindgren
065c37d3f5 xwayland: Process move-only client configure requests more quickly
For a move-only client configure request, treat it similarly to
view_move() by updating the scene-graph immediately, rather than waiting
for handle_commit().  Move-and-resize requests are handled the same as
before.

This (mostly?) fixes the glitchiness that was noticeable when dragging
an undecorated XWayland window (e.g. Audacious in Winamp mode).

Also:

- Reduce some code duplication in handle_request_configure() by
  simply calling configure(), as suggested by @johanmalm in #428.
- Factor out common logic after a move and/or resize into view_moved().
2022-07-18 22:06:12 +01:00
John Lindgren
80792d446f (Partly) fix handling of client-initiated configure requests
- Add missing call to wlr_scene_node_set_position() in
  unmanaged_handle_commit() -- this fixes moving unmanaged XWayland
  windows.

- Update view->pending_move_resize when we receive a configure request
  for a managed XWayland surface -- this fixes moving managed but
  undecorated XWayland windows.

- Also update view->pending_move_resize when we move a surface while a
  configure request is already pending -- this fixes a discrepancy
  between displayed and actual position for XWayland windows that try to
  set their own initial position, but then get overridden by labwc's
  positioning.

Moving undecorated XWayland windows is still really glitchy -- it appears
that an XWayland window gets sent incorrect mouse motion coordinates when
there is a pending configure request moving the window itself.
2022-07-03 12:59:36 +01:00
Consolatis
5585977f72 Rename unmaximized_geometry to natural_geometry 2022-07-02 16:21:32 +01:00
Consolatis
3a4b55886d src/view.c: Convert SnapToEdge to use view_apply_xxx_geometry framework 2022-07-02 12:43:23 +01:00
Consolatis
f4aa6118e9 src/layers.c: Adjust views based on usable_area changes 2022-06-30 20:41:54 +01:00
Consus
ca56357b5f workspaces: Allow switching/sending to the last used workspace
Actions GoToDesktop and SendToDesktop now support the new direction
called "last" that corresponds to the last used workspace (see Openbox
help[1] for reference).

[1]: http://openbox.org/wiki/Help:Actions#GoToDesktop
2022-06-18 18:34:58 +02:00
Joshua Ashton
505b1edb98 Allow leasing desktop displays
Apps such as Gamescope eventually want to offer a DRM lease option to use planes and handle all of getting to the screen themselves.

This implements logic to allow leasing of desktop displays
2022-06-16 20:42:17 +01:00
Consolatis
d557623c34 workspaces: Add workspaces.{c,h} 2022-06-15 22:26:21 +02:00
Consolatis
37ca5c28c1 include/labwc.h desktop_cycle_view: Clarify signature 2022-06-15 16:14:02 +01:00
Consolatis
a0d1003f28 src/keyboard.c: Make any_modifier_pressed() global 2022-06-15 16:14:02 +01:00
Johan Malm
9dcabbcfdd xwayland-unmanaged: prepare for handling more events
Sway handles some xwayland events that labwc still does not. This commit
just starts to rig up some handlers for these with log messages if they
are caught.

  - set_geometry: try to handle, but cannot find an application that uses
    it, so is untested.
  - request_activate - just log caught event
  - override_redirect - just log caught event
2022-06-05 09:45:58 +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
Johan Malm
81f216b6a2 xwayland: handle set_override_redirect events
This is needed to allow X11 applications to create surfaces as
non-override_redirect and then change them to override_redirect later

Without this gitk-menus and rofi are treated as xwayland-views with
associated server-side-decoration and forced positioning.
2022-05-03 20:45:30 +01:00
01micko
cbed8acf01 nls: add native language support
- adds labwc.pot and po files for de, es, it and sv
- added notes in NEWS.md and CONTRIBUTING.md
- addresses #269
- conditional upon `msgfmt` being installed
- can be disabled at build time
2022-05-02 10:33:42 +01:00
Consolatis
73930f7e0f view: Refactor view destruction some more 2022-04-23 08:59:06 +01:00
Joshua Ashton
d0b9680d00 view: Refactor view destruction
Consolidates all of the view destruction code for xwl + xdg into one function.

Fixes several notable bugs along the way:
  - Fixes a crash when alt tabbing when a selected view gets destroyed.
  - Fixes the OSD not updating to reflect a view has been destroyed.
2022-04-22 01:58:52 +02:00