History

wayland: further xdg-decoration/border refinements

The value of the border option should always match what the actual state of the window is. Previously if a compositor rejected the request by mpv, it did not correct itself. Also add some code to keep track of decoration requests. Anytime the state is changed, make the last saved request again (doesn't hurt and seems like intuitive behavior). Unfortunately, this isn't foolproof since options only send callback if the value is changed. (ex. on sway if the floating window has no border, and then is titled, setting the border value to "yes" does nothing since tiling the window already set the border value to "yes").

Dudemanguy committed 5 years ago

Commit 2d348981 parent 940f8712 files · +40 −26Browse files

Unified · Split

2 files
  1. video/out/wayland_common.c +39 −26
  2. video/out/wayland_common.h +1 −0
video/out/wayland_common.c+39−26
@@ -153,7 +153,7 @@ static int spawn_cursor(struct vo_wayland_state *wl); · 152 unmodified lines
153static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b);153static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b);
154static void queue_new_sync(struct vo_wayland_state *wl);154static void queue_new_sync(struct vo_wayland_state *wl);
155static void remove_output(struct vo_wayland_output *out);155static void remove_output(struct vo_wayland_output *out);
156static void set_border_decorations(struct vo_wayland_state *wl, uint32_t mode);156static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode);
157static void set_geometry(struct vo_wayland_state *wl);157static void set_geometry(struct vo_wayland_state *wl);
158static void set_surface_scaling(struct vo_wayland_state *wl);158static void set_surface_scaling(struct vo_wayland_state *wl);
159static void sync_shift(struct vo_wayland_state *wl);159static void sync_shift(struct vo_wayland_state *wl);
@@ -828,6 +828,9 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, · 668 unmodified lines
828 m_config_cache_write_opt(wl->vo_opts_cache, &vo_opts->window_maximized);828 m_config_cache_write_opt(wl->vo_opts_cache, &vo_opts->window_maximized);
829 }829 }
830 830
831 if (wl->requested_decoration)
832 request_decoration_mode(wl, wl->requested_decoration);
833
831 if (wl->activated != is_activated) {834 if (wl->activated != is_activated) {
832 wl->activated = is_activated;835 wl->activated = is_activated;
833 if ((!wl->focused && wl->activated && wl->has_keyboard_input) ||836 if ((!wl->focused && wl->activated && wl->has_keyboard_input) ||
@@ -905,7 +908,18 @@ static void configure_decorations(void *data, · 71 unmodified lines
905 uint32_t mode)908 uint32_t mode)
906{909{
907 struct vo_wayland_state *wl = data;910 struct vo_wayland_state *wl = data;
908 set_border_decorations(wl, mode);911 struct mp_vo_opts *opts = wl->vo_opts;
912
913 if (wl->requested_decoration == mode)
914 wl->requested_decoration = 0;
915
916 if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) {
917 MP_VERBOSE(wl, "Enabling server decorations\n");
918 } else {
919 MP_VERBOSE(wl, "Disabling server decorations\n");
920 }
921 opts->border = mode - 1;
922 m_config_cache_write_opt(wl->vo_opts_cache, &opts->border);
909}923}
910 924
911static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = {925static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = {
@@ -1311,6 +1325,12 @@ static void queue_new_sync(struct vo_wayland_state *wl) · 399 unmodified lines
1311 sync_shift(wl);1325 sync_shift(wl);
1312}1326}
1313 1327
1328static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode)
1329{
1330 wl->requested_decoration = mode;
1331 zxdg_toplevel_decoration_v1_set_mode(wl->xdg_toplevel_decoration, mode);
1332}
1333
1314static void remove_output(struct vo_wayland_output *out)1334static void remove_output(struct vo_wayland_output *out)
1315{1335{
1316 if (!out)1336 if (!out)
@@ -1325,25 +1345,6 @@ static void remove_output(struct vo_wayland_output *out) · 8 unmodified lines
1325 return;1345 return;
1326}1346}
1327 1347
1328static void set_border_decorations(struct vo_wayland_state *wl, uint32_t mode)
1329{
1330 if (!wl->xdg_toplevel_decoration) {
1331 wl->vo_opts->border = false;
1332 m_config_cache_write_opt(wl->vo_opts_cache,
1333 &wl->vo_opts->border);
1334 return;
1335 }
1336 if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) {
1337 MP_VERBOSE(wl, "Enabling server decorations\n");
1338 wl->vo_opts->border = true;
1339 } else {
1340 MP_VERBOSE(wl, "Disabling server decorations\n");
1341 wl->vo_opts->border = false;
1342 }
1343 m_config_cache_write_opt(wl->vo_opts_cache,
1344 &wl->vo_opts->border);
1345}
1346
1347static int set_cursor_visibility(struct vo_wayland_state *wl, bool on)1348static int set_cursor_visibility(struct vo_wayland_state *wl, bool on)
1348{1349{
1349 wl->cursor_visible = on;1350 wl->cursor_visible = on;
@@ -1562,9 +1563,22 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) · 212 unmodified lines
1562 while (m_config_cache_get_next_changed(wl->vo_opts_cache, &opt)) {1563 while (m_config_cache_get_next_changed(wl->vo_opts_cache, &opt)) {
1563 if (opt == &opts->appid)1564 if (opt == &opts->appid)
1564 update_app_id(wl);1565 update_app_id(wl);
1565 if (opt == &opts->border && wl->xdg_toplevel_decoration)1566 if (opt == &opts->border)
1566 // The enum in xdg-decoration starts at 1.1567 {
1567 zxdg_toplevel_decoration_v1_set_mode(wl->xdg_toplevel_decoration, opts->border + 1);1568 // This is stupid but the value of border shouldn't be written
1569 // unless we get a configure event. Change it back to its old
1570 // value and let configure_decorations handle it after the request.
1571 if (wl->xdg_toplevel_decoration) {
1572 opts->border = !opts->border;
1573 m_config_cache_write_opt(wl->vo_opts_cache,
1574 &opts->border);
1575 request_decoration_mode(wl, !opts->border + 1);
1576 } else {
1577 opts->border = false;
1578 m_config_cache_write_opt(wl->vo_opts_cache,
1579 &wl->vo_opts->border);
1580 }
1581 }
1568 if (opt == &opts->fullscreen)1582 if (opt == &opts->fullscreen)
1569 toggle_fullscreen(wl);1583 toggle_fullscreen(wl);
1570 if (opt == &opts->hidpi_window_scale)1584 if (opt == &opts->hidpi_window_scale)
@@ -1736,8 +1750,7 @@ int vo_wayland_init(struct vo *vo) · 165 unmodified lines
1736 if (wl->xdg_decoration_manager) {1750 if (wl->xdg_decoration_manager) {
1737 wl->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(wl->xdg_decoration_manager, wl->xdg_toplevel);1751 wl->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(wl->xdg_decoration_manager, wl->xdg_toplevel);
1738 zxdg_toplevel_decoration_v1_add_listener(wl->xdg_toplevel_decoration, &decoration_listener, wl);1752 zxdg_toplevel_decoration_v1_add_listener(wl->xdg_toplevel_decoration, &decoration_listener, wl);
1739 // The enum in xdg-decoration starts at 1.1753 request_decoration_mode(wl, wl->vo_opts->border + 1);
1740 zxdg_toplevel_decoration_v1_set_mode(wl->xdg_toplevel_decoration, wl->vo_opts->border + 1);
1741 } else {1754 } else {
1742 wl->vo_opts->border = false;1755 wl->vo_opts->border = false;
1743 m_config_cache_write_opt(wl->vo_opts_cache,1756 m_config_cache_write_opt(wl->vo_opts_cache,
video/out/wayland_common.h+1−0
@@ -79,6 +79,7 @@ struct vo_wayland_state { · 78 unmodified lines
79 /* xdg-decoration */79 /* xdg-decoration */
80 struct zxdg_decoration_manager_v1 *xdg_decoration_manager;80 struct zxdg_decoration_manager_v1 *xdg_decoration_manager;
81 struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;81 struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
82 int requested_decoration;
82 83
83 /* xdg-shell */84 /* xdg-shell */
84 struct xdg_wm_base *wm_base;85 struct xdg_wm_base *wm_base;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t