Re: [dwm] dual-head and floats on all tags (and one feature request)

From: Guillaume Quintin <coincoin169g_AT_gmail.com>
Date: Thu, 23 Apr 2009 22:10:05 +0200

For the multihead, you can try my patch (even if it is not really the
same than having floating windows on the second screen)

Basically, my patch stores all the informations on all detected monitors
in a table. There are two functions :

win2mon : moves the selected client to the monitor number arg->i. The
client becomes floating, and visible on all tags (I find this useful but
you can remove it)

win2main : moves the selected client back to the tag arg->ui and make it
tiled.

It is up to you to configure your keys in your config.h.

For the urgent hint patch I think that you can do the patch on your own,
I'll be interested in it. If I have time tomorrow I will give it a try
unless someone gives it before.

-- 
Kind regards
Guillaume Quintin

--- dwm.c.orig 2009-04-18 13:49:24.000000000 +0200
+++ dwm.c 2009-04-20 00:49:20.971772171 +0200
@@ -127,6 +127,11 @@
         Bool isfloating;
 } Rule;
 
+/* struct to store other monitors info */
+typedef struct {
+ int wx,wy,ww,wh;
+} Monitor;
+
 /* function declarations */
 static void applyrules(Client *c);
 static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h);
@@ -203,6 +208,8 @@
 static int xerrordummy(Display *dpy, XErrorEvent *ee);
 static int xerrorstart(Display *dpy, XErrorEvent *ee);
 static void zoom(const Arg *arg);
+void win2mon(const Arg *);
+void win2main(const Arg *);
 
 /* variables */
 static char stext[256];
@@ -210,6 +217,7 @@
 static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */
 static int by, bh, blw; /* bar geometry y, height and layout symbol width */
 static int wx, wy, ww, wh; /* window area geometry x, y, width, height, bar excluded */
+Monitor *monitors;int nb_mon; /* the other monitors */
 static unsigned int seltags = 0, sellt = 0;
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static unsigned int numlockmask = 0;
@@ -1501,21 +1509,35 @@
         int n, i = 0;
         XineramaScreenInfo *info = NULL;
 
+ if ( monitors ) { free(monitors); }
+
         /* window area geometry */
- if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
- if(n > 1) {
- int di, x, y;
- unsigned int dui;
- Window dummy;
- if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
- for(i = 0; i < n; i++)
- if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
- break;
+ if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n)))
+ {
+ nb_mon = n - 1;
+ monitors = malloc(n * sizeof(Monitor));
+ if ( !monitors ) { die("Not enough memory for monitors' informations."); }
+
+ int di, x, y;
+ unsigned int dui;
+ Window dummy;
+ if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
+ {
+ for(i = 0; i < n; i++)
+ {
+ if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
+ {
+ wx = info[i].x_org;
+ wy = showbar && topbar ? info[i].y_org + bh : info[i].y_org;
+ ww = info[i].width;
+ wh = showbar ? info[i].height - bh : info[i].height;
+ }
+ monitors[i].wx = info[i].x_org;
+ monitors[i].wy = info[i].y_org;
+ monitors[i].ww = info[i].width;
+ monitors[i].wh = info[i].height;
+ }
                 }
- wx = info[i].x_org;
- wy = showbar && topbar ? info[i].y_org + bh : info[i].y_org;
- ww = info[i].width;
- wh = showbar ? info[i].height - bh : info[i].height;
                 XFree(info);
         }
         else
@@ -1682,6 +1704,23 @@
         arrange();
 }
 
+void win2mon(const Arg *arg)
+{
+ if ( arg->i > nb_mon || !sel ) { return; }
+ Monitor *m = &monitors[arg->i];
+ sel->tags = ~0;
+ sel->isfloating = 1;
+ resize(sel,m->wx,m->wy,m->ww - 2 * sel->bw,m->wh - 2 * sel->bw);
+ arrange();
+}
+
+void win2main(const Arg *arg)
+{
+ if ( !sel ) { return; }
+ sel->isfloating = 0;
+ tag(arg);
+}
+
 int
 main(int argc, char *argv[]) {
         if(argc == 2 && !strcmp("-v", argv[1]))
Received on Thu Apr 23 2009 - 20:10:05 UTC

This archive was generated by hypermail 2.2.0 : Thu Apr 23 2009 - 20:12:04 UTC