Commit graph

1918 commits

Author SHA1 Message Date
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
John Lindgren
1f541be481 view: fix some inconsistencies in view_ functions
... especially regarding whether a (view *) parameter may be NULL. It's
confusing when some functions accept NULL and others don't, and could
trip someone up.

I'm partly to blame for the inconsistency, since (if memory serves) I
added view_is_tiled() and view_is_floating(), which do accept NULL.

In detail:

- Make view_is_tiled() and view_is_floating() no longer accept NULL.

- Rename view_isfocusable -> view_is_focusable for consistency with
  other view_is_ functions.

- Eliminate view_inhibits_keybinds() as it only existed to safely accept
  NULL and check a single flag, which can be checked directly.

- Add assert(view) to remaining public view_ functions to catch
  accidentally passing NULL.

- Inline inhibit_keybinds() into view_toggle_keybinds(). It is closely
  related and not called from anywhere else; inlining it allows
  eliminating an extra assert() which is now impossible.
2023-10-09 20:34:13 +01:00
Consolatis
d00f76e562 docs: update supported keybind and mousebind modifiers 2023-10-09 20:31:59 +01:00
Consolatis
3e2baa3f05 keyboard: prevent storing synthetic layout change key event
Before this patch, we were storing the key in our pressed set
and didn't remove it which in turn caused all further keybinds
to fail. The behavior was dependent on the exact flow of press
and release events and was most obvious when using
XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle

We now simply treat it as a modifier and thus do not store it
in the pressed set.

Fixes: #1129
2023-10-08 21:11:32 +02:00
Consolatis
65bd32d625 keybinds: add support for Meta and Hyper modifiers
The modifiers can be used in keybinds via M-key and H-key

Additionally adds support for:
- Mod1 (same as A)
- Mod3 (same as H)
- Mod4 (same as W)
- Mod5 (same as M)

This is compatible with the format used by Openbox.
(http://openbox.org/wiki/Help:Bindings#Syntax)

Mod2 (NumLock) and Caps are still not supported due to
their locking behavior but could theoretically be added.

Fixes: #1061
2023-10-08 21:11:32 +02:00
Moises Lima
47a80fc4f2 Refactor title height to use 'titlebar.height' from themerc 2023-10-06 22:19:16 +01:00
John Lindgren
0acdf041b8 keyboard: allow switching VT when locked 2023-10-05 20:14:19 +01:00
John Lindgren
00ce7a2b5e session-lock: reconfigure for output layout changes
Currently, if the output layout changes while the session is locked,
the lock surfaces may end up wrongly positioned, which looks bad and
may reveal some of the user's workspace underneath.

To prevent this, re-align the scene trees and reconfigure the lock
surfaces when the output layout changes.
2023-10-05 20:10:37 +01:00
John Lindgren
b7bd5a52e4 desktop: add commentary clarifying focus rules 2023-10-04 10:28:39 -04:00
John Lindgren
9be6bd8b1d Revert "desktop: try harder to avoid focusing unfocusable views"
Some X11 applications (MATLAB is known to be one) apparently still use
the outdated "globally active" input focus model, in which they declare
they don't want the window manager to give them input focus, but expect
to be able to take it explicitly themselves via XSetInputFocus().

Such applications are not a good fit for the Wayland world, and may have
issues even with remotely modern X11 window managers that prevent such
"focus stealing". Labwc certainly doesn't (and won't) allow it. However,
to avoid breaking such applications entirely, let's still allow the user
to give focus by clicking in the window.

For the sake of applications that legitimately don't want to be given
input focus (such as taskbars or other "panels"), we still don't give
focus to them automatically when another view is closed, and they aren't
shown in Alt-Tab.

This reverts commit cae96b0cce.
2023-10-04 10:28:39 -04:00
Johan Malm
db41b5eec0 s/::/./ 2023-10-04 06:06:52 +01:00
Johan Malm
c7c8b373b5 cursor: fix layer subsurface focus bug
...by simply not focusing layer-shell subsurfaces on button press.

This is a temporary patch to fix a regression.

Fixes: issue #1131
2023-10-03 00:03:35 +02:00
Consus
3e5b988d38 common: use fnmatch() for pattern matching
Drop-in POSIX-compliant function that has a nice glob(7) manual page for
reference.
2023-10-01 14:17:29 +01:00
Consus
e864419194 workspaces: allow referencing the current workspace
This value allows a user to reference the currently visible workspace.
2023-10-01 14:17:29 +01:00
Consus
22e3be40e5 action: add If and ForEach actions
Add If and ForEach actions as described in OpenBox specification.

