Commit graph

409 commits

Author SHA1 Message Date
Johan Malm
7e338fc365 view: fix view_get_adjacent_output() bug
...when using more than two outputs.

Use the centre of the view's output as the reference coordinate when
seeking adjacent outputs.

Fixes: #1582
2024-03-02 21:23:01 +00:00
Andrew J. Hesford
6c87254146 view: cancel interactive resize when shading 2024-02-08 17:33:23 +00:00
Consolatis
382068e452 src/view.c: store outputs the view is visible on 2024-02-06 17:23:45 +01:00
Andrew J. Hesford
cf34e60240 edges: limit edge attraction and resistance...
...to edges actually encountered by motion during interactive moves and
resizes.

In addition, ignore edge resistance and attraction for minimized views.
2024-02-05 22:05:22 +00:00
Andrew J. Hesford
242b94bca9 view: respect rc.gap when moving to cursor
Fixes: #1494
2024-02-02 21:39:13 +01:00
Andrew J. Hesford
01af000cd1 view: better honor usable areas when changing outputs...
...in view_move_to_edge. If a view is fully within the usable area of
its original output, it should be fully within the usable area (if
possible) on its new output.
2024-01-30 21:12:46 +00:00
Andrew J. Hesford
e7e6d29237 edges, resistance, snap: unified resistance and snapping engine 2024-01-30 15:02:17 -05:00
Andrew J. Hesford
3162bbb3c2 xdg: add snapping.notifyClient option to control tiling events 2024-01-30 07:30:07 -05:00
Andrew J. Hesford
c1a2dd3e27 view, xdg: notify clients when tiling windows 2024-01-30 07:30:07 -05:00
Andrew J. Hesford
9ecd8c2b43 view: ensure midpoint is visible on layout change
Fixes: #1476.
2024-01-25 20:22:10 +01:00
Jens Peters
3cdeaecb4b view: do not resize fullscreen windows 2024-01-23 00:03:33 +01:00
Jens Peters
10d417258a view: fix early return condition 2024-01-22 22:27:08 +00:00
Jens Peters
b1d626fbfd view: add move_to_output() function 2024-01-22 22:27:08 +00:00
Jens Peters
982df84407 view: expose view_get_adjacent_output 2024-01-22 22:27:08 +00:00
Jens Peters
099929cf46 view: allow overriding of cursor placement policy 2024-01-22 22:27:08 +00:00
Jens Peters
8517254705 view: fix typo 2024-01-22 22:27:08 +00:00
Johan Malm
f73e9ded1c view: fix regression whereby cursor is not updated
...on view destruction because focus_change_notify() in seat.c changes
server->active_view so the logic introduced by 6c6e406 (which checks if
view =! active_view) is no longer right.

The glitches described in the commit below have not come back.
6c6e406507

Fixes #1393
2024-01-19 20:37:23 +00:00
Consolatis
e05bedb140 feat: add Shade/Unshade/ToggleShade actions
This builds on the work of @Consolatis in #1018.

Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
2024-01-15 21:37:36 +00:00
bi4k8
9d63c803d3 view: fix crash when a minimized fullscreen window closes
Do not call view methods after invalidating an invariant of the view
(view->scene_tree != NULL)
2024-01-11 20:56:47 +00:00
Andrew J. Hesford
313a80f6aa view: only constrain sizes for oversized views
...and ensure initial position is on the target display.
2024-01-08 20:12:55 -05:00
Johan Malm
c646c7bd1b view: constrain window size to that of usable area
...on first map (when application is started).

Fixes #1399
2024-01-08 22:08:27 +00:00
Andrew J. Hesford
c229f6edc0 view: try to honor original geometry with layout changes
Whenever the output layout changes, each view's original geometry will
be captured as last_layout_geometry (if it has not already been captured
by a previous layout change), which will remain valid unless the user
modifies the view's geometry (i.e., by tiling, maximizing, moving,
resizing or full-screening). On subsequent output layout changes, views
with valid last_layout_geometry will be back to their original position
if possible, or else to the closest possible output.
2024-01-06 19:04:11 +00:00
Ph42oN
1b5af86402 fix adaptive sync fullscreen 2024-01-06 15:37:18 +00:00
Andrew J. Hesford
b1c5e95c05 view: honor automatic placement when adjusting floating geometry
The view_adjust_floating_geometry function is called when un-maximizing
a window or changing the output layout to ensure that views are well
placed. Rather than always centering these views should they fall
offscren, use the automatic placement strategy if so configured.
2023-12-30 16:50:09 +00:00
Ph42oN
08045d7843 config: add adaptive sync fullscreen option 2023-12-30 15:46:35 +00:00
Andrew J. Hesford
52aafcc054 feat: automatic window placement
With automatic placement, new top-level windows will be placed to
minimize overlap with other windows already on screen.
2023-12-26 19:20:06 +00:00
Andrew J. Hesford
ef62d47ad1 feat: under-cursor window placement
With under-cursor placement, new top-level windows will be centered
under the cursor rather than centered on the active view.
2023-12-26 19:20:06 +00:00
Johan Malm
3a959cc74b s/focused_view/active_view/ 2023-12-19 20:34:07 +00:00
Andrew J. Hesford
e303281333 view: continue move-to-edge behavior to adjacent outputs 2023-12-09 08:50:32 +00:00
John Lindgren
83e67b32b6 xwayland: treat X11 panel views as if fixedPosition rule is set 2023-11-29 06:48:31 +00:00
Brandon Nason
bad8f334ea Add omnipresent flag for views 2023-11-28 21:41:30 +00:00
Christopher Snowhill
d7dc6e01b4 Chase wlroots: Unified mapping
Need to handle new unified mapping, where mapping is attached to the
wlr_surface objects instead of their parents. Also, most of them require
a new associate event for xsurface objects, their surface member will be
NULL before this event is received.

