Commit graph

77 commits

Author SHA1 Message Date
tokyo4j
e707e16130 layer: update pointer focus on popup destruction
Same as previous commit
2024-12-20 00:43:06 +09:00
tokyo4j
1765bf8cc2 layer-shell: stop sending configure events on surface creation
With wlroots 0.18, layer-shell's new_surface event is emitted on
zwlr_layer_shell_v1.get_layer_surface request rather than the first
commit. This change layer-shell clients like fuzzel to flicker on launch
because labwc was sending a configure event with fullscreen geometry due
to the absence of geometry hints on get_layer_surface requests.

This commit removes the code that updates the usable area from
new_surface handler, preventing unintended configure events with
fullscreen geometry.
2024-07-23 14:47:56 +02:00
Consolatis
3b2ab4a48e chase: move xdg destroy signal to toplevel / popup
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4345
2024-07-17 21:28:59 +01:00
John Lindgren
a98f2635ea xdg: support xdg-shell v3 with popup repositioning
See https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3514
which added support on the wlroots side.

We now re-run popup positioning (for both xdg-shell and layer-shell
popups) when the "reposition" event is received. This allows popups that
change size (such as qmpanel's applications menu) to be positioned
correctly.

xdg-shell v3 also gives the compositor some additional "hints" for popup
positioning (reactive, parent_size, and parent_configure_serial) which
are available but we don't make use of currently.
2024-07-01 20:16:31 +01:00
Consolatis
c80b55eb69 src/layer.c: deal with wlroots scene graph running out of memory
This fixes an issue detected by the static analyzer.

Rather than setting up the new popup as usual return
a wayland error to the client and destroy the popup.
2024-04-10 08:14:59 +02:00
Johan Malm
4fc6bce3ea layer: try to set keyboard focus on map
...for the following reasons:

1. We interpret 'normal input-focus semantics' for clients with on-demand
   keyboard interactivity to means that a surface receives input focus on
   cursor-button-press AND on map (the latter previously missing), just
   like a normal window would. In this regard, we do not differentiate
   between layers.

2. Most layer-surfaces set the keyboard interactivity at a similar time to
   their first (and normally only) map, so the absence of an explicit
   attempt to focus on map does not make a difference. However, for a
   long-running layer-shell client (such as lxqt-runner) which sets the
   interactivity on launch and then maps/unmaps many times throughout its
   lifetime, a specific focus-attempt is required on map to avoid the
   client itself having to keep resetting its interactivity to grab the
   keyboard on map.

3. Compositors like sway and river process focus (for clients with
   keyboard-interactivity)  in their map-handlers, so this makes for a
   common approach.

Fixes: #1653
2024-03-24 23:00:13 +01:00
Johan Malm
6990ff713b layer: do not focus on-demand clients in commit-handler
...because we should only try to focus them as part of normal input
handling semantics, for example when receiving a cursor-button-press.
2024-03-17 21:18:47 +00:00
Johan Malm
e67e8d6ed0 layer: do not change keyboard-focus in map-handler
If a client wants keyboard-interactivity this will be processed in the
commit handler.

Remove duplicate (and incorrect) requrests for focus.
2024-03-17 21:18:47 +00:00
Johan Malm
cb361fbb55 layer: change focus better on 'none' keyboard-interactivity request
...and on unmap.

Add `try_to_focus_next_layer_or_toplevel()` which does the following
(in order of precedence):

- Give focus to last added overlay/top layer-shell client with exclusive
  interactivity on the output nearest the pointer (normally the one where
  the users is currently working). The reason for not considering clients
  on all outputs is that giving focus to a client on another output may be
  confusing to the user.

- Give focus to topmost toplevel if one exists (this was done previously
  anyway).
2024-03-17 21:18:47 +00:00
Johan Malm
36058a63e2 layer: change logic for giving keyboard-interactivity
Use the following logic:
 - Exclusive: Grant regardless of layer (previously it was only given if
   in top or overlay layers) AND grant if in the same or higher layer
   (nearer overlay) compared with other clients with exclusive
   interactivity.
 - On-demand: Grant only if no other layer-shell client has exclusive
   keyboard interactivity. Previously it was treated the same as
   exclusive.
 - None: Unset focus if the commit associated with the 'none' came from
   the currently focused layer. Previously it was just unset regardless.
2024-03-17 21:18:47 +00:00
tokyo4j
b6d576922b IME: support IME popup 2024-03-14 20:11:03 +00:00
Consolatis
598ab9bcff src/layers.c: delay popup unconstrain until after first commit
Fixes: #1372
2024-02-25 11:49:03 +00:00
kyak
266690091f Remove headers not being used directly
Fix clangd warnings regarding headers not being used directly.
2023-12-22 20:19:39 +00:00
Consolatis
02aa000b0d src/layers.c: move popups from the background layer to the top layer
Previously we would only do that for the bottom layer.

Fixes #1293

Reported-by: @spl237
2023-12-07 11:11:47 +01:00
Consolatis
d59b1d0966 src/layers.c: calculate usable_area before positioning clients
This ensures that the usable area is completely calculated
before non exclusive-zone clients are positioned / resized.

Fixes #1285
Reported-by: @spl237
2023-12-06 22:04:07 +00:00
Christopher Snowhill
d7dc6e01b4 Chase wlroots: Unified mapping
Need to handle new unified mapping, where mapping is attached to the
wlr_surface objects instead of their parents. Also, most of them require
a new associate event for xsurface objects, their surface member will be
NULL before this event is received.

Refactored by jlindgren:
- add struct mappable
- unify map/unmap logic
2023-11-27 21:01:53 +00:00
Consolatis
b4fc72b460 Chase wlroots: Layershell version
Chases 9f793d350379872aeee56ea5c476adfeedc8bc88
layer-shell-v1: specify version in constructor
2023-11-27 21:01:53 +00:00
John Lindgren
a036d985d7 common: rename array-size.h to macros.h 2023-10-21 12:37:42 +01:00
Johan Malm
cf72d01f0c layers: remove redundant function argument 2023-10-16 17:10:09 -04:00
Johan Malm
8d3b15576b Add ARRAY_SIZE() macro 2023-09-19 22:03:59 +01:00
Johan Malm
4a531daef8 config: support <margin top="" bottom="" left="" right="" output="" /> 2023-06-26 06:04:07 +01: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
John Lindgren
ed31381eb8 output: Add output_update_usable_area/all_usable_areas()
Move the desktop_arrange_all_views() call outside layers_arrange() into
a new function, output_update_usable_area().  The new function currently
does exactly what layers_arrange() used to, but will be expanded in a
later commit.

Add output_update_all_usable_areas(), which is the same as calling
output_update_usable_area() for each output, but only calls
desktop_arrange_all_views() once.

Rebased and slightly modified by @Consolatis
2023-01-06 14:51:46 +01:00
Consolatis
0d8b459912 src/layers.c: destroy layer surface on output loss 2023-01-03 19:46:31 +00:00
Consolatis
a4c1c4815e src/layers.c: ensure layers_arrange() is only called with an output set 2023-01-03 19:46:31 +00:00
Consolatis
c241d89c7c src/layers.c: remove new_popup handler on node destruction 2023-01-03 19:46:31 +00:00
Consolatis
cd645318e7 src/layers.c: prevent crash with no outputs available 2023-01-03 19:46:31 +00:00
Consolatis
84b3df4ef2 src/layers.c: minor simplification 2023-01-01 18:15:37 +00:00
Johan Malm
15781a394c layer: s/struct wlr_box/output->usable_area/
...because Linux kernel style prefers `sizeof(*foo)` over
`sizeof(struct foo)`.
2022-12-29 23:18:08 +01:00
Johan Malm
7037ea4e8f layer: rename signal-handler functions to handle_*
...rather than *_notify to comply with naming convention agreed on in
CONTRIBUTING.md
2022-12-29 23:18:08 +01:00
Johan Malm
349a38e676 layer: get struct output from wlr_output user-data
...rather than output_from_wlr_output()
2022-12-29 23:18:08 +01:00
Johan Malm
73df50a1c8 layer: s/layers_above_shell/layers_above_views/ 2022-12-29 23:18:08 +01:00
Johan Malm
f01071e72c layer: remove wl_list layers[] from struct output
...and just use `struct wlr_scene_tree *layer_tree[]`
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
Johan Malm
e45e2c7e60 Fix coding style 2022-11-03 23:01:52 +01:00
Consolatis
89ad0b808f s/wl_list_insert(list.prev...)/wl_list_append(list...)/ 2022-10-05 19:50:36 +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
John Lindgren
b8c3fdaef9 seat: Listen for destroy signal of pressed.surface 2022-09-13 15:57:20 -04:00
John Lindgren
7c6c018f43 cursor: Fix out-of-surface movement for unmanaged surfaces 2022-09-02 05:12:34 +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
Consolatis
992089e901 src/layers.c: Prevent re-arranging views if usable_area didn't change 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
ef3dbbf29a Fix usable area calculation
Currently if a surface with exclusive zone is created prior to regular
surfaces, the size of the exclusize zone does not affect the usable area
for regular surfaces. This for example results in notifications being
rendered over the statusbar.

This commit fixes the issue by handling the surfaces with exclusive
zones first.

Fixes #420.
2022-06-28 21:38:42 +01:00
Consolatis
5f38d5ec55 src/layers.c: Update output for popup after forced move
Fixes #369
2022-06-17 06:08:06 +01:00
Consolatis
08518513cc Chase wlroots: scene_node.state is now inlined
Chases wlroots cb2dbc327e4d695c2a60a386e116a7dc20b29107
wlr_scene: Inline wlr_scene_node_state
2022-06-07 07:13:37 +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
Johan Malm
bb2a98645b layer: handle output_destroy.notify without crash
Steps to reproduce crash:
- run nested with two outputs (e.g. WLR_WL_OUTPUTS=2 ./build/labwc)
- start panel on one output (e.g. waybar)
- close that output

Backtrace pointed to output_destroy_notify() at ../src/layers.c:92

Reported-by: @Consolatis
2022-04-24 22:24:47 +01:00
Johan Malm
801a04a647 layers: always unmap on destroy
This sets seat->focused_layer to NULL if appropriate.
2022-03-07 20:54:22 +00:00
Johan Malm
852a6f02fa layers: fix layer_popup_tree implementation 2022-03-06 16:48:39 +00:00