Commit graph

1794 commits

Author SHA1 Message Date
Consolatis
797e743c8a Move input handler init() and finish() functions to input/input.c 2023-10-30 21:14:04 +00:00
Consolatis
b359b1560c Move keyboard functions into input/keyboard.h 2023-10-30 21:14:04 +00:00
Consolatis
5e1562fae6 Make touch depend on cursor to prevent racing 2023-10-30 21:14:04 +00:00
Consolatis
8d0812d45a Move gesture handling out of cursor.c 2023-10-30 21:14:04 +00:00
Consolatis
67a8ae8561 Move input related source files into src/input/ 2023-10-30 21:14:04 +00:00
Consolatis
d2c403b84f src/common/spawn.c: Restore SIGPIPE default handler before exec
Fixes: #1209
Reported-by: @bdantas
2023-10-29 15:18:32 +01:00
John Lindgren
0430f6f818 view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.

Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).

Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.

Internally, I've taken the following approach:

- SSD code decorates the view as "maximized" (i.e. hiding borders) only
  if maximized in both directions.

- Layout code (interactive move/resize, tiling, etc.) generally treats
  the view as "maximized" (with the restrictions that entails) if
  maximized in either direction. For example, moving a vertically-
  maximized view first restores the natural geometry (this differs from
  Openbox, which instead allows the view to move only horizontally.)

v2: use enum view_axis for view->maximized
v3:
  - update docs
  - allow resizing if partly maximized
  - add TODOs & corrections noted by Consolatis
2023-10-28 22:46:49 +02:00
Consolatis
7b644b3b94 CONTRIBUTING.md: update list of package maintainers 2023-10-25 21:00:58 +02:00
Consolatis
2b81d09626 src/keyboard.c: always try to remove keys from the pressed set on release
Fixes: #1200
Reported-by: @kyak
2023-10-25 18:30:05 +02:00
John Lindgren
db591d1400 view: avoid raising same view over and over
Since view_move_to_front() now does more work than it used to
(updating XWayland server stacking order), try to avoid doing that
work unnecessarily.
2023-10-21 21:42:24 +01:00
John Lindgren
0ddf3c43ad xwayland: update stacking order in move_to_front/back()
Currently xwayland views are restacked on top of the XWayland server
stacking order when activated (i.e. focused). This is wrong because
focus/raise are independent concepts (though often occurring together).
The stacking order should be updated when the view is raised/lowered,
not when the view is focused.

Work is in progress elsewhere (draft PR) that will result in views more
often being raised without being focused. Without this fix, those views
don't get restacked properly, resulting in clicks "passing through" to
views underneath.
2023-10-21 21:42:24 +01:00
John Lindgren
921c30c1fa regions: perform rounding more carefully
Add percentages (x + width, y + height) before scaling so that there is
no gap between regions due to rounding variations
2023-10-21 20:49:04 +02:00
John Lindgren
47e80a488e view: commonize sub-view logic in view_move_to_front/back()
The logic was the same for xdg-shell and xwayland views, so move it from
the view->impl layer out to the view_move_to_front/back() functions.

view->impl->move_to_front/back() still exist for now, in case we want to
add xdg/xwayland-specific logic in future, but they now move only one
view and not sub-views.
2023-10-21 15:40:56 +01:00
John Lindgren
048d22d473 common: move MIN and MAX to common/macros.h 2023-10-21 12:37:42 +01:00
John Lindgren
5cb1d0e83f common: add and use CONNECT_SIGNAL macro
This makes the code a bit more readable IMHO (and forces us to be
consistent with event handler function names).

Adjust scripts/checkpatch.pl to not complain.
2023-10-21 12:37:42 +01:00
John Lindgren
a036d985d7 common: rename array-size.h to macros.h 2023-10-21 12:37:42 +01:00
Johan Malm
7f30de1134 xdg: add xdg_shell_init()
...to have the event-handler functions in the same translation unit as
the signal connector.

No functional change intended.
2023-10-20 18:14:11 -04:00
Consolatis
8d17ab2d60 scaled_scene_buffer: make dropping the buffer optional
In preparation to also use the scaled_scene_buffer for
theme components like rounded corner images and button
icons.

