repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 63ce725d31d1949742d3a0f47be3f108d1d68ea3:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 63ce725d31d1949742d3a0f47be3f108d1d68ea3
Author: Marc Lehmann 
Date:   Thu Jun 7 16:04:31 2012 +0000

    visual selection

diff --git a/Changes b/Changes
index 46823ea85d9d4f1cfa0de212a47d5b5f3e3835e1..
index ..46f1bc4c102a2edbf9947285cb3009698431146f 100644
--- a/Changes
+++ b/Changes
@@ -56,6 +56,8 @@ TODO: description into --help output?
         - iso14755 51 mode window now displays row and column.
         - perl extensions can now provide commandline switches and resources
           which show up in -help etc.
+        - implement a -visual switch and move that and -depth to frills, also
+          warn when we can't get the requested visual.

 9.15 Sat Jan 21 13:36:56 CET 2012
 	- remove "using namespace std" because clang erroneously
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod
index ccad5825d3eff6c2af050f354b3c7821b93e5bff..
index ..22ba206a62d3bd6f615b1eec0fa9590e9f9ae3c5 100644
--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -2438,6 +2438,7 @@ in combination with other switches) is:
   skip builtin block graphics (-sbg)
   separate highlight colour (-highlightColor, -highlightTextColor)
   extended mouse reporting modes (1005 and 1015).
+  visual selection via -visual and -depth.

 It also enables some non-essential features otherwise disabled, such as:

diff --git a/src/init.C b/src/init.C
index 052a6cad302a9c37eb9f1a75e93acf76b8dc2b3a..
index ..db373a1348a75243b0d618ba61787af5d656e4a8 100644
--- a/src/init.C
+++ b/src/init.C
@@ -590,9 +590,11 @@ rxvt_term::init_resources (int argc, const char *const *argv)
   set (display);
   extract_resources ();

-#if XFT
-  if (rs[Rs_depth])
-    select_visual (strtol (rs[Rs_depth], 0, 0));
+#if ENABLE_FRILLS
+  if (rs[Rs_visual])
+    select_visual (strtol (rs[Rs_visual], 0, 0));
+  else if (rs[Rs_depth])
+    select_depth (strtol (rs[Rs_depth], 0, 0));
 #endif

   for (int i = NUM_RESOURCES; i--; )
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C
index 5831f84f46d5a88f217bb135730d98f22c84ec35..
index ..86d62dc607e644bc81b0ef0b65b5a29cb193aca3 100644
--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -262,21 +262,41 @@ rxvt_screen::set (rxvt_display *disp)
   cmap    = DefaultColormapOfScreen (screen);
 }

+#if ENABLE_FRILLS
+
 void
-rxvt_screen::select_visual (int bitdepth)
+rxvt_screen::select_visual (int id)
 {
-#if XFT
   XVisualInfo vinfo;
+  vinfo.visualid = id;
+  int n;

-  if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo))
+  if (XVisualInfo *vi = XGetVisualInfo (dpy, VisualIDMask, &vinfo, &n))
     {
-      depth  = bitdepth;
-      visual = vinfo.visual;
-      cmap   = XCreateColormap (dpy, display->root, visual, AllocNone);
+      depth  = vi->depth;
+      visual = vi->visual;
+
+      XFree (vi);
+
+      cmap = XCreateColormap (dpy, display->root, visual, AllocNone);
     }
-#endif
+  else
+    rxvt_warn ("cannot requested visual id 0x%02x, using default visual.\n", id);
+}
+
+void
+rxvt_screen::select_depth (int bitdepth)
+{
+  XVisualInfo vinfo;
+
+  if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo))
+    select_visual (vinfo.visualid);
+  else
+    rxvt_warn ("no visual found for requested depth %d, using default visual.\n", bitdepth);
 }

+#endif
+
 void
 rxvt_screen::clear ()
 {
diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h
index d7a53218c0ba10258f9034a2f2e5ac5aa3a6de1d..
index ..ebb2d0a8d1d907da84bbbec8f5e48e1653d01e3c 100644
--- a/src/rxvttoolkit.h
+++ b/src/rxvttoolkit.h
@@ -214,7 +214,8 @@ struct rxvt_screen
 #endif

   void set (rxvt_display *disp);
-  void select_visual (int bitdepth);
+  void select_visual (int id);
+  void select_depth (int bitdepth); // select visual by depth
   void clear ();
 };

-----END OF PAGE-----