]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Allow setting the WM_CLASS X window property as a configuration option
authorSimon Tatham <anakin@pobox.com>
Sat, 15 Jan 2011 11:39:44 +0000 (11:39 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 15 Jan 2011 11:39:44 +0000 (11:39 +0000)
in saved sessions, so that a programmable window manager can
distinguish different PuTTYs/pterms on startup and assign them
different window management properties.

[originally from svn r9078]

putty.h
settings.c
unix/gtkcfg.c
unix/gtkwin.c

diff --git a/putty.h b/putty.h
index 0d14c50280a2b732f38d24958ad7ea4c286922df..9fddcae6a8a83074d98d6a07e0da273dc9503763 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -626,6 +626,7 @@ struct config_tag {
     FontSpec wideboldfont;
     int shadowboldoffset;
     int crhaslf;
+    char winclass[256];
 };
 
 /*
index 5ba034d0ce6fda189d78eff6e9dbdbc28b832884..82b915a918267cca810a51fa842e0de36b98fe00 100644 (file)
@@ -499,6 +499,7 @@ void save_open_settings(void *sesskey, Config *cfg)
     write_setting_i(sesskey, "SerialStopHalfbits", cfg->serstopbits);
     write_setting_i(sesskey, "SerialParity", cfg->serparity);
     write_setting_i(sesskey, "SerialFlowControl", cfg->serflow);
+    write_setting_s(sesskey, "WindowClass", cfg->winclass);
 }
 
 void load_settings(char *section, Config * cfg)
@@ -858,6 +859,7 @@ void load_open_settings(void *sesskey, Config *cfg)
     gppi(sesskey, "SerialStopHalfbits", 2, &cfg->serstopbits);
     gppi(sesskey, "SerialParity", SER_PAR_NONE, &cfg->serparity);
     gppi(sesskey, "SerialFlowControl", SER_FLOW_XONXOFF, &cfg->serflow);
+    gpps(sesskey, "WindowClass", "", cfg->winclass, sizeof(cfg->winclass));
 }
 
 void do_defaults(char *session, Config * cfg)
index 00e88b40da62f2af69bcd6d77c438ce439f8c39e..8cbdd514aa40faf300a1b22543ffa794ad90905f 100644 (file)
@@ -127,4 +127,18 @@ void gtk_setup_config_box(struct controlbox *b, int midsession, void *win)
                  HELPCTX(translation_utf8_override),
                  dlg_stdcheckbox_handler,
                  I(offsetof(Config,utf8_override)));
+
+    if (!midsession) {
+        /*
+         * Allow the user to specify the window class as part of the saved
+         * configuration, so that they can have their window manager treat
+         * different kinds of PuTTY and pterm differently if they want to.
+         */
+        s = ctrl_getset(b, "Window/Behaviour", "x11",
+                        "X Window System settings");
+        ctrl_editbox(s, "Window class name:", 'z', 50,
+                     HELPCTX(no_help), dlg_stdeditbox_handler,
+                     I(offsetof(Config,winclass)),
+                     I(sizeof(((Config *)0)->winclass)));
+    }
 }
index d08dffd41df27f6c5998876c2ae885d123b318b9..e4af62803f42432835ebdba99cca36c7ea91c121 100644 (file)
@@ -3430,6 +3430,9 @@ int pt_main(int argc, char **argv)
     init_cutbuffers();
 
     inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    if (inst->cfg.winclass[0])
+        gtk_window_set_wmclass(GTK_WINDOW(inst->window),
+                               inst->cfg.winclass, inst->cfg.winclass);
 
     /*
      * Set up the colour map.