Commit graph

54 commits

Author SHA1 Message Date
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
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
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
235a8ad9bc ToggleKeybinds per window 2023-07-06 06:02:28 +01: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
Ph42oN
ea623daaee action: add ResizeRelative 2023-06-27 20:59:33 +02:00
Johan Malm
16bf67a8cd view: add minimize method
...and call wlr_xwayland_surface_set_minimized() for xwayland surfaces on
(un)minimize.

Fixes: #958
2023-06-25 16:25:17 +01:00
Johan Malm
15cd093f2e action: add ToggleAlwaysOnBottom 2023-05-22 20:37:49 +01:00
Tomi Ollila
7ad5200f2e includes: identifier consistency in include guards
Made all header files to have LABWC_ prefix in include guard identifers.

Converted from __LABWC_ in 35 include/ files.
Converted from __LAB_ in 5 include/ files.
Added LABWC prefix to 3 include/ files.
Added include guards to 3 include/ files.

The double underscores were removed since according to C standard
those "are always reserved for any use".
2023-05-13 22:29:21 +01:00
John Lindgren
d7dd366bad view: Add view_move_to_front/back().
This avoids calling view->impl functions from cursor.c and desktop.c.

v2: Add an explicit recursion guard in cursor_update_focus().
2023-04-01 22:50:01 +02:00
Johan Malm
a6896e6978 desktop: move scene-tree node in move-to-back
view_minimize() does not need to call desktop_move_to_back() because the
stacking order is not changed and the windowSwitcher uses the scene-tree
nodes anyway.

Note: Movement of xwayland sub-views still relies on keeping server->views
in sync with z-order
2023-03-26 20:22:57 +01:00
Consolatis
35e71ada82 Decorations: respect earlier client side decoration negotion result
Before this patch, it was impossible to differentiate between negotiations
resulting in client side decorations and no negotiations at all.

By adding an enum we are now able to differentiate between the two states.
2023-03-25 07:24:40 +00:00
John Lindgren
ea09fc3850 xdg: Detect pending configure request timeouts 2023-03-05 08:46:55 +00:00
John Lindgren
9f00087a82 view: Comment updates 2023-03-05 08:44:03 +00:00
John Lindgren
331f62f662 view: Add view_set_output() 2023-03-05 08:44:03 +00:00
John Lindgren
55c6280322 view: Add documentation for view->output 2023-03-05 08:44:03 +00:00
John Lindgren
60fbb44f6a view: Eliminate view_output() and use view->output directly 2023-03-05 08:44:03 +00:00
John Lindgren
a9cbbe1e41 view: Set view->output prior to calling view_center() 2023-03-05 08:44:03 +00:00
John Lindgren
bdbbbb2e62 xdg: Set view->output prior to view_set_fullscreen() 2023-03-05 08:44:03 +00:00
John Lindgren
64bea4f511 view: Attempt to keep non-floating views on the same output
- Make view_discover_output() static
- Call view_discover_output() only for floating views
- Deprecate view_output(); make it use view->output when possible
2023-03-05 08:44:03 +00:00
Johan Malm
ecbe699f94 view: make request_activate listener xwayland only 2023-02-24 22:56:00 +01:00
Johan Malm
b8ec5a3e2e view: add move_to_front to struct view_impl
...to increase xwayland and xdg-shell encapsulation and to avoid passing a
function pointer as an argument in `xwayland_move_sub_views_to_front()`
which is inconsistent with labwc design patterns.

Rename view-impl.c to view-impl-common.c

Move function declarations that are common to view-implementations from
view.h into view-impl-common.h
2023-02-24 20:42:01 +00:00
John Lindgren
74bc16910a xdg: Use view_center() for parent-relative centering
- Add optional struct wlr_box* ref argument to view_center()
- Perform margin adjustment within view_center()
- Expose view_output() to fetch parent's output
2023-02-20 11:50:12 -05:00
John Lindgren
5062c5bea3 view: Add optional output parameter to view_center()
Allows centering the view on a specific output without the workaround of
overwriting view->current.x/y.
2023-02-20 11:50:12 -05:00
John Lindgren
49c9466039 view: Tidy up view->output/view->fullscreen redundancy
A fullscreen view currently has its output specified twice by:
  - struct output *output
  - struct wlr_output *fullscreen

view->fullscreen may also become a dangling pointer if the output is
disconnected, because view_on_output_destroy() clears view->output but
not view->fullscreen.

To eliminate the redundancy and the dangling pointer, let's change
view->fullscreen to a Boolean and rely on view->output to specify the
output.

Along the way, change a few related usages of struct wlr_output to
struct output as well.

No functional change intended.

v2: Don't allow entering fullscreen on disabled output (makes
    conditions for entering/leaving fullscreen symmetric)
v3: Use output_is_usable() helper
2023-02-17 06:59:39 -05:00
John Lindgren
d2fae39fe3 view: Add view_evacuate_region() helper
v2: Modify asserts as suggested by Consolatis
2023-02-17 04:47:15 +01:00
John Lindgren
0ca6c4c763 view: Unify view_move()/view_move_resize()
view->impl->move() is a specific case of view->impl->configure().
To reduce code duplication, we can use view->impl->configure() for
pure moves (without resize) as well.

