Commit graph

1723 commits

Author SHA1 Message Date
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
Standreas
08d14bea58 Add default menu descriptions to labwc-menu.5.scd 2023-09-26 21:08:35 +01:00
John Lindgren
ce36cbac2d view: account for base size in resize indicator
For views with a non-pixel size increment (e.g. X11 terminals), it's
helpful to subtract the base size of the window (typically including
menu bar, scrollbars, etc.) before computing the number of size
increments (e.g. cells/characters). This way, the displayed size will
exactly match the terminal grid (e.g. 80x25 or whatever).

wlr_box isn't really the best fit for size hints, so let's define a
struct view_size_hints and a nice view_get_size_hints() function,
wrapping view->impl->get_size_hints().

This also seems like a great opportunity to make view_adjust_size()
window-system-agnostic and eliminate xwayland_apply_size_hints().
2023-09-26 01:24:02 -04:00
Johan Malm
48e0b3f6a6 build: bump version to 0.6.5 2023-09-23 16:54:34 +01:00
Johan Malm
d54b95a3d4 NEWS.md: add notes for 0.6.5 2023-09-23 16:49:54 +01:00
Johan Malm
c293886911 NEWS.md: use latest keep-a-changelogs link format
...which points to https://github.com/.../compare/v0.0.1...v0.0.2
rather than a 'release' page.
2023-09-23 16:49:54 +01:00
Johan Malm
ccc3d14658 common/buf.c: do not use memcpy for overlapping regions 2023-09-23 16:28:23 +01:00
Johan Malm
881d788bee action: do not expand env vars in Exec action
...<command> argument (but still resolve tilde).

This makes it easier to write sh -c '' constructs without turning labwc
into a shell parser in order to expand environment variables, whilst
respecting single quotes and escaped characters as well as ignoring
subshells syntax like $(foo) and backticks.

Also, fix bug where buffer length+alloc get out-of-sync
2023-09-23 14:52:59 +01:00
Johan Malm
c6c1f8e04b buf: do not expand $() in buf_expand_shell_variables() 2023-09-23 14:52:59 +01:00
Consolatis
e8ec8ea7ff src/ssd: use view->ssd_titlebar_hidden for ssd_thickness calculations
Before this patch we were using the internal .enabled flag of the titlebar
tree node. This failed due to ssd_thickness() not having view->ssd assigned
when initially called. Instead of assigning view->ssd within ssd_create()
we just always use the view boolean flag directly. This fixes an issue
where a border-only view that has been snapped to an edge or region would
have a gap in the size of the titlebar on top after a Reconfigure.

Fixes #1083
2023-09-21 22:21:19 +01:00
Consolatis
e5d459aa0c Ensure xdg and xwayland string_prop() handlers deal with destroying views
When a view is destroyed (including override_redirect in the xwayland
case), the view_destroy() handler is called which checks for a currently
open A-Tab window switcher and causes an update there to remove the
destroying view from the list. Before view_destroy() is called, both
xwayland and xdg handlers reset the xdg_surface / xwayland_surface.

The window switcher update then creates a list of all windows which do
not have the 'skipWindowSwitcher' window rule property set. If there is
at least one 'matchOnce' window rule configured, this also tries to get
string properties of the destroying view which already had their
xdg_surface / xwayland_surface reset and thus run into an assert.

This patch fixes that so that the string_prop() handlers always return
an empty string in those cases rather than running into the assert.

For a more in-depth analyses and alternative solutions see the linked
issue.

Fixes #1082
2023-09-21 22:16:11 +01:00
Standreas
44e65e7930 Added note for localization support to menu.xml
Maybe mention it in the man page too?
2023-09-20 19:08:46 +02:00
Johan Malm
8d3b15576b Add ARRAY_SIZE() macro 2023-09-19 22:03:59 +01:00
Standreas
ae676c1607 Fix typo in labwc-theme.5.scd 2023-09-19 22:06:12 +02:00
Johan Malm
715405fe29 build: make svg buttons optional
Add -Dsvg=disabled to your meson setup/configure command to disable svg
buttons even if the correct version of librsvg is available.

