x11: xcb_aux_get_screen instead of two hand-rolled screen walks

win.c and xim.c each iterated the setup's roots to find the screen
xcb_connect had chosen; xcb-util, already linked through imdkit, has
xcb_aux_get_screen for that.
This commit is contained in:
2026-08-17 01:58:30 +09:00
parent 268b687ee6
commit dd389edc4f
6 changed files with 12 additions and 32 deletions

14
win.c
View File

@@ -1,4 +1,5 @@
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/randr.h>
#include "dat.h"
#include "fn.h"
@@ -14,17 +15,6 @@ static xcb_atom_t workarea;
static int hasrandr, imgh, imgw;
static int shown, ptrx, ptry; /* the popup, and where the pointer was as it came up */
static xcb_screen_t*
getscr(xcb_connection_t *c, int n)
{
xcb_screen_iterator_t i;
for(i = xcb_setup_roots_iterator(xcb_get_setup(c)); i.rem; xcb_screen_next(&i))
if(n-- == 0)
return i.data;
return nil;
}
static xcb_visualtype_t*
getvisual(xcb_screen_t *s)
{
@@ -218,7 +208,7 @@ wininit(void)
wincleanup();
return 0;
}
scr = getscr(conn, n);
scr = xcb_aux_get_screen(conn, n);
if(scr == nil || !validformat(conn, scr)){
fprint(2, "strans: popup disabled: unsupported X root format\n");
wincleanup();