]> 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 120e495df49c650856251a785e9716acf90d6a39..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 *);
@@ -156,7 +156,7 @@ static void xresize(int, int);
 static void xhints(void);
 static int xloadcolor(int, const char *, Color *);
 static int xloadfont(Font *, FcPattern *);
-static void xloadfonts(char *, double);
+static void xloadfonts(const char *, double);
 static void xunloadfont(Font *);
 static void xunloadfonts(void);
 static void xsetenv(void);
@@ -387,7 +387,9 @@ mousereport(XEvent *e)
                        button = 3;
                } else {
                        button -= Button1;
-                       if (button >= 3)
+                       if (button >= 7)
+                               button += 128 - 7;
+                       else if (button >= 3)
                                button += 64 - 3;
                }
                if (e->xbutton.type == ButtonPress) {
@@ -797,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)
 {
@@ -950,7 +965,7 @@ xloadfont(Font *f, FcPattern *pattern)
 }
 
 void
-xloadfonts(char *fontstr, double fontsize)
+xloadfonts(const char *fontstr, double fontsize)
 {
        FcPattern *pattern;
        double fontval;
@@ -958,7 +973,7 @@ xloadfonts(char *fontstr, double fontsize)
        if (fontstr[0] == '-')
                pattern = XftXlfdParse(fontstr, False, False);
        else
-               pattern = FcNameParse((FcChar8 *)fontstr);
+               pattern = FcNameParse((const FcChar8 *)fontstr);
 
        if (!pattern)
                die("can't open font %s\n", fontstr);
@@ -1586,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);
@@ -1599,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);