Browse Source

Add x-wm-class and x-wm-class-name configuration variables (closes LP bug 1075555)

rdb 13 years ago
parent
commit
b04f8a5db8

+ 11 - 1
panda/src/x11display/config_x11display.cxx

@@ -1,5 +1,5 @@
 // Filename: config_x11display.cxx
-// Created by:  pro-rsoft (07Jul09)
+// Created by:  rdb (07Jul09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -61,6 +61,16 @@ ConfigVariableInt x_wheel_right_button
           "mouse button number does the system report when one scrolls "
           "to the right?"));
 
+ConfigVariableString x_wm_class_name
+("x-wm-class-name", "",
+ PRC_DESC("Specify the value to use for the res_name field of the window's "
+          "WM_CLASS property.  Has no effect when x-wm-class is not set."));
+
+ConfigVariableString x_wm_class
+("x-wm-class", "",
+ PRC_DESC("Specify the value to use for the res_class field of the window's "
+          "WM_CLASS property."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libx11display
 //  Description: Initializes the library.  This must be called at

+ 4 - 1
panda/src/x11display/config_x11display.h

@@ -1,5 +1,5 @@
 // Filename: config_x11display.h
-// Created by:  pro-rsoft (07Jul09)
+// Created by:  rdb (07Jul09)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -33,4 +33,7 @@ extern ConfigVariableInt x_wheel_down_button;
 extern ConfigVariableInt x_wheel_left_button;
 extern ConfigVariableInt x_wheel_right_button;
 
+extern ConfigVariableString x_wm_class_name;
+extern ConfigVariableString x_wm_class;
+
 #endif

+ 12 - 4
panda/src/x11display/x11GraphicsWindow.cxx

@@ -1077,13 +1077,21 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) {
   // Class to "Undecorated", and let the user configure his/her window
   // manager not to put a border around windows of this class.
   XClassHint *class_hints_p = NULL;
-  if (properties.get_undecorated() || properties.get_fullscreen()) {
+  if (!x_wm_class.empty()) {
+    // Unless the user wanted to use his own WM_CLASS, of course.
+    class_hints_p = XAllocClassHint();
+    class_hints_p->res_class = x_wm_class.c_str();
+    if (!x_wm_class_name.empty()) {
+      class_hints_p->res_name = x_wm_class_name.c_str();
+    }
+
+  } else if (properties.get_undecorated() || properties.get_fullscreen()) {
     class_hints_p = XAllocClassHint();
     class_hints_p->res_class = (char*) "Undecorated";
+  }
 
-    if (!properties.get_fullscreen()) {
-      type_data[next_type_data++] = _net_wm_window_type_splash;
-    }
+  if (properties.get_undecorated() && !properties.get_fullscreen()) {
+    type_data[next_type_data++] = _net_wm_window_type_splash;
   }
 
   if (properties.has_z_order()) {