Commit graph

109 commits

Author SHA1 Message Date
Johan Malm
a89bcc3c60 cursor: prevent press on layer-subsurface from cancelling popup grab
Fixes: #1030
2023-08-15 20:25:58 +01:00
Johan Malm
a6f0fc9c62 window-rules: add skipTaskbar and skipWindowSwitcher 2023-05-22 20:37:49 +01:00
Johan Malm
5744bba849 xwayland: validate PID before activating unmanaged surface
Check that an unmanaged surface trying to grab focus is actually a child
of the topmost mapped view.
2023-04-21 15:59:36 +01:00
Johan Malm
d4288415c9 Support ext-session-lock protocol 2023-04-02 23:09:38 +01:00
John Lindgren
d7dd366bad view: Add view_move_to_front/back().
This avoids calling view->impl functions from cursor.c and desktop.c.

v2: Add an explicit recursion guard in cursor_update_focus().
2023-04-01 22:50:01 +02:00
Johan Malm
a6896e6978 desktop: move scene-tree node in move-to-back
view_minimize() does not need to call desktop_move_to_back() because the
stacking order is not changed and the windowSwitcher uses the scene-tree
nodes anyway.

Note: Movement of xwayland sub-views still relies on keeping server->views
in sync with z-order
2023-03-26 20:22:57 +01:00
Consolatis
a0b5a80ce1 Add FocusOutput action
Fixes #806

Suggested-by: @EysseW
Tested-by: @EysseW
2023-03-06 21:58:11 +00:00
Johan Malm
b8ec5a3e2e view: add move_to_front to struct view_impl
...to increase xwayland and xdg-shell encapsulation and to avoid passing a
function pointer as an argument in `xwayland_move_sub_views_to_front()`
which is inconsistent with labwc design patterns.

Rename view-impl.c to view-impl-common.c

Move function declarations that are common to view-implementations from
view.h into view-impl-common.h
2023-02-24 20:42:01 +00:00
John Lindgren
859eba1c6b desktop: Avoid centering views without initial geometry 2023-02-15 18:59:26 +00:00
Johan Malm
6f3043b08d layer: improve keyboard-interactivity
- Process layer-shell keyboard interactivity in the map and commit
  handlers only, rather than in layers_arrange(). This allows handling of
  the layer-surface that emitted the event rather than iterating over all
  surfaces in the output layer-tree, and therefore avoids having to guess
  which surface should have keyboard preference (and it might not be the
  last one added to the list which was the assumption previously).

- Prevent seat_focus_surface() from setting keyboard focus if a layer-shell
  surface with exclusive keyboard-interactivity has the focus.

- Set cursor_context type for layer-surfaces without node-descriptors
  in order to set keyboard focus correctly in cursor_button_press().

Tested satisfactorily with xfce4-panel and gtk-layer-demo.

Fixes #725 and #704
2023-01-29 14:31:49 +00:00
Consolatis
7e99d8ba08 SnapToRegion: Add overlay while moving and pressing a modifier 2023-01-11 18:52:24 +01:00
John Lindgren
45e0a4f48c xwayland: Add xwayland.h and move more things to xwayland.c
- Move xwayland-specific struct definitions to new xwayland.h header
- Move xwayland_move_sub_views_to_front() from desktop.c to xwayland.c
- Split out xwayland_server_init/finish() from server_init/finish()
- Rename new_xwayland_surface -> xwayland_new_surface and
  xwayland_surface_new() -> handle_new_surface() for consistency
- Add "mapped" argument to xwayland_unmanaged_create() so that we can
  make unmanaged_handle_map() private to xwayland-unmanaged.c
2023-01-07 22:22:55 -05:00
Johan Malm
86fa0c0a65 desktop.c: handle layer-subsurfaces in get_cursor_context()
...to allow these surfaces to receive pointer button events

Test by running `gtk-layer-demo --keyboard exclusive`, then open the
'set margin' dialog and try setting the margin with the pointer.
2022-12-29 23:18:08 +01:00
Johan Malm
9dbac2e06f layer: use scene-graph API more fully
...and thus simplify the usage of wlr_scene_node_at(). Specifically:

- desktop.c: in get_cursor_context() use node-description for
  layer-surfaces and layer-popups. This lays the foundations for a
  pointer-enter-event being sent when a new layer-surfaces appears under
  the pointer (even if the pointer doesn not move).

- layers.c:

  * Iterate over `struct wlr_scene_tree *layer_tree[]` rather than
    `struct wl_list layers[]` when arranging layers to avoid surfaces
    being out of sync with nodes

  * Set signal handlers after scene node creation to avoid configure
    race conditions

  * Handle scene-node destroy event rather than event of
    `struct wlr_layer_surface_v1`

  * Arrange layers on map and unmap

  * Handle client request for layer-change

