Commit graph

560 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Johan Malm
8d3b15576b Add ARRAY_SIZE() macro 2023-09-19 22:03:59 +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
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
Consolatis
bb235337d8 window-rules: add ignoreFocusRequest property
This allows to reject focus requests from specific applications.
2023-09-10 13:31:15 +02: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
Consolatis
1703b4d6cc src/menu/menu.c: support keyboard driven selection
Fixes: #1058
Requested-by: @stefonarch
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
Consolatis
72936ccb3e src/ssd: fix tiling via keybind when maximized
The previous PR introduced an issue with tiling based actions
like SnapToEdge and SnapToRegion using outdated SSD margin
values when called via keybind while maximized. That resulted
in wrong offsets for the tiled windows.

This commit restores the functionality by forcing a re-calculation
of the SSD margin when changing the maximized state.

Thanks to @Flrian for reporting the issue via IRC.
2023-08-25 15:54:22 +02:00
Consolatis
f42f5f41c5 src/ssd: un-round corners on maximize 2023-08-25 11:34:52 +02:00
Consolatis
10f22a8f5b src/ssd: disable border on maximize
Fixes #1044
2023-08-25 11:34:52 +02:00
Johan Malm
206db43786 config: s/app_id/identifier/ for window-switcher field
...to be consistent with window rules.

The use of 'app_id' for window-switcher fields is hereby deprecated.
2023-08-20 20:49:27 +01:00
Johan Malm
e5a6c57a6e Move isfocusable() from desktop.c to view.c 2023-08-20 17:00:23 +01:00
Johan Malm
602d59a3b2 Add common/array.h with wl_array_len() 2023-08-20 13:08:45 +02:00
Johan Malm
7fde7ed2cc view: add for_each_view()
Helped-by: @Consolatis and @heroin-moose (by a significant amount)
2023-08-20 09:56:49 +01:00
Johan Malm
57b9efeb45 view: add view_array_append()
...to reduce code duplication.

The function populates an array with views which meet any set of critera
from:

  - current-workspace
  - no-always-on-top
  - no-skipWindowSwitcher (window-rule)

Make src/osd.c use this new interface. Note that always-on-top views are
still filtered out from the window-switcher and that desktop_cycle_view()
needs to be re-worked before always-on-top views can be opted in.
2023-08-20 09:56:49 +01:00
Consolatis
58b33fb0c9 Add window resize indicator 2023-08-19 18:37:16 +02:00
Consolatis
c8321e3264 src/xwayland.c: make size_hints globally accessible 2023-08-19 18:37:16 +02:00
Johan Malm
a89bcc3c60 cursor: prevent press on layer-subsurface from cancelling popup grab
Fixes: #1030
2023-08-15 20:25:58 +01:00
Johan Malm
2b9a6914a6 button: move button-png.c to button/
...so that all button code is in the same place.
2023-08-10 16:33:03 +01:00
Johan Malm
03bc2ada47 button: refactor xbm code
- Rename src/xbm/ to src/button/
- Combine xbm.c parse.c tokenize.c into button-xbm.c

No functional change
2023-08-10 16:33:03 +01:00
Consolatis
e39744f1d3 Add keepBorder <theme> option and enable it by default
With the new keepBorder option enabled, the
ToggleDecorations action now has 3 states:

- the first time only disables the titlebar
- the second time disables the whole SSD
- the third time enables the whole SSD again

When the keepBorder action is disabled, the old 2-state
behavior is restored, e.g. the ToggleDecorations action
only toggles between on and off.

Fixes #813
2023-08-10 16:09:20 +02:00
Johan Malm
a6a03daae3 Support png buttons
In the theme directory add close-{active,inactive}.png instead of
close.xbm - and similarly for iconify, menu and max.
2023-08-09 07:38:17 +01:00
Johan Malm
eca98a9b6e theme: simplify loading of xbm buttons
No functional change.
2023-08-09 07:38:17 +01:00
Consolatis
43db75f43c Restore SnapToEdge and MoveToEdge default keybinds
When adding the fallback keybinds we add them as string but expect them being an int.
This commit fixes that by using the same parsing routines that are used when parsing
user supplied configuration.

Fixes 1ee8715d57
actions: use enum for _ToEdge action
2023-08-06 10:37:36 +02:00
Johan Malm
2c14a5a406 view: make move_sub_views() use append_children method
...to share common code with minimize_sub_views()

Also, fix a bug in the move-to-back functions to move the window
hierarchy in the right order.

Helped-by: @Consolatis
2023-08-05 21:06:28 +02:00
Johan Malm
e991eae103 view: minimize parents/children together
Minimize the whole view-hierarchy from top to bottom regardless of which
one in the hierarchy requested the minimize. For example, if an 'About' or
'Open File' dialog is minimized, its toplevel is minimized also, and vice
versa.

For reference:
- This is consistent with in openbox, where child views (dialogs) can be
  minimized, but when doing so the parent is also minimized.
- In mutter these types of dialogs cannot be minimized (via client-menu or
  otherwise).
- In both openbox and mutter, when a toplevel window is minimized any open
  children are also minimized.
2023-08-05 15:25:00 +01:00
Consolatis
1ee8715d57 actions: use enum for _ToEdge actions
This also improves the config robustness as invalid edge names will now
prevent the action to be created in the first place and the user gets
notified about the issue.
2023-08-02 17:57:04 +01:00
Ph42oN
cb4afadd01 view: move MoveRelative code from action.c and restore natural geometry 2023-07-24 00:55:08 +02:00
Consolatis
40aba9e542 Add support for ext_idle_notify_v1..
..and combine both idle variants into a standalone manager
2023-07-09 08:26:33 +01:00
Consolatis
235a8ad9bc ToggleKeybinds per window 2023-07-06 06:02:28 +01:00
Consolatis
660127acb0 theme: add option osd.window-switcher.item.active.border.width
...and change default values for the variables below to keep the
window-switcher look the same as it was at the last release.

osd.window-switcher.padding = 4
osd.window-switcher.item.padding.y = 1
osd.window-switcher.item.active.border.width = 2
2023-07-05 21:31:30 +01:00
Johan Malm
55bf79c3fe theme: add option osd.window-switcher.padding
Fixes: issue #969
2023-07-05 21:31:30 +01:00
Consolatis
65b441a0ba config: validate keybind, mousebind and menu actions 2023-07-05 22:20:18 +02:00
Consolatis
665d31c1c7 src/action.c: add action_is_valid() 2023-07-05 22:20:18 +02:00
Consolatis
b05b92bb27 src/action.c: enforce action arg->key being set 2023-07-05 22:20:18 +02:00
John Lindgren
370cdc80e0 view: add client_request flag to view->impl->unmap()
This makes explicit the subtle behavioral difference between
xwayland_view_unmap() and handle_unmap().

With this change, the XDG and XWayland versions of handle_map/unmap()
are now identical, which will make further refactoring possible.
2023-07-01 23:07:39 +02:00