Limitations:

- If and ForEach cannot contain nested If and ForEach.
2023-10-01 14:17:29 +01:00
Consus
12f6a8975a Unbreak match_glob
Since bool is not a C89 type, include <stdbool.h> in match.h.
2023-10-01 14:17:29 +01:00
Consus
abb7c03c75 view: introduce view_matches_query()
Add new function view_matches_query() that will be required by If and
ForEach actions in the future.
2023-10-01 14:17:29 +01:00
Consus
8988194785 action: Simplify the code
Replace action_str_from_arg() and action_get_first_arg() with
action_get_str().

Two reasons:

- This optimization reduces neither LOC nor amount of work done during
  the arguments processing, but requires two additional functions.

- Logging only the first argument of an action creates an illusion that
  only one argument was given. Instead of confusing the user just log
  the fact that the action is being handled.
2023-10-01 14:17:29 +01:00
Consus
ccca62e4bc action: Reduce code duplication
Introduce function action_get_arg() and a set of thin wrappers around
it. This function is responsible for finding the argument and checking
it's type, while the wrappers only to do the necessary type casting.
2023-10-01 14:17:29 +01:00
Johan Malm
2e07bc754e README.md: update section 1.4 too 2023-10-01 08:00:25 +01:00
Johan Malm
8780202af8 README.md: tone down no-frills statement
Features such as icons, gradients and drop-shadows were declined in the
early phases of the project to focus on designing the fundamental building
blocks well without pressure to implement additional features which may
have compromised good design decisions.

As a core team we are not against these features per se other than when
they sacrifice the ability to run well on low spec hardware, or
disproportionately increase code complexity and long term maintenance
burden.
2023-09-30 22:26:38 +01:00
Johan Malm
942b4e7e4b README.md: describe --wrap-mode=nodownload
Fixes: issue #1063
2023-09-30 22:26:38 +01:00
Johan Malm
c9e96c86dd README.md: specify librsvg version and that it is optional 2023-09-30 22:26:38 +01:00
John Lindgren
1c785d74c1 xwayland: do not set xsurface->data for unmanaged surface
xsurface->data is presumed to be a (struct view *) if set, so it must be
left NULL for an unmanaged surface. Otherwise view_from_wlr_surface()
may return a (struct xwayland_unmanaged *) where a (struct view *) was
expected, leading to a crash.

valgrind backtrace:

    Invalid read of size 1
      at 0x48F8FFC: wlr_scene_node_set_enabled (wlr_scene.c:903)
      by 0x124C9F: ssd_set_active (ssd.c:323)
      by 0x124C9F: ssd_set_active (ssd.c:318)
      by 0x124C9F: view_set_activated (view.c:215)
      by 0x118851: focus_change_notify (seat.c:353)
      by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
      by 0x48FC8F2: wlr_seat_keyboard_enter (wlr_seat_keyboard.c:298)
      by 0x119E60: seat_focus.lto_priv.0 (seat.c:473)
      by 0x1248FD: seat_focus_surface (seat.c:491)
      by 0x1248FD: unmanaged_handle_map (xwayland-unmanaged.c:51)
      by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
      by 0x487E01D: wl_signal_emit_mutable (wayland-server.c:2241)
      by 0x490FC91: surface_commit_state (wlr_compositor.c:499)
      by 0x56A24F5: ffi_call_unix64 (unix64.S:104)
      by 0x569EF5D: ffi_call_int.lto_priv.0 (ffi64.c:673)
    Address 0xa0e15ff30788b68 is not stack'd, malloc'd or (recently) free'd

Fixes: 4028a9482f
("seat: use focus_change event to update focused/active view")
2023-09-30 20:32:26 +02:00
Johan Malm
2e8820cf6a key-state: rename function for consistency
...with the equivalent function that returns the number of pressed keys.

s/key_state_nr_keys/key_state_nr_bound_keys/
2023-09-30 15:43:59 +02:00
Ikko Eltociear Ashimine
3f0cf9c3a8 Fix typo in output.c
specifc -> specific
2023-09-30 08:58:54 +01:00
John Lindgren
4b887657bd xwayland: add explanatory comment on WM_HINTS.input 2023-09-29 18:04:32 +01:00