Note that regardless of this patch and the value of the 'svg' variable,
the build will gracefully fall back to not using librsvg if the correct
version is not available.

Helped-by: @01micko
2023-09-17 19:26:41 +01:00
Johan Malm
c598cf7f11 button-png.c: s/png_load/button_png_load/ 2023-09-17 19:26:41 +01:00
Johan Malm
c62df26c2a Support svg buttons
In the theme directory add close-{active,inactive}.svg instead of
close.xbm - and similarly for iconify, menu and max.
2023-09-17 19:26:41 +01:00
Johan Malm
a386133068 common/file-helpers.c: share file_exists() to reduce duplication 2023-09-17 19:26:41 +01:00
Johan Malm
a8951c4b75 button/common.c: share button_filename() to reduce duplication 2023-09-17 19:26:41 +01:00
redtide
143714f1c9 src/common/parse-bool.c: support on/off boolean values 2023-09-13 05:27:27 +01:00
Consolatis
bd6efe4849
Merge pull request #1072 from Consolatis/feature/keycode_binds
Keybinds: keyboard layout agnostic keybinds
2023-09-11 22:00:39 +02:00
Consolatis
c1c624daf0 keybinds: add optional layoutDependent argument
This allows to define keybinds as layout dependent. E.g. keybinds
only trigger if the configured key exists in the currently active
keyboard layout. The keybind will also only trigger on the physical
key that is mapped to the configured key in the active layout.

By default the new argument is false which means all keybinds by
default are layout agnostic. This optional argument can be used
to restore the earlier default behavior of having keys layout
dependent.
2023-09-11 15:41:19 +02:00
Consolatis
6b80751010 keybinds: prefer keycodes over keysyms
This allows keyboard layout agnostic keybinds
in a multi layout configuration.

Fixes: #1069
2023-09-11 15:39:34 +02:00
Standreas
8a67476ab3 docs: clarify keyboard modifiers can be used for mousebinds
Fixes: #1075
2023-09-10 19:36:24 +02:00
Consolatis
97ac960fee src/cursor: ensure interactive move/resize ends correctly for CSD clients
Before this patch, when moving a CSD client below a layershell surface -
like a panel that was configured with either the "top" or "overlay"
layers - we'd only send a matching release button event to the client but
not actually end the interactive move operation. That caused the drag to
continue even though the user already released the mouse button.

In comparison, SSD clients were not suffering from the same issue because
the initial mouse "down" event was not attached to any client surface and
thus it would not take the first early return because there was no surface
attached to the release event.

This patch fixes the issue by reordering the conditions where we return
early. It also ensures that when we finish the move, we still send the
release event to CSD clients.

Fixes: #1053
Reported-by: @DynamoFox (thanks)
2023-09-10 16:49:54 +01:00
Consolatis
bb235337d8 window-rules: add ignoreFocusRequest property
This allows to reject focus requests from specific applications.
2023-09-10 13:31:15 +02:00
Consolatis
272222e3c9 keybinds: allow non-english based keybinds 2023-09-07 23:24:36 +01:00
tokyo4j
19ffbae320 config: replace enums with int to handle negative values
This commit also fixes that an invalid value in <accelProfile> is interpreted as "flat"
2023-09-07 22:55:50 +01:00
tokyo4j
3c3656f74e config: support <tapAndDrag> and <dragLock> 2023-09-07 22:55:50 +01:00
tokyo4j
4268991105 CodeStyle: double indent in if statement 2023-09-07 22:55:50 +01:00
Consolatis
1703b4d6cc src/menu/menu.c: support keyboard driven selection
Fixes: #1058
Requested-by: @stefonarch
2023-09-05 19:57:14 +01:00
Consolatis
a9ab8ebdaf src/menu/menu.c: convert to wl_list_append() 2023-09-05 19:57:14 +01:00
bi4k8
a49e12e112 touch: store initial coordinate adjustments
this avoids touch offsets jumping when a touch point moves off of a surface
2023-08-27 23:13:24 +02:00