Before this commit, the pointer focus is cleared when a menu is closed
by clicking its border. This is because get_cursor_context() returns
type=LAB_SSD_NONE when the cursor is on the menu border and
cursor_update_common() clears the pointer focus. This commit fixes this
by replacing cursor_update_common() with cursor_update_focus(), which
calls get_cursor_context() again after the menu scene-node is hidden.
This is reland of 2ade6a1e which was reverted with 21bd5b00, but this
prevents the x-position of the menu from being negative and slides menus
opened with Alt-Space too.
Prior to this commit, a backing buffer with scale 1 was always created for
a scaled_scene_buffer before showing it, and backing buffers for specific
scales were created on output_enter events.
This commit removes this redundant re-renderings by calling
wlr_scene_buffer_set_dest_size() upon scaled_scene_buffer creation just to
receive output_enter events and delaying the first rendering to the first
output_enter event.
I needed to add font_get_buffer_size() to obtain the size of a font buffer
without actually creating it.
After commit e2189903 in wlroots, when ctrl-f is pressed in firefox with
a IME client running, the following key-release event for "f" is not
sent, thus "f" is repeated like "ffffffffff..." in the input box of
firefox. This is because the key-release event for "f" is firstly
forwarded to the IME client and then sent via the virtual keyboard created
by the IME client while the key-press event is sent via physical
keyboard, and with e2189903, key-release events without a corresponding
key-press event on the same keyboard is not emitted to the compositor.
So this commit fixes this problem by not forwarding the key-release event
to the IME client unless the corresponding key-press event was also
forwarded.
This allows to use it for a future ext-workspace implementation.
It is also more generalized so can be used for other protocol
implementation in the future in case the protocols require some
kind of transaction management.
This commit delegates the calculation for menu position into wlroots
utilities for xdg_positioner.
Notable functional changes are:
- Slide the menu to fit in the output when it's opened out of the output
(e.g. top-left window menu is opened when the window is overflowing to
the left), rather than not updating the menu at all.
- The horizontal alignment of menus is now determined based on the size of
each (sub)menu alone rather than the total width of entire menu tree.
This means submenus can now overlap with is parents, but this is no
longer a problem since we recently added support for menu borders.
- Fixed that pipemenus always follow the alignment of its parent even when
it overflows from the output.
Arrow signs are specific to submenu items, so they would be more natural
to be handled in menu.c rather than accepting "arrow" in
font_buffer_create().
Also I allowed non-positive numbers for max_width in font_buffer_create(),
in which case the natural font width is used as the buffer width.
- Don't store font/background buffers in menuitem struct since we no
longer dynamically update buffers of existing menuitems.
- Factor out the duplicated codes for creating menu item scenes for each
unselected/selected states.
This is a compile-time check, so it will be too conservative if somebody
updates wlroots after building labwc, but that is still better than the
alternatives.
Simple utility to allow protocol and version comparison between different
running compositors. This can be used to detect missing protocols or
versions in labwc. See for example this result when running against the
current labwc master and sway 1.10 (nested, results on DRM may differ):
Protocols missing from labwc @ wayland-0
ext_transient_seat_manager_v1 1
wl_compositor 6 (has version 5)
wp_alpha_modifier_v1 1
wp_content_type_manager_v1 1
xdg_wm_base 5 (has version 3)
zwp_keyboard_shortcuts_inhibit_manager_v1 1
Protocols missing from sway @ wayland-1
wl_drm 2
zcosmic_workspace_manager_v1 1
...to avoid a bug that is present in wlroots <0.18.2 and which has the
potential to crash the compositor when performing a drag-and-drop action
at the same time as the XWayland server is shutting down.
This will be reverted when wlroots-0.18.2 can be linked with.
Related-to: #2371
...when options are specified as elements leading to hitting the assert()
in xstrdup().
Reproduce by using this rc.xml:
```
<?xml version="1.0"?>
<labwc_config>
<touch>
<deviceName>foo</deviceName>
<mapToOutput>bar</mapToOutput>
</touch>
</labwc_config>
```
It is likely that <touch> was only tested with options as attributes.
Prior to this commit, output-relative coordinate was passed to
menu_open_root() as the menu position when it's designated via "x"/"y"
arguments in ShowMenu action, so menu can be misplaced to the output other
than the one in which the cursor is in.
With 2ade6a1, negative x-values can be passed to menu_configure() when the
window menu is opened from top-left button in a maximized window, but
wlr_output_layout_output_at() couldn't find the output for the coordinate
since it's out of the output layout, thus it just opened the menu without
updating its position.
As the next release is close and the visual improvement by 2ade6a1 is not
very impactful for UX, let's revert it for now.
This commit slides menus opened from buttons (with atCursor="no") to the
left by menu.border.width. This makes the location of the window menu
look more natural, especially when it's opened from the window icon in
the left corner of the titlebar.
In the longer term we want this to be user-configurable (and also depend
on the sandbox engine, app_id and instance).
But dropping privileged protocols for sandboxed clients in the meantime
seems like a sensible thing to do and matches user expectations.
Related: #2392
set_squared_corners(false) was always called when titlebar is created.
However, set_squared_corners(false) sets the width of the titlebar
background buffer to (view width) - (corner radius), which causes pixman
errors due to the negative width set for titlebar background buffer when
the view is so small.