Fixes issue #667
2022-12-29 23:18:08 +01:00
John Lindgren
b67eccc99a ssd: Move implementation details from ssd.h to ssd-internal.h
- Move private structs and functions to `ssd-internal.h`
- Add `ssd_button_get_type()` and `ssd_button_get_view()`
2022-11-27 15:09:45 +00:00
John Lindgren
1e8b0414fe ssd: Allocate struct ssd and struct ssd_hover_state separately
- Store a pointer to the `struct view` in `struct ssd`
- Pass `struct ssd *` instead of `struct view *` to ssd functions
- Add `ssd_get_margin()` convenience function
2022-11-27 06:48:41 +00:00
John Lindgren
957d9e5926 ssd: Cosmetic cleanups
- Minimize includes in `ssd.h`
- Avoid repetitive `view->ssd.margin` pattern
- Use `struct ssd *` or `const struct ssd *` rather than `struct view *`
  where convenient

Part of the motivation is to make it easier to separate `struct ssd`
from `struct view` in a future commit.
2022-11-26 21:24:46 +00:00
John Lindgren
4da37c6532 view: Move xdg_surface + xwayland_surface to derived structs
Add xdg_surface_from_view() + xwayland_surface_from_view() accessors
that assert() the view is of the expected type before returning.

Fix a real bug in xdg.c parent_of() that dereferenced
`view->xdg_surface->toplevel` without first checking `view->type`.

The goal of the new accessors is to catch similar bugs in future.
2022-11-25 22:21:17 +00:00
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
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
Consolatis
89ad0b808f s/wl_list_insert(list.prev...)/wl_list_append(list...)/ 2022-10-05 19:50:36 +01:00
Consolatis
92976f30d0 src/osd.c: Ensure destroying views are not used as preview anchors 2022-09-27 17:35:10 +01:00
Consolatis
c83c1beace src/osd.c: Prevent showing invalid windows
This might happen when closing the last
application "to tray" like VLC, Discord or Steam.

Reported-by: @Flrian
2022-09-27 17:35:10 +01:00
Johan Malm
d424514e24 Fix minor coding-style violations
...based on https://github.com/johanmalm/checkpatch.pl
2022-09-22 22:39:44 +01: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
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
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
John Lindgren
79d9cfcda6 desktop: Cycle first to topmost view if not already focused
The topmost view may not always be the focused view; for example,
when Audacious's main window is focused but the floating Search
Tool window remains on top of it.  In that case the floating window
(not the main window) should be the first view selected in the
window switcher.
2022-09-07 00:27:03 +02:00
Consolatis
15a5b710db alt-tab preview: restore functionality after move to scene-graph 2022-08-28 20:40:36 +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
f4aa6118e9 src/layers.c: Adjust views based on usable_area changes 2022-06-30 20:41:54 +01:00
Consolatis
8c5157a098 workspaces: Wire up workspaces 2022-06-15 22:26:21 +02: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
f1ada7e407 src/ssd: Use LAB_SSD_PART_CORNER_x for rounded corner backgrounds
This matches the behavior of the surrounding borders and will usually
cause resizing instead of triggering the button itself. This effect
is only really visible when using a border width settings of > 1.

Fixes #379
2022-06-09 22:04:35 +01:00
Consolatis
2ed7a10779 Chase wlroots: every scene_node parent is now a tree
Chases wlroots ccd0f85c2a36308e35b153c7f9653abac7659af3
wlr_scene: Only allow parenting on a wlr_scene_tree
2022-06-07 07:13:37 +01:00
Consolatis
3f65a2ff77 Chase wlroots: wlr_scene is now a tree node
Chases wlroots 9eb71146ae56c509ee33c7e8a662549592aad870
wlr_scene: Refactor wlr_scene (the root element) to encase a wlr_scene_tree
2022-06-07 07:13:37 +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
3699a2a7f6 desktop_node_and_view_at(): handle layer surfaces
+ Replace some tabs with spaces in include/node.h

Fixes: #278
2022-05-25 21:48:28 +01:00
Johan Malm
48c9e6fda0 osd: show alt-tab switcher center-aligned on all outputs
Fixes issue #283
2022-04-20 17:45:10 +01: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
8444ba4075 Convert menu to node_descriptors 2022-03-03 17:49:54 +00:00
Johan Malm
30298228e3 Rename node-descriptor.c to node.c
...in anticipation of adding helpers like node_view_from_node()
2022-03-02 21:07:04 +00:00
Consolatis
51e02e2afa src/desktop.c: Fix label error
Fixes "a label can only be part of a statement
and a declaration is not a statement".
2022-03-02 20:43:59 +00:00
Johan Malm
bd9ac3478a Remove src/damage.c 2022-03-01 20:54:52 +00:00
Johan Malm
cec0c5cee6 desktop.c: set *view_area right for layer-popup 2022-02-26 23:30:02 +00:00
Johan Malm
2891ff245e Add node-descriptor for wlr_scene_nodes
Support identification of wlr_scene_node role to enable simplification
of codebase including the avoidance of iterating over lists of
layer-surface, menuitems, and so on.

Use node-descriptors for xdg toplevels and popups
2022-02-26 22:35:51 +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