From 8581c2b56763d7787604c8c833d2bd78bdc6a466 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:22:59 -0500 Subject: libdraw: add Cursor2, a 32x32 high-res cursor Also add setcursor2, esetcursor2, and draw protocol encoding. Calls to the old setcursor, esetcursor create a 32x32 by pixel doubling when needed. --- include/cursor.h | 10 ++++++++++ include/draw.h | 3 ++- include/drawfcall.h | 6 ++++++ include/event.h | 2 ++ include/mouse.h | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/cursor.h b/include/cursor.h index d53baf81..e39d2ea5 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -12,6 +12,16 @@ struct Cursor uchar set[2*16]; }; +typedef struct Cursor2 Cursor2; +struct Cursor2 +{ + Point offset; + uchar clr[4*32]; + uchar set[4*32]; +}; + +void scalecursor(Cursor2*, Cursor*); + #if defined(__cplusplus) } #endif diff --git a/include/draw.h b/include/draw.h index 3a012959..2f283bdf 100644 --- a/include/draw.h +++ b/include/draw.h @@ -568,9 +568,10 @@ int mousescrollsize(int); */ struct Mouse; struct Cursor; +struct Cursor2; int _displaybouncemouse(Display *d, struct Mouse *m); int _displayconnect(Display *d); -int _displaycursor(Display *d, struct Cursor *c); +int _displaycursor(Display *d, struct Cursor *c, struct Cursor2 *c2); int _displayinit(Display *d, char *label, char *winsize); int _displaylabel(Display *d, char *label); int _displaymoveto(Display *d, Point p); diff --git a/include/drawfcall.h b/include/drawfcall.h index fb339919..acab98c5 100644 --- a/include/drawfcall.h +++ b/include/drawfcall.h @@ -13,6 +13,9 @@ tag[1] Rmoveto tag[1] Tcursor cursor[] tag[1] Rcursor +tag[1] Tcursor2 cursor[] +tag[1] Rcursor2 + tag[1] Tbouncemouse x[4] y[4] button[4] tag[1] Rbouncemouse @@ -89,6 +92,8 @@ enum { Rtop, Tresize = 26, Rresize, + Tcursor2 = 28, + Rcursor2, Tmax, }; @@ -104,6 +109,7 @@ struct Wsysmsg Mouse mouse; int resized; Cursor cursor; + Cursor2 cursor2; int arrowcursor; Rune rune; char *winsize; diff --git a/include/event.h b/include/event.h index 09cb5c78..e66bf117 100644 --- a/include/event.h +++ b/include/event.h @@ -61,7 +61,9 @@ extern int emenuhit(int, Mouse*, Menu*); extern int eatomouse(Mouse*, char*, int); extern Rectangle getrect(int, Mouse*); struct Cursor; +struct Cursor2; extern void esetcursor(struct Cursor*); +extern void esetcursor2(struct Cursor*, struct Cursor2*); extern void emoveto(Point); extern Rectangle egetrect(int, Mouse*); extern void edrawgetrect(Rectangle, int); diff --git a/include/mouse.h b/include/mouse.h index 3d5c975f..c46d51e9 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -38,7 +38,9 @@ extern void moveto(Mousectl*, Point); extern int readmouse(Mousectl*); extern void closemouse(Mousectl*); struct Cursor; +struct Cursor2; extern void setcursor(Mousectl*, struct Cursor*); +extern void setcursor2(Mousectl*, struct Cursor*, struct Cursor2*); extern void drawgetrect(Rectangle, int); extern Rectangle getrect(int, Mousectl*); extern int menuhit(int, Mousectl*, Menu*, Screen*); -- cgit v1.2.3 From 16d00819899260085ee10949012b07bf1c203db6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 23:52:05 -0500 Subject: libdraw: redo default font construction to be hidpi-safe If $font is not set, the default font is constructed from font data linked into every libdraw binary. That process was different from the usual openfont code, and so it was not hidpi-aware, resulting in very tiny fonts out of the box on hidpi systems, until users set $font. Fix this by using openfont to construct the default font, by recognizing the name *default* when looking for font and subfont file contents. Then all the hidpi scaling applies automatically. As a side effect, the concept of a 'default subfont' is gone, as are display->defaultsubfont, getdefont, and memgetdefont. --- include/draw.h | 4 ---- include/memdraw.h | 1 - 2 files changed, 5 deletions(-) (limited to 'include') diff --git a/include/draw.h b/include/draw.h index 2f283bdf..926cc748 100644 --- a/include/draw.h +++ b/include/draw.h @@ -199,7 +199,6 @@ struct Display int obufsize; uchar *obufp; Font *defaultfont; - Subfont *defaultsubfont; Image *windows; Image *screenimage; int _isnewdisplay; @@ -498,7 +497,6 @@ extern Point strsubfontwidth(Subfont*, char*); extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**); extern char* subfontname(char*, char*, int); extern Subfont* _getsubfont(Display*, char*); -extern Subfont* getdefont(Display*); extern void lockdisplay(Display*); extern void unlockdisplay(Display*); extern int drawlsetrefresh(u32int, int, void*, void*); @@ -508,8 +506,6 @@ extern void swapfont(Font*, Font**, Font**); /* * Predefined */ -extern uchar defontdata[]; -extern int sizeofdefont; extern Point ZP; extern Rectangle ZR; diff --git a/include/memdraw.h b/include/memdraw.h index b1495ed8..a22dbe2b 100644 --- a/include/memdraw.h +++ b/include/memdraw.h @@ -178,7 +178,6 @@ extern Memsubfont* allocmemsubfont(char*, int, int, int, Fontchar*, Memimage*); extern Memsubfont* openmemsubfont(char*); extern void freememsubfont(Memsubfont*); extern Point memsubfontwidth(Memsubfont*, char*); -extern Memsubfont* getmemdefont(void); /* * Predefined -- cgit v1.2.3