i3compat: add window_type to IPC response

i3 added these in i3/i3#3797
This commit is contained in:
Jason Nader 2020-02-16 15:14:45 +09:00 committed by Drew DeVault
parent 8608a1c38b
commit d2cab83833

View file

@ -86,32 +86,39 @@ static const char *ipc_json_output_transform_description(enum wl_output_transfor
} }
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
static const char *ipc_json_xwindow_type_description(enum atom_name window_type) { static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
switch (window_type) { struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
case NET_WM_WINDOW_TYPE_NORMAL: struct sway_xwayland *xwayland = &server.xwayland;
for (size_t i = 0; i < surface->window_type_len; ++i) {
xcb_atom_t type = surface->window_type[i];
if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_NORMAL]) {
return "normal"; return "normal";
case NET_WM_WINDOW_TYPE_DIALOG: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_DIALOG]) {
return "dialog"; return "dialog";
case NET_WM_WINDOW_TYPE_UTILITY: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_UTILITY]) {
return "utility"; return "utility";
case NET_WM_WINDOW_TYPE_TOOLBAR: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_TOOLBAR]) {
return "toolbar"; return "toolbar";
case NET_WM_WINDOW_TYPE_SPLASH: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_SPLASH]) {
return "splash"; return "splash";
case NET_WM_WINDOW_TYPE_MENU: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_MENU]) {
return "menu"; return "menu";
case NET_WM_WINDOW_TYPE_DROPDOWN_MENU: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_DROPDOWN_MENU]) {
return "dropdown_menu"; return "dropdown_menu";
case NET_WM_WINDOW_TYPE_POPUP_MENU: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_POPUP_MENU]) {
return "popup_menu"; return "popup_menu";
case NET_WM_WINDOW_TYPE_TOOLTIP: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_TOOLTIP]) {
return "tooltip"; return "tooltip";
case NET_WM_WINDOW_TYPE_NOTIFICATION: } else if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_NOTIFICATION]) {
return "notification"; return "notification";
default: } else {
return "unknown"; return "unknown";
} }
} }
return "unknown";
}
#endif #endif
json_object *ipc_json_get_version(void) { json_object *ipc_json_get_version(void) {
@ -485,7 +492,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
if (window_type) { if (window_type) {
json_object_object_add(window_props, "window_type", json_object_object_add(window_props, "window_type",
json_object_new_string( json_object_new_string(
ipc_json_xwindow_type_description(window_type))); ipc_json_xwindow_type_description(c->view)));
} }
json_object_object_add(object, "window_properties", window_props); json_object_object_add(object, "window_properties", window_props);