win: fix incorrect wintype atoms

I mixed up wintype names and their corresponding atoms.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-20 00:41:55 +00:00
parent faa7ba222f
commit bc7b697915
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
6 changed files with 31 additions and 23 deletions

View File

@ -1655,7 +1655,9 @@ static bool c2_match_once_leaf_string(struct atom *atoms, const struct managed_w
const char *predef_target = NULL;
if (leaf->predef != C2_L_PUNDEFINED) {
switch (leaf->predef) {
case C2_L_PWINDOWTYPE: predef_target = WINTYPES[w->window_type]; break;
case C2_L_PWINDOWTYPE:
predef_target = WINTYPES[w->window_type].name;
break;
case C2_L_PNAME: predef_target = w->name; break;
case C2_L_PCLASSG: predef_target = w->class_general; break;
case C2_L_PCLASSI: predef_target = w->class_instance; break;

View File

@ -387,8 +387,11 @@ typedef struct session {
/// Enumeration for window event hints.
typedef enum { WIN_EVMODE_UNKNOWN, WIN_EVMODE_FRAME, WIN_EVMODE_CLIENT } win_evmode_t;
extern const char *const WINTYPES[NUM_WINTYPES];
struct wintype_info {
const char *name;
const char *atom;
};
extern const struct wintype_info WINTYPES[NUM_WINTYPES];
extern session_t *ps_g;
void ev_xcb_error(session_t *ps, xcb_generic_error_t *err);

View File

@ -659,7 +659,7 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// XXX ! Refactor all the wintype_* arrays into a struct
for (wintype_t i = 0; i < NUM_WINTYPES; ++i) {
parse_wintype_config(&cfg, WINTYPES[i], &opt->wintype_option[i],
parse_wintype_config(&cfg, WINTYPES[i].name, &opt->wintype_option[i],
&winopt_mask[i]);
}

View File

@ -46,6 +46,7 @@
#include "err.h"
#include "kernel.h"
#include "picom.h"
#include "win_defs.h"
#ifdef CONFIG_OPENGL
#include "opengl.h"
#endif
@ -85,22 +86,24 @@ static void unredirect(session_t *ps);
// === Global constants ===
/// Name strings for window types.
const char *const WINTYPES[] = {
[WINTYPE_UNKNOWN] = "unknown",
[WINTYPE_DESKTOP] = "desktop",
[WINTYPE_DOCK] = "dock",
[WINTYPE_TOOLBAR] = "toolbar",
[WINTYPE_MENU] = "menu",
[WINTYPE_UTILITY] = "utility",
[WINTYPE_SPLASH] = "splash",
[WINTYPE_DIALOG] = "dialog",
[WINTYPE_NORMAL] = "normal",
[WINTYPE_DROPDOWN_MENU] = "dropdown_menu",
[WINTYPE_POPUP_MENU] = "popup_menu",
[WINTYPE_TOOLTIP] = "tooltip",
[WINTYPE_NOTIFICATION] = "notification",
[WINTYPE_COMBO] = "combo",
[WINTYPE_DND] = "dnd",
const struct wintype_info WINTYPES[] = {
[WINTYPE_UNKNOWN] = {"unknown", NULL},
#define X(name, type) [WINTYPE_##type] = {#name, "_NET_WM_WINDOW_TYPE_" #type}
X(desktop, DESKTOP),
X(dock, DOCK),
X(toolbar, TOOLBAR),
X(menu, MENU),
X(utility, UTILITY),
X(splash, SPLASH),
X(dialog, DIALOG),
X(normal, NORMAL),
X(dropdown_menu, DROPDOWN_MENU),
X(popup_menu, POPUP_MENU),
X(tooltip, TOOLTIP),
X(notification, NOTIFICATION),
X(combo, COMBO),
X(dnd, DND),
#undef X
};
// clang-format off

View File

@ -778,7 +778,7 @@ wid_get_prop_wintype(struct x_connection *c, struct atom *atoms, xcb_window_t wi
for (unsigned i = 0; i < prop.nitems; ++i) {
for (wintype_t j = 1; j < NUM_WINTYPES; ++j) {
if (get_atom_with_nul(atoms, WINTYPES[j], c->c) ==
if (get_atom_with_nul(atoms, WINTYPES[j].atom, c->c) ==
(xcb_atom_t)prop.p32[i]) {
free_winprop(&prop);
return j;
@ -2549,7 +2549,7 @@ void map_win_start(session_t *ps, struct managed_win *w) {
// Update window mode here to check for ARGB windows
w->mode = win_calc_mode(w);
log_debug("Window (%#010x) has type %s", w->base.id, WINTYPES[w->window_type]);
log_debug("Window (%#010x) has type %s", w->base.id, WINTYPES[w->window_type].name);
// XXX We need to make sure that win_data is available
// iff `state` is MAPPED

View File

@ -2,7 +2,7 @@
#include <stdint.h>
typedef enum {
WINTYPE_UNKNOWN,
WINTYPE_UNKNOWN = 0,
WINTYPE_DESKTOP,
WINTYPE_DOCK,
WINTYPE_TOOLBAR,