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:
@@ -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
|
style; otherwise the popup sits under the focus window, or under the client
|
||||||
window when no focus window is set.
|
window when no focus window is set.
|
||||||
|
|
||||||
The popup is an X11 window, XIM is X11-only, and GTK popup placement converts
|
The popup is an X11 window sized by `GDK_SCALE` on HiDPI displays, XIM is
|
||||||
the GTK caret to X11 root coordinates. There is no native Wayland popup
|
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
|
surface or Wayland caret positioning. GTK and IBus clients can still use
|
||||||
inline preedit where their display environment supports it.
|
inline preedit where their display environment supports it.
|
||||||
|
|
||||||
|
|||||||
17
dat.h
17
dat.h
@@ -18,12 +18,6 @@ enum
|
|||||||
LangEMOJI = 0x05,
|
LangEMOJI = 0x05,
|
||||||
LangVI = 0x16,
|
LangVI = 0x16,
|
||||||
|
|
||||||
Fontsz = 32,
|
|
||||||
PopupPad = 4,
|
|
||||||
PopupSep = 1,
|
|
||||||
PopupNumw = Fontsz,
|
|
||||||
PopupTextw = 12*Fontsz,
|
|
||||||
PopupBasew = 2*PopupPad + PopupNumw + PopupTextw,
|
|
||||||
Maxrunes = 64,
|
Maxrunes = 64,
|
||||||
Maxutf = Maxrunes * UTFmax + 1,
|
Maxutf = Maxrunes * UTFmax + 1,
|
||||||
};
|
};
|
||||||
@@ -33,7 +27,6 @@ enum
|
|||||||
Maxclients = 64,
|
Maxclients = 64,
|
||||||
Maxkouho = 128,
|
Maxkouho = 128,
|
||||||
Maxdisp = 9,
|
Maxdisp = 9,
|
||||||
Imgh = 2*PopupPad + (Maxdisp + 2)*Fontsz + PopupSep,
|
|
||||||
|
|
||||||
Colfg = 0x000000,
|
Colfg = 0x000000,
|
||||||
Colbg = 0xffffff,
|
Colbg = 0xffffff,
|
||||||
@@ -42,6 +35,16 @@ enum
|
|||||||
Colselfg = 0xffffff,
|
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;
|
typedef struct Str Str;
|
||||||
struct Str
|
struct Str
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ enum {
|
|||||||
Asciitofull = 0xFEE0,
|
Asciitofull = 0xFEE0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int popupscale = 1;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill(u32int *buf, int n, u32int color)
|
fill(u32int *buf, int n, u32int color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,12 +5,13 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Guard = 8,
|
Guard = 8,
|
||||||
Testw = 6 * Fontsz,
|
|
||||||
Testh = 3 * Fontsz,
|
|
||||||
Testn = Testw * Testh,
|
|
||||||
Rgbmask = 0xffffff,
|
Rgbmask = 0xffffff,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define Testw (6 * Fontsz)
|
||||||
|
#define Testh (3 * Fontsz)
|
||||||
|
#define Testn (Testw * Testh)
|
||||||
|
|
||||||
static u32int guardcolor = 0x5a5a5a5a;
|
static u32int guardcolor = 0x5a5a5a5a;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ checkpadding(struct ct *t, u32int *img, Popup *p)
|
|||||||
void
|
void
|
||||||
popup_layout(struct ct *t)
|
popup_layout(struct ct *t)
|
||||||
{
|
{
|
||||||
static int tinyheight[] = {
|
int tinyheight[] = {
|
||||||
1, PopupPad, 2*PopupPad + Fontsz - 1,
|
1, PopupPad, 2*PopupPad + Fontsz - 1,
|
||||||
};
|
};
|
||||||
static const struct {
|
static const struct {
|
||||||
|
|||||||
4
win.c
4
win.c
@@ -206,7 +206,11 @@ wininit(void)
|
|||||||
xcb_randr_query_version_cookie_t rc;
|
xcb_randr_query_version_cookie_t rc;
|
||||||
xcb_randr_query_version_reply_t *rr;
|
xcb_randr_query_version_reply_t *rr;
|
||||||
const xcb_query_extension_reply_t *rext;
|
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);
|
conn = xcb_connect(nil, &n);
|
||||||
if(xcb_connection_has_error(conn)){
|
if(xcb_connection_has_error(conn)){
|
||||||
fprint(2, "strans: popup disabled: cannot connect to X display\n");
|
fprint(2, "strans: popup disabled: cannot connect to X display\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user