Commit graph

1755 commits

Author SHA1 Message Date
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
John Lindgren
cae96b0cce desktop: try harder to avoid focusing unfocusable views
Make desktop_focus_view() do nothing if the view is not focusable.
2023-09-29 18:04:32 +01:00
John Lindgren
7e72bf975f view/xwayland: avoid focusing views that don't want focus
XWayland views can self-declare that they don't want keyboard focus via
the ICCCM WM_HINTS property. Most of the logic is already in place to
avoid giving focus to such views (e.g. taskbars).

Add a couple of missing pieces to make this work:

- Hook up view_isfocusable() to look at WM_HINTS for XWayland views
- Adjust desktop_focus_topmost_mapped_view() to skip unfocusable views
2023-09-29 18:04:32 +01:00
Consolatis
d503370a77 Chase wlroots: Stop using wlr_xwayland_surface event data
Follow-up from b816c16701
Chase wlroots: Stop using wlr_xwayland_surface event data

Chases: 27edd024f83892f4af9c5084d47b73f26966aaf1
xwayland: pass NULL as event data
2023-09-29 05:04:45 +02:00
Consolatis
869ed069a5 Chase wlroots: Stop using wlr_drag_icon event data
Chases: af4181f3880dedcc7c717cfd54c047737bd95ee4
drag: use unified map logic
2023-09-29 05:04:45 +02:00
Consolatis
607c295527 src/view.c: guard xwayland include
Fixes: #1118
2023-09-28 20:34:21 -04:00
John Lindgren
4028a9482f seat: use focus_change event to update focused/active view
- Connect to wlr_seat_keyboard_state's focus_change event.
- Add view_from_wlr_surface(), which does what the name says.
- Use focus_change event along with view_from_wlr_surface() to update
  server->focused_view and set SSD states via view_set_activated().
- Eliminate desktop_focused_view() since server->focused_view should be
  reliably up-to-date now.
- Eliminate view_focus/defocus() since we can now just call
  seat_focus_surface() directly.
2023-09-28 22:52:30 +01:00
Johan Malm
bb5d272dc9 README.md: describe --force-fallback-for option 2023-09-28 22:46:39 +01:00
Johan Malm
d56cf92794 keyboard: fix release event bug after session lock
Do not withhold the release event associated with a keybind which executes
a keyboard-input-inhibiting client like swaylock.

In other words, make release-events of absorbed keys (those used up by a
keybind) de-register as such even though session-lock or input-inhibit is
in-force.

Fixes: issue #1114

Helped-by: @Consolatis
2023-09-28 21:58:47 +02:00
John Lindgren
e5aef03319 desktop: switch workspaces and optionally raise in desktop_focus_view()
Make desktop_focus_view() always switch to the workspace containing the
view being focused. It doesn't make much sense for an invisible view to
have the keyboard focus.

Also add an optional "raise" parameter to desktop_focus_view(). This
allows the common pattern of desktop_focus_view() + view_move_to_front()
to be reduced to a single function call.
2023-09-28 03:38:51 +02:00
Johan Malm
e77330bc3f keyboard: make keybind match stricter
...and avoid failing to send release events to clients for any keys that were
not absorbed by a keybind.

Do not match keybinds if there are other non-modifier keys (not part of any
defined bind) pressed at the same time.

Only store non-modifier keycodes in the key-state.c 'pressed' array.
This makes the call to wlr_seat_keyboard_notify_enter() in seat_focus()
consistent with the equivalent in sway (in seat_keyboard_notify_enter()).

Fixes: issue #1091
2023-09-27 21:34:28 +01:00
John Lindgren
3022985ba7 view: try to reduce confusion in focused_view tracking
Our current approach to handling the focused/active view is a bit
confusing. In particular, it's hard to be sure when server->focused_view
is or isn't in sync with the real wlroots keyboard focus.

Try to clean things up a bit. In particular:

- Add comments to server->focused_view and desktop_focused_view() to
  clarify that they should match, but it's not guaranteed.

- desktop_focused_view() now prints a warning if it detects that
  server->focused_view is out of sync. We should keep an eye out for
  this warning, and if we see it, try to figure out why it happened.

- For consistency, use only "focus/defocus" as the verbs in function
  names rather than "activate". This is a bit arbitrary, but the idea is
  that focus is the primary action while the active/inactive state is a
  side effect.

- view_focus/defocus() replace view_set_activated() and now update both
  focus and active/inactive state, to try to keep them in sync.

- Add comments at view_focus/defocus() to warn against calling them
  directly (we should generally call the desktop.c functions).

- desktop_focus_view(NULL) is now forbidden and is no longer handled as
  a special case to clear the focus. This was (at least to me) a
  surprising behavior and caused trouble when working on another change.

- To maintain existing behavior, desktop_focus_topmost_mapped_view() now
  explicitly clears the focus if there are no mapped views.

There should be no behavioral change here.
2023-09-27 17:13:08 +01:00
Johan Malm
003d1fd494 CONTRIBUTING.md: add wl_array_len() and ARRAY_SIZE() to API section 2023-09-26 21:15:25 +01:00
Johan Malm
69f250f8e0 CONTRIBUTING.md: updates notes on up-versioning 2023-09-26 21:15:25 +01:00