Refactored by jlindgren:
- add struct mappable
- unify map/unmap logic
2023-11-27 21:01:53 +00:00
John Lindgren
b5220a723e Chase wlroots: convert to try_from
Chases: 711a1a3ed42150fdbc716e80719d482006075f69
xdg-shell: convert to try_from

Chases: f9bd416d4156942ce3951a6c5cf9f81a3cf4a3dd
layer-shell-v1: convert to try_from

Chases: fbf5982e3838ee28b5345e98832f6956c402b225
xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface()
2023-11-27 21:01:53 +00:00
Consolatis
4d679801ad src/view.c: add always_on_top criteria 2023-11-21 22:31:05 +01:00
Consolatis
13d0b14244 Update top layer visiblity on workspace switch
Fixes: #1158
2023-11-12 17:39:00 +00:00
Johan Malm
368ede7460 window-rules: add fixedPosition property
...to address regression introduced by 57075ce and enables panel/desktop
clients which rely on window rules to remain in the same position when
the usable-area changes (normally because an exclusive layer-shell
clients is started/finished).

Also disallows interactive move/resize, for example by alt +
mouse-press.

Fixes: #1235
2023-11-10 21:46:15 +01:00
tokyo4j
9a8a2905ad interactive: Make window snapping with mouse more intuitive
1. Prevent window snapping triggered by mouse from moving the window
 into the adjacent output.
2. Make the coordinates used to check whether window snapping is
 triggered relative to the output the cursor is at, not the output the
 view is belonging to. This allows users to grab a tiled window and move
 it into another output or tile it again in another output in a single
 drag.
2023-11-10 19:41:36 +00:00
John Lindgren
57075ce864 view: ensure that floating views don't overlap top panels
The top_left_edge_boundary_check() function in xwayland.c ensures that
views trying to position themselves at 0,0 don't end up with a titlebar
offscreen. However, it doesn't take into account the usable area and
thus these views can still end up overlapping a top panel.

Also, there is no good reason for top_left_edge_boundary_check() to be
xwayland-specific. This logic should really be part of
view_adjust_for_layout_change().

To fix all this, add a new view_adjust_floating_geometry() function,
which replaces the existing similar (and duplicated) logic in
view_apply_natural_geometry() and view_adjust_for_layout_change().

view_adjust_for_layout_change() is already being called from xwayland's
set_initial_position(), so top_left_edge_boundary_check() is now
redundant and can just be deleted.

Lightly tested with waybar and feh --geometry 640x480+0+0. The feh
window is now correctly positioned below waybar, even if started before
waybar (in that case, the feh window is moved when waybar starts).
2023-11-05 15:03:13 +00:00
Consolatis
984aeb0b0b keyboard: allow applying keyboard layout per window
Fixes #1076

It can be enabled with a config like

~/.config/labwc/rc.xml:
<keyboard layoutScope="window">

~/.config/labwc/environment:
XKB_DEFAULT_LAYOUT=de,us
XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,grp_led:scroll

With a configuration like this each window should now remember
the active keyboard layout when switching between windows.

By default, the keyboard layout keeps being a global state.
2023-11-04 07:58:43 +00:00
John Lindgren
0430f6f818 view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.

Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).

Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.

Internally, I've taken the following approach:

- SSD code decorates the view as "maximized" (i.e. hiding borders) only
  if maximized in both directions.

- Layout code (interactive move/resize, tiling, etc.) generally treats
  the view as "maximized" (with the restrictions that entails) if
  maximized in either direction. For example, moving a vertically-
  maximized view first restores the natural geometry (this differs from
  Openbox, which instead allows the view to move only horizontally.)

v2: use enum view_axis for view->maximized
v3:
  - update docs
  - allow resizing if partly maximized
  - add TODOs & corrections noted by Consolatis
2023-10-28 22:46:49 +02:00
John Lindgren
db591d1400 view: avoid raising same view over and over
Since view_move_to_front() now does more work than it used to
(updating XWayland server stacking order), try to avoid doing that
work unnecessarily.
2023-10-21 21:42:24 +01:00
John Lindgren
47e80a488e view: commonize sub-view logic in view_move_to_front/back()
The logic was the same for xdg-shell and xwayland views, so move it from
the view->impl layer out to the view_move_to_front/back() functions.

view->impl->move_to_front/back() still exist for now, in case we want to
add xdg/xwayland-specific logic in future, but they now move only one
view and not sub-views.
2023-10-21 15:40:56 +01:00
John Lindgren
048d22d473 common: move MIN and MAX to common/macros.h 2023-10-21 12:37:42 +01:00
Axel Burri
299fb83fcc GrowToEdge, ShrinkToEdge: Implement actions 2023-10-19 19:09:42 +01:00
Axel Burri
08cff6edcf MoveToEdge: Snap to window edge
Add configurable option (enabled by default) to snap to next window
edge instead of screen edge.
2023-10-19 19:09:42 +01:00
Axel Burri
5176ac4f64 Move min/max view width/height to header
Preparatory for snap to window edge framework.
2023-10-19 19:09:42 +01:00
Axel Burri
0fd26c63fa Use output_usable_area_scaled() helper 2023-10-19 19:09:42 +01: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
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