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

15
xim.c
View File

@@ -5,6 +5,7 @@
#include <locale.h>
#include <poll.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
@@ -132,18 +133,6 @@ kwatch(void)
events, parts, parts, nil);
}
static xcb_screen_t*
getscreen(int scr)
{
xcb_screen_iterator_t iter;
iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
for(; iter.rem; scr--, xcb_screen_next(&iter))
if(scr == 0)
return iter.data;
return nil;
}
static int
translate(xcb_window_t win, int x, int y, Caret *caret)
{
@@ -550,7 +539,7 @@ ximinit(void)
ximlog("cannot connect to X server");
return -1;
}
screen = getscreen(scr);
screen = xcb_aux_get_screen(conn, scr);
if(screen == nil){
ximlog("cannot find X screen");
return -1;