No functional change intended.
2023-10-19 21:48:57 +01:00
Johan Malm
7aa540b8ab docs/labwc-config.5.scd: describe <snapping> section 2023-10-19 21:32:32 +02:00
Axel Burri
ced4ae46ec doc: Add GrowToEdge, ShrinkToEdge actions 2023-10-19 19:09:42 +01:00
Axel Burri
299fb83fcc GrowToEdge, ShrinkToEdge: Implement actions 2023-10-19 19:09:42 +01:00
Axel Burri
81af658c1f doc: Adapt MoveToEdge action 2023-10-19 19:09:42 +01:00
Axel Burri
08cff6edcf MoveToEdge: Snap to window edge
Add configurable option (enabled by default) to snap to next window
edge instead of screen edge.
2023-10-19 19:09:42 +01:00
Axel Burri
1d72a08916 Add snap to window edge framework
Adds functions for calculation of distances between window edges, as
well as for window growing and shrinking.

All calculations are based on the "pending" geometry.

Ignored from snapping:

 - views that do not share the same output
 - minimized views
 - maximized views
 - views that are neither:
   - part of the current workspace
   - part of the always-on-top tree
2023-10-19 19:09:42 +01:00
Axel Burri
5176ac4f64 Move min/max view width/height to header
Preparatory for snap to window edge framework.
2023-10-19 19:09:42 +01:00
Axel Burri
0fd26c63fa Use output_usable_area_scaled() helper 2023-10-19 19:09:42 +01:00
Axel Burri
afe92654fd Add output_usable_area_scaled() helper
Preparatory for snap to window edge framework.
2023-10-19 19:09:42 +01:00
Johan Malm
5eb769d6d6 docs/environment: comment out variables
...to avoid users copying this file to ~/.config/labwc/ without editing
it and ending up with Swedish keyboard layout, etc.

Fixes: #1011
2023-10-19 00:59:15 +02:00
Johan Malm
30502af0e5 src/config/session.c: set _JAVA_AWT_WM_NONREPARENTING=1 2023-10-19 00:59:15 +02:00
John Lindgren
a1324c8cdc xwayland: center stored natural geometry for initially maximized views
For views that are initially maximized or fullscreen and have no
explicitly specified position, we need to center the stored natural
geometry, or the view may end up partially offscreen once unmaximized/
unfullscreened.
2023-10-18 19:49:53 +01:00
John Lindgren
45a4b3c047 xwayland: honor initially maximized requests via _NET_WM_STATE
X11 clients may request to be initially fullscreen or maximized by
setting hints in the _NET_WM_STATE property. For some reason, we are
currently only honoring fullscreen requests but not maximize.

The fixes issues with GTK apps (notably Firefox, but others as well)
not starting maximized.

There is a remaining issue that the window position may not be set
correctly after unmaximizing. This will be fixed in a follow-up commit.
2023-10-18 19:49:53 +01:00
John Lindgren
a047e4a4e3 xdg,xwayland: raise sub-view correctly relative to other sub-views
When a parent view has multiple sub-views (dialogs) visible, focusing
one sub-view ought to raise it above the others. This doesn't currently
happen -- focusing a sub-view raises the whole group of views together,
but has no effect on the relative stacking order between them.

This seems like a simple oversight in xdg/xwayland_view_move_to_front()
that's pretty easy to fix.

Add FIXMEs to deduplicate this logic in future.

Tested with HomeBank: the Import dialog pops up an additional Open File
dialog, which before this change appears behind the Import dialog (and
clicking on it does not raise it to the front). After this change, the
Open File dialog appears in front as expected.
2023-10-17 18:41:43 +02:00
John Lindgren
8e2ec3437b xwayland: assume views wanting decorations also want focus
Assume that Globally Active xwayland views do want focus if they want
window decorations (according to _MOTIF_WM_HINTS). This is a stop-gap
fix to ensure that various applications (mainly Java-based ones such as
IntelliJ IDEA) get focus normally and appear in the window switcher. It
would be better to match based on _NET_WM_WINDOW_TYPE instead, but that
property isn't currently available through wlroots API.

Fixes (partially): 7e72bf975f
("view/xwayland: avoid focusing views that don't want focus")
2023-10-16 17:13:52 -04:00
Johan Malm
cf72d01f0c layers: remove redundant function argument 2023-10-16 17:10:09 -04:00
John Lindgren
f6e3527767 desktop: allow re-focus between "globally active" views of the same PID
Commit 7e72bf975f changed behavior to not automatically focus xwayland
views using the "Globally Active" input model (WM_HINTS.inputs = false
but WM_TAKE_FOCUS listed in WM_PROTOCOLS).

One undesired side effect of this change is that when a dialog is
closed, the parent window is not re-focused if "Globally Active". This
issue is seen for example with JDownloader. It can be solved taking a
similar approach to what is done for unmanaged xwayland views: allow
automatic re-focus between views sharing the same PID.

