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:
@@ -23,6 +23,7 @@ RUN pacman -Syu --noconfirm --needed \
|
|||||||
which \
|
which \
|
||||||
xorg-server-xvfb \
|
xorg-server-xvfb \
|
||||||
xcb-imdkit \
|
xcb-imdkit \
|
||||||
|
xcb-util \
|
||||||
dbus \
|
dbus \
|
||||||
&& pacman -Scc --noconfirm
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -5,12 +5,12 @@ CFLAGS ?= -O2 -g
|
|||||||
WARN_CFLAGS = -Wall -Wextra
|
WARN_CFLAGS = -Wall -Wextra
|
||||||
IBUS_CFLAGS = $(shell $(PKG_CONFIG) --cflags dbus-1 xkbcommon)
|
IBUS_CFLAGS = $(shell $(PKG_CONFIG) --cflags dbus-1 xkbcommon)
|
||||||
IBUS_LIBS = $(shell $(PKG_CONFIG) --libs dbus-1 xkbcommon)
|
IBUS_LIBS = $(shell $(PKG_CONFIG) --libs dbus-1 xkbcommon)
|
||||||
XIM_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-imdkit xcb-xkb xkbcommon-x11)
|
XIM_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
|
||||||
XIM_LIBS = $(shell $(PKG_CONFIG) --libs xcb-imdkit xcb-xkb xkbcommon-x11)
|
XIM_LIBS = $(shell $(PKG_CONFIG) --libs xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
|
||||||
TEXT_CFLAGS = $(shell $(PKG_CONFIG) --cflags pangocairo cairo fontconfig)
|
TEXT_CFLAGS = $(shell $(PKG_CONFIG) --cflags pangocairo cairo fontconfig)
|
||||||
TEXT_LIBS = $(shell $(PKG_CONFIG) --libs pangocairo cairo fontconfig)
|
TEXT_LIBS = $(shell $(PKG_CONFIG) --libs pangocairo cairo fontconfig)
|
||||||
POPUP_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-randr)
|
POPUP_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-aux xcb-randr)
|
||||||
POPUP_LIBS = $(shell $(PKG_CONFIG) --libs xcb-randr)
|
POPUP_LIBS = $(shell $(PKG_CONFIG) --libs xcb-aux xcb-randr)
|
||||||
PROJECT_CPPFLAGS =
|
PROJECT_CPPFLAGS =
|
||||||
PROJECT_LDLIBS = -lthread -lbio -lxcb $(IBUS_LIBS) $(TEXT_LIBS) \
|
PROJECT_LDLIBS = -lthread -lbio -lxcb $(IBUS_LIBS) $(TEXT_LIBS) \
|
||||||
$(XIM_LIBS) $(POPUP_LIBS)
|
$(XIM_LIBS) $(POPUP_LIBS)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ and cmp/diff, plus development files for:
|
|||||||
|
|
||||||
- Plan 9 port (`9c`, `9l`, `libthread`, and `libbio`);
|
- Plan 9 port (`9c`, `9l`, `libthread`, and `libbio`);
|
||||||
- D-Bus development files;
|
- D-Bus development files;
|
||||||
- XCB, XCB RandR, XCB XKB, xcb-imdkit, xkbcommon, and xkbcommon-x11;
|
- XCB, XCB RandR, XCB XKB, xcb-util, xcb-imdkit, xkbcommon, and xkbcommon-x11;
|
||||||
- Pango, PangoCairo, Cairo, and Fontconfig;
|
- Pango, PangoCairo, Cairo, and Fontconfig;
|
||||||
- GTK 3, plus libibus and Xlib for the live clients;
|
- GTK 3, plus libibus and Xlib for the live clients;
|
||||||
- Xvfb for the X11 live tests;
|
- Xvfb for the X11 live tests;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ IBUS_CLIENT_CFLAGS = $(shell $(PKG_CONFIG) --cflags ibus-1.0)
|
|||||||
IBUS_CLIENT_LIBS = $(shell $(PKG_CONFIG) --libs ibus-1.0)
|
IBUS_CLIENT_LIBS = $(shell $(PKG_CONFIG) --libs ibus-1.0)
|
||||||
X11_CFLAGS = $(shell $(PKG_CONFIG) --cflags x11)
|
X11_CFLAGS = $(shell $(PKG_CONFIG) --cflags x11)
|
||||||
X11_LIBS = $(shell $(PKG_CONFIG) --libs x11)
|
X11_LIBS = $(shell $(PKG_CONFIG) --libs x11)
|
||||||
XIM_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-imdkit xcb-xkb xkbcommon-x11)
|
XIM_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
|
||||||
XIM_LIBS = $(shell $(PKG_CONFIG) --libs xcb-imdkit xcb-xkb xkbcommon-x11)
|
XIM_LIBS = $(shell $(PKG_CONFIG) --libs xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
|
||||||
UNIT_LDLIBS = -lthread -lbio $(TEXT_LIBS) $(IBUS_LIBS) $(XIM_LIBS)
|
UNIT_LDLIBS = -lthread -lbio $(TEXT_LIBS) $(IBUS_LIBS) $(XIM_LIBS)
|
||||||
|
|
||||||
PROG = unit_test
|
PROG = unit_test
|
||||||
|
|||||||
14
win.c
14
win.c
@@ -1,4 +1,5 @@
|
|||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
#include <xcb/randr.h>
|
#include <xcb/randr.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fn.h"
|
#include "fn.h"
|
||||||
@@ -14,17 +15,6 @@ static xcb_atom_t workarea;
|
|||||||
static int hasrandr, imgh, imgw;
|
static int hasrandr, imgh, imgw;
|
||||||
static int shown, ptrx, ptry; /* the popup, and where the pointer was as it came up */
|
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*
|
static xcb_visualtype_t*
|
||||||
getvisual(xcb_screen_t *s)
|
getvisual(xcb_screen_t *s)
|
||||||
{
|
{
|
||||||
@@ -218,7 +208,7 @@ wininit(void)
|
|||||||
wincleanup();
|
wincleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
scr = getscr(conn, n);
|
scr = xcb_aux_get_screen(conn, n);
|
||||||
if(scr == nil || !validformat(conn, scr)){
|
if(scr == nil || !validformat(conn, scr)){
|
||||||
fprint(2, "strans: popup disabled: unsupported X root format\n");
|
fprint(2, "strans: popup disabled: unsupported X root format\n");
|
||||||
wincleanup();
|
wincleanup();
|
||||||
|
|||||||
15
xim.c
15
xim.c
@@ -5,6 +5,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
#include <xcb/xkb.h>
|
#include <xcb/xkb.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
@@ -132,18 +133,6 @@ kwatch(void)
|
|||||||
events, parts, parts, nil);
|
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
|
static int
|
||||||
translate(xcb_window_t win, int x, int y, Caret *caret)
|
translate(xcb_window_t win, int x, int y, Caret *caret)
|
||||||
{
|
{
|
||||||
@@ -550,7 +539,7 @@ ximinit(void)
|
|||||||
ximlog("cannot connect to X server");
|
ximlog("cannot connect to X server");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
screen = getscreen(scr);
|
screen = xcb_aux_get_screen(conn, scr);
|
||||||
if(screen == nil){
|
if(screen == nil){
|
||||||
ximlog("cannot find X screen");
|
ximlog("cannot find X screen");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user