popup: follow GDK_SCALE on HiDPI

The popup was 32-pixel rows whatever the display; next to 2x application
text it was small. Its metrics now scale with the daemon's GDK_SCALE,
the setting the applications use.
This commit is contained in:
2026-08-16 21:35:43 +09:00
parent 30abd05e68
commit 4ff696d06c
6 changed files with 24 additions and 13 deletions

View File

@@ -45,8 +45,9 @@ sends `XNSpotLocation` gets the popup at that spot whatever its preedit
style; otherwise the popup sits under the focus window, or under the client
window when no focus window is set.
The popup is an X11 window, XIM is X11-only, and GTK popup placement converts
the GTK caret to X11 root coordinates. There is no native Wayland popup
The popup is an X11 window sized by `GDK_SCALE` on HiDPI displays, XIM is
X11-only, and GTK popup placement converts the GTK caret to X11 root
coordinates. There is no native Wayland popup
surface or Wayland caret positioning. GTK and IBus clients can still use
inline preedit where their display environment supports it.

17
dat.h
View File

@@ -18,12 +18,6 @@ enum
LangEMOJI = 0x05,
LangVI = 0x16,
Fontsz = 32,
PopupPad = 4,
PopupSep = 1,
PopupNumw = Fontsz,
PopupTextw = 12*Fontsz,
PopupBasew = 2*PopupPad + PopupNumw + PopupTextw,
Maxrunes = 64,
Maxutf = Maxrunes * UTFmax + 1,
};
@@ -33,7 +27,6 @@ enum
Maxclients = 64,
Maxkouho = 128,
Maxdisp = 9,
Imgh = 2*PopupPad + (Maxdisp + 2)*Fontsz + PopupSep,
Colfg = 0x000000,
Colbg = 0xffffff,
@@ -42,6 +35,16 @@ enum
Colselfg = 0xffffff,
};
/* Popup metrics in pixels; popupscale is GDK_SCALE, for HiDPI. */
extern int popupscale;
#define Fontsz (32*popupscale)
#define PopupPad (4*popupscale)
#define PopupSep popupscale
#define PopupNumw Fontsz
#define PopupTextw (12*Fontsz)
#define PopupBasew (2*PopupPad + PopupNumw + PopupTextw)
#define Imgh (2*PopupPad + (Maxdisp + 2)*Fontsz + PopupSep)
typedef struct Str Str;
struct Str
{

View File

@@ -5,6 +5,8 @@ enum {
Asciitofull = 0xFEE0,
};
int popupscale = 1;
static void
fill(u32int *buf, int n, u32int color)
{

View File

@@ -5,12 +5,13 @@
enum
{
Guard = 8,
Testw = 6 * Fontsz,
Testh = 3 * Fontsz,
Testn = Testw * Testh,
Rgbmask = 0xffffff,
};
#define Testw (6 * Fontsz)
#define Testh (3 * Fontsz)
#define Testn (Testw * Testh)
static u32int guardcolor = 0x5a5a5a5a;
static void

View File

@@ -40,7 +40,7 @@ checkpadding(struct ct *t, u32int *img, Popup *p)
void
popup_layout(struct ct *t)
{
static int tinyheight[] = {
int tinyheight[] = {
1, PopupPad, 2*PopupPad + Fontsz - 1,
};
static const struct {

4
win.c
View File

@@ -206,7 +206,11 @@ wininit(void)
xcb_randr_query_version_cookie_t rc;
xcb_randr_query_version_reply_t *rr;
const xcb_query_extension_reply_t *rext;
char *scale;
scale = getenv("GDK_SCALE");
if(scale != nil && atoi(scale) > 1)
popupscale = min(atoi(scale), 4);
conn = xcb_connect(nil, &n);
if(xcb_connection_has_error(conn)){
fprint(2, "strans: popup disabled: cannot connect to X display\n");