Note that it's difficult to completely solve all of the focus issues
with Globally Active views without proper WM_TAKE_FOCUS support.
Implementing proper support is difficult since it requires wlroots
changes and would also mean waiting for a message round-trip in
desktop_focus_topmost_view().

Fixes (partially): 7e72bf975f
("view/xwayland: avoid focusing views that don't want focus")
2023-10-16 20:28:18 +01:00
John Lindgren
dd7f563a50 view: add view_wants_focus enum (NEVER/ALWAYS/OFFER) and function
This allows identifying XWayland views using the ICCCM "Globally Active"
input model. Later commits will improve handling of these views.

No functional change in this commit.
2023-10-16 20:28:18 +01:00
John Lindgren
8bb2e2123f seat: move session-lock check down to seat_focus() level
We were checking for a locked session in desktop_focus_view(), but there
are several other call sites of seat_focus_surface() which were missing
such a check. Any one of those could cause the lock screen to lose focus
(making the session impossible to unlock) or another surface to gain it
(breaching the session lock).

To fix the issue, make any call to seat_focus_surface() no-op when the
session is locked. Add a specific seat_focus_lock_surface() function
which is the only way to bypass the check and is called only from
session-lock.c.
2023-10-15 21:32:41 +01:00
John Lindgren
b053c9e375 view: only focus topmost view if unmapped view was focused
The unmap() handlers should only call desktop_focus_topmost_view() if
the unmapped view was the focused view. Unmapping a view that was not
focused should not change the focus.

I expect this rarely had any effect in practice; it would only matter in
a focus-follows-mouse config where some view other than the one on top
was focused. But it still seems better to fix.

Rather than repeating the logic in two places, create a small
view_impl_unmap() helper. Perhaps more common "unmap" logic could be
moved there in future.
2023-10-15 21:15:11 +01:00
Arnaudv6
8920e546db Add MoveToCursor action 2023-10-15 20:36:37 +01:00
John Lindgren
5c4038493f view: add view_is_related()
Allows removing xwayland-specific stuff from seat.c.

Based on a suggestion from @Consolatis.

v2: add comments
2023-10-15 18:38:47 +02:00
Consolatis
9b0031aec4 CI: limit workflow runs to 20 minutes
This prevents the FreeBSD runner to run for 6 hours in a bootloop.
2023-10-15 17:17:59 +02:00
Consolatis
4174553124 desktop.c: prevent switching workspaces for always-on-bottom windows
Fixes: #1170

Reported-by: @stefonarch
Reported-by: @tsujan
2023-10-15 01:05:45 +02:00
John Lindgren
50ceae5fb4 cursor: backport null check from wlroots-0.17 branch
Check that wlr_layer_surface_v1_from_wlr_surface() doesn't return NULL.
This may be unnecessary with wlroots 0.16 (not sure) but doesn't hurt
and reduces the delta to the wlroots-0.17 branch.
2023-10-14 20:01:51 +02:00
John Lindgren
259d6d0c71 seat: ignore focus change to unmanaged surface belonging to same PID
If an xwayland-unmanaged surface was focused belonging to the same
application as the focused view, allow the view to remain active. This
fixes an issue with menus immediately closing in some X11 apps (try
LibreOffice with SAL_USE_VCLPLUGIN=gen).

Fixes: 4028a9482f
("seat: use focus_change event to update focused/active view")
2023-10-14 13:38:19 -04:00
John Lindgren
125bab4796 output: fix invisible cursor after wlopm --off && wlopm --on
Use the same fix/workaround as in output_update_for_layout_change() to
make sure that the cursor is also visible after (re-)enabling an output
in handle_output_power_manager_set_mode().
2023-10-11 20:12:34 +02:00
Consolatis
3aa3edd356 keyboard: add missing Hyper_ and Meta_ syms to modifier detection
This was forgotten in 65bd32d625
Reported-by: @jonhiggs (thanks)

Also stop treating the synthetic layout change sym as modifier
but still prevent it from being added to the set of pressed keys.

Additionally slightly reformat the code.
2023-10-10 19:57:45 +01:00
Johan Malm
a105c8781a menu: use wl_list instead of array
...to make it easier to split menu.c into smaller chunks without
exposing nr_menus variable.
2023-10-10 06:17:37 +01:00
Johan Malm
b22722dafa menu: minor coding style tweaks 2023-10-10 06:13:55 +01:00
Johan Malm
c827c4c9e5 menu: split parse_xml() in readiness for pipemenus 2023-10-10 06:13:55 +01:00
John Lindgren
ecad76560e keyboard: add option to enable Num Lock automatically (default=enabled)
Co-authored-by: @Consolatis
2023-10-09 20:48:03 +01:00