mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
xwayland: add wlr_xwayland_set_workareas()
This function allows compositors to set the _NET_WORKAREA property on the root window. XWayland clients use _NET_WORKAREA to determine how much of the screen is not covered by panels/docks. The property is used for example by Qt to determine areas of the screen that popup menus should not overlap (see QScreen::availableVirtualGeometry).
This commit is contained in:
parent
2410710a0f
commit
af165acb42
3 changed files with 34 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
#include <wlr/util/addon.h>
|
#include <wlr/util/addon.h>
|
||||||
|
|
||||||
|
struct wlr_box;
|
||||||
struct wlr_xwm;
|
struct wlr_xwm;
|
||||||
struct wlr_data_source;
|
struct wlr_data_source;
|
||||||
struct wlr_drag;
|
struct wlr_drag;
|
||||||
|
@ -285,4 +286,14 @@ bool wlr_xwayland_or_surface_wants_focus(
|
||||||
enum wlr_xwayland_icccm_input_model wlr_xwayland_icccm_input_model(
|
enum wlr_xwayland_icccm_input_model wlr_xwayland_icccm_input_model(
|
||||||
const struct wlr_xwayland_surface *xsurface);
|
const struct wlr_xwayland_surface *xsurface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the _NET_WORKAREA root window property. The compositor should set
|
||||||
|
* one workarea per virtual desktop. This indicates the usable geometry
|
||||||
|
* (relative to the virtual desktop viewport) that is not covered by
|
||||||
|
* panels, docks, etc. Unfortunately, it is not possible to specify
|
||||||
|
* per-output workareas.
|
||||||
|
*/
|
||||||
|
void wlr_xwayland_set_workareas(struct wlr_xwayland *wlr_xwayland,
|
||||||
|
const struct wlr_box *workareas, size_t num_workareas);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -88,6 +88,7 @@ enum atom_name {
|
||||||
DND_ACTION_PRIVATE,
|
DND_ACTION_PRIVATE,
|
||||||
NET_CLIENT_LIST,
|
NET_CLIENT_LIST,
|
||||||
NET_CLIENT_LIST_STACKING,
|
NET_CLIENT_LIST_STACKING,
|
||||||
|
NET_WORKAREA,
|
||||||
ATOM_LAST // keep last
|
ATOM_LAST // keep last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ static const char *const atom_map[ATOM_LAST] = {
|
||||||
[DND_ACTION_PRIVATE] = "XdndActionPrivate",
|
[DND_ACTION_PRIVATE] = "XdndActionPrivate",
|
||||||
[NET_CLIENT_LIST] = "_NET_CLIENT_LIST",
|
[NET_CLIENT_LIST] = "_NET_CLIENT_LIST",
|
||||||
[NET_CLIENT_LIST_STACKING] = "_NET_CLIENT_LIST_STACKING",
|
[NET_CLIENT_LIST_STACKING] = "_NET_CLIENT_LIST_STACKING",
|
||||||
|
[NET_WORKAREA] = "_NET_WORKAREA",
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STARTUP_INFO_REMOVE_PREFIX "remove: ID="
|
#define STARTUP_INFO_REMOVE_PREFIX "remove: ID="
|
||||||
|
@ -2327,3 +2328,24 @@ enum wlr_xwayland_icccm_input_model wlr_xwayland_icccm_input_model(
|
||||||
}
|
}
|
||||||
return WLR_ICCCM_INPUT_MODEL_NONE;
|
return WLR_ICCCM_INPUT_MODEL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_xwayland_set_workareas(struct wlr_xwayland *wlr_xwayland,
|
||||||
|
const struct wlr_box *workareas, size_t num_workareas) {
|
||||||
|
uint32_t *data = malloc(4 * sizeof(uint32_t) * num_workareas);
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_workareas; i++) {
|
||||||
|
data[4 * i] = workareas[i].x;
|
||||||
|
data[4 * i + 1] = workareas[i].y;
|
||||||
|
data[4 * i + 2] = workareas[i].width;
|
||||||
|
data[4 * i + 3] = workareas[i].height;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_xwm *xwm = wlr_xwayland->xwm;
|
||||||
|
xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE,
|
||||||
|
xwm->screen->root, xwm->atoms[NET_WORKAREA],
|
||||||
|
XCB_ATOM_CARDINAL, 32, 4 * num_workareas, data);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue