]> Sergey Matveev's repositories - st.git/blobdiff - x.c
Add support for OSC color sequences
[st.git] / x.c
diff --git a/x.c b/x.c
index 718604067917b7b470a1618cedc72da379ebee37..8a16faaad0f09a0ceae0faa436fc08593e8df2a4 100644 (file)
--- a/x.c
+++ b/x.c
@@ -48,7 +48,7 @@ typedef struct {
 /* X modifiers */
 #define XK_ANY_MOD    UINT_MAX
 #define XK_NO_MOD     0
-#define XK_SWITCH_MOD (1<<13)
+#define XK_SWITCH_MOD (1<<13|1<<14)
 
 /* function definitions used in config.h */
 static void clipcopy(const Arg *);
@@ -799,6 +799,19 @@ xloadcols(void)
        loaded = 1;
 }
 
+int
+xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
+{
+       if (!BETWEEN(x, 0, dc.collen))
+               return 1;
+
+       *r = dc.col[x].color.red >> 8;
+       *g = dc.col[x].color.green >> 8;
+       *b = dc.col[x].color.blue >> 8;
+
+       return 0;
+}
+
 int
 xsetcolorname(int x, const char *name)
 {
@@ -1588,8 +1601,9 @@ xseticontitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
-       Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
-                       &prop);
+       if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+                                       &prop) != Success)
+               return;
        XSetWMIconName(xw.dpy, xw.win, &prop);
        XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
        XFree(prop.value);
@@ -1601,8 +1615,9 @@ xsettitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
-       Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
-                       &prop);
+       if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+                                       &prop) != Success)
+               return;
        XSetWMName(xw.dpy, xw.win, &prop);
        XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
        XFree(prop.value);