xwayland's move() function also possibly contained a race condition
when there was a pending resize, as it used the current surface
width/height rather than the pending width/height. This is fixed.
2023-02-16 05:21:47 +01:00
Consolatis
aeb6aa0cd8 src/view.c: view_is_floating() add missing tiled_region_evacuate
Also
- remove static inline (e.g. trust the compiler to optimize)
- move from include/view.h to src/view.c
2023-02-11 13:15:49 +00:00
John Lindgren
a1b5e1939d xdg: Just call view_center() now that it uses pending width/height 2023-02-09 18:26:44 +01:00
John Lindgren
b75dbd5b38 view: Use wlr_box for current/pending geometry 2023-02-09 10:44:15 -05:00
John Lindgren
cfc3c93102 xdg: Eliminate redundant update_x/update_y flags
struct view's pending_move_resize.update_x/update_y flags appear to
be redundant, since we can easily determine whether x/y have been
update via a simple comparison in handle_commit().

The only corner case I can think of where this change might affect
behavior, is if xdg_toplevel_view_move() is called while a resize
is still pending (e.g. after xdg_toplevel_view_configure() but
before handle_commit()). This corner case will be addressed in the
following commit.
2023-02-08 22:22:10 +00:00
John Lindgren
09599861ac xwayland: Fix size issue when starting VLC fullscreen 2023-02-08 22:15:14 +00:00
Consolatis
27218cd2c9 src/view.c: make view_wlr_output() static
.. as there are no external consumers left.
2023-02-02 13:40:21 +01:00
Consolatis
14a0c83ae0 src/foreign.c: refactor 2023-02-01 17:47:34 +00:00
Consolatis
07ee56176d SnapToRegion: Allow for live config updates 2023-01-11 18:52:24 +01:00
Consolatis
4edd67de17 SnapToRegion: Evacuate tiled views from destroying outputs 2023-01-11 18:52:24 +01:00
Consolatis
9d3e309a22 SnapToRegion: Add view_snap_to_region() 2023-01-11 18:52:24 +01:00
John Lindgren
45e0a4f48c xwayland: Add xwayland.h and move more things to xwayland.c
- Move xwayland-specific struct definitions to new xwayland.h header
- Move xwayland_move_sub_views_to_front() from desktop.c to xwayland.c
- Split out xwayland_server_init/finish() from server_init/finish()
- Rename new_xwayland_surface -> xwayland_new_surface and
  xwayland_surface_new() -> handle_new_surface() for consistency
- Add "mapped" argument to xwayland_unmanaged_create() so that we can
  make unmanaged_handle_map() private to xwayland-unmanaged.c
2023-01-07 22:22:55 -05:00
Consolatis
e39fd341ec src/workspaces.c: prevent re-focus for always-on-top views
Before this patch a focused always-on-top view lost its keyboard
focus when switching workspaces. Now the view keeps its focus.
2022-12-29 18:58:25 +01:00
bi4k8
1b30edc778 don't set view->w and view->h when mapping xdg views
these should only be set on commit. doing so before then confuses
code that expects these fields to be in sync with the scene tree,
such as `handle_commit`.

these were only being set so that `view_center` could read them to
compute a centered position, so instead we can simply forward the
values directly to `view_compute_centered_position` and `view_move`.
2022-12-19 18:21:07 +01:00
John Lindgren
1e8b0414fe ssd: Allocate struct ssd and struct ssd_hover_state separately
- Store a pointer to the `struct view` in `struct ssd`
- Pass `struct ssd *` instead of `struct view *` to ssd functions
- Add `ssd_get_margin()` convenience function
2022-11-27 06:48:41 +00:00
John Lindgren
ac9228e7f8 view: Add view_reload_ssd()
Gather related logic from `reload_config_and_theme()` in `server.c` and
`ssd_reload()` in `ssd.c` into a new function, `view_reload_ssd()`.

Also drop the `view->mapped` check since we want to update any view that
has SSD nodes created, mapped or not.
2022-11-26 18:02:24 +00:00
John Lindgren
4da37c6532 view: Move xdg_surface + xwayland_surface to derived structs
Add xdg_surface_from_view() + xwayland_surface_from_view() accessors
that assert() the view is of the expected type before returning.

Fix a real bug in xdg.c parent_of() that dereferenced
`view->xdg_surface->toplevel` without first checking `view->type`.

The goal of the new accessors is to catch similar bugs in future.
2022-11-25 22:21:17 +00:00
Johan Malm
df7276345f view: create derived structs
...for XDG toplevels and XWayland views to only include applicable
wl_listeners for each type of view.
2022-11-25 14:47:53 +00:00
John Lindgren
56f8837ca6 view/ssd: Move ssd->enabled to view->ssd_enabled 2022-11-22 09:17:33 +01:00