aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--liberty-xdg.c18
-rw-r--r--liberty-xui.c17
-rw-r--r--liberty.c5
-rw-r--r--libertyxdr.vim2
4 files changed, 29 insertions, 13 deletions
diff --git a/liberty-xdg.c b/liberty-xdg.c
index be0746a..a918592 100644
--- a/liberty-xdg.c
+++ b/liberty-xdg.c
@@ -86,24 +86,30 @@ xdg_xsettings_update (struct xdg_xsettings *self, Display *dpy)
// TODO: We're supposed to lock the server.
// TODO: We're supposed to trap X errors.
char *selection = xstrdup_printf ("_XSETTINGS_S%d", DefaultScreen (dpy));
- Window owner
- = XGetSelectionOwner (dpy, XInternAtom (dpy, selection, True));
+ Atom selection_atom = XInternAtom (dpy, selection, True);
free (selection);
+ if (!selection_atom)
+ return;
+
+ Window owner = XGetSelectionOwner (dpy, selection_atom);
if (!owner)
return;
+ Atom xsettings_atom = XInternAtom (dpy, "_XSETTINGS_SETTINGS", True);
+ if (!xsettings_atom)
+ return;
+
Atom actual_type = None;
int actual_format = 0;
unsigned long nitems = 0, bytes_after = 0;
unsigned char *buffer = NULL;
- Atom xsettings = XInternAtom (dpy, "_XSETTINGS_SETTINGS", True);
int status = XGetWindowProperty (dpy,
owner,
- xsettings,
+ xsettings_atom,
0L,
LONG_MAX,
False,
- xsettings,
+ xsettings_atom,
&actual_type,
&actual_format,
&nitems,
@@ -112,7 +118,7 @@ xdg_xsettings_update (struct xdg_xsettings *self, Display *dpy)
if (status != Success || !buffer)
return;
- if (actual_type != xsettings
+ if (actual_type != xsettings_atom
|| actual_format != 8
|| nitems < 12)
goto fail;
diff --git a/liberty-xui.c b/liberty-xui.c
index 3f193b5..7058b41 100644
--- a/liberty-xui.c
+++ b/liberty-xui.c
@@ -1269,14 +1269,21 @@ x11_render_label (struct widget *self)
XRenderColor solid = *x11_fg (self), colors[3] = { solid, solid, solid };
colors[2].alpha = 0;
- double portion = MIN (1, 2.0 * font->list->font->height / space);
+ // Nvidia's XRender appears to not add (x, y) to (srcx, srcy),
+ // and works correctly if we pass self->x as srcx further on.
+ //
+ // Instead of special-casing nvidia_drv.so, let's have the gradient
+ // also extend to the left, in order to make text legible at all.
+ //
+ // We could also detect the behaviour experimentally in run-time.
+ double portion = MIN (1, 2. * font->list->font->height / (self->x + space));
XFixed stops[3] = { 0, XDoubleToFixed (1 - portion), XDoubleToFixed (1) };
- XLinearGradient gradient = { {}, { XDoubleToFixed (space), 0 } };
+ XLinearGradient gradient = { {}, { XDoubleToFixed (self->x + space), 0 } };
// Note that this masking is a very expensive operation.
Picture source =
XRenderCreateLinearGradient (g_xui.dpy, &gradient, stops, colors, 3);
- x11_font_render (font, PictOpOver, source, -self->x, 0, self->x, self->y,
+ x11_font_render (font, PictOpOver, source, 0, 0, self->x, self->y,
self->text);
XRenderFreePicture (g_xui.dpy, source);
}
@@ -1884,6 +1891,8 @@ x11_init (struct poller *poller, struct attrs *app_attrs, size_t app_attrs_len)
if (!(g_xui.dpy = XkbOpenDisplay
(NULL, &g_xui.xkb_base_event_code, NULL, NULL, NULL, NULL)))
exit_fatal ("cannot open display");
+ if (!XftInit (NULL))
+ print_warning ("Fontconfig initialization failed");
if (!XftDefaultHasRender (g_xui.dpy))
exit_fatal ("XRender is not supported");
if (!(g_xui.x11_im = XOpenIM (g_xui.dpy, NULL, NULL, NULL)))
@@ -1912,8 +1921,6 @@ x11_init (struct poller *poller, struct attrs *app_attrs, size_t app_attrs_len)
g_xui.x11_xsettings = xdg_xsettings_make ();
xdg_xsettings_update (&g_xui.x11_xsettings, g_xui.dpy);
- if (!FcInit ())
- print_warning ("Fontconfig initialization failed");
if (!(g_xui.xft_fonts = x11_font_open (0)))
exit_fatal ("cannot open a font");
diff --git a/liberty.c b/liberty.c
index 0690e89..b13a388 100644
--- a/liberty.c
+++ b/liberty.c
@@ -1209,7 +1209,10 @@ async_make (struct async_manager *manager)
}
/// Only allowed from the main thread once the job has been started but before
-/// the results have been dispatched
+/// the results have been dispatched.
+///
+/// Note that it may in practice lead to memory leakage, although that's
+/// an implementation issue: https://eissing.org/icing/posts/rip_pthread_cancel/
static void
async_cancel (struct async *self)
{
diff --git a/libertyxdr.vim b/libertyxdr.vim
index d980d77..ebe3f3a 100644
--- a/libertyxdr.vim
+++ b/libertyxdr.vim
@@ -8,7 +8,7 @@ syn region libertyxdrBlockComment start=+/[*]+ end=+[*]/+
syn match libertyxdrComment "//.*"
syn match libertyxdrIdentifier "\<[[:alpha:]][[:alnum:]_]*\>"
syn match libertyxdrNumber "\<0\>\|\(-\|\<\)[1-9][[:digit:]]*\>"
-syn keyword libertyxdrKeyword const enum struct union switch case
+syn keyword libertyxdrKeyword const enum struct union switch case default
syn keyword libertyxdrType bool u8 u16 u32 u64 i8 i16 i32 i64 string void
let b:current_syntax = "libertyxdr"