Keywords: Metacity, Twinview, Xinerama, dual-display, dualdisplay, dual-view, dualview, window, placement, algorithm, patch, other screen, arghh, doh, dapper, edgy, 6.06, 6.10
HOWTO: Change Metacity/(Twinview/Xinerama) window placement behavior [Dapper, Edgy]
This HOWTO applies to 32 bit Dapper and 32 bit Edgy only
Hey everybody
First of all, what is this HOWTO for? This HOWTO can help solve your problem if you meet the following two criteria:
- You have a functional Twinview system, (no matter which graphics card) meaning that your desktop extends onto an other screen
- You are pulling your hair out because every time you open the second window on a desktop, this window automatically opens on the second monitor and that was NOT what you wanted it to
If you meet the criteria above, please read on.
The solution to this problem is a simple one line patch of the Metacity (the window management application in GNOME) source-code. This will change the behavior of the window placement algorithm so that it works like it did before EXCEPT that it will always open new windows on the same screen as the one the mouse is in.
Be aware: This patch is neither supported or encouraged by the Metacity development team, in fact they claim that it is wrong (see comment 12 in this thread), and I don't have any c-programming experience so that I can check it out for myself. So use it at your own risk That being said, it works fine for me and I haven't experienced any side-effects, plus, the place where I found the patch in the first place is a university that supplies the patched packages to all the users of a certain piece of software they develop, soooo it HAS been tested and is still in use there.
There are two ways to install this. The first one is to simple install the patched .deb's that I've supplied and the second, which is somewhat more "hands on", is to, download the source-code, place the patch, repackage and install the packages. Since I have now updated this for edgy also this guide now covers two different version of metacity, 2.14.5(Dapper) and 2.16.3(Edgy). Therefore the download commands are split in two and you are off course only meant to get the one that corresponds to your system. In the rest of the instructions I have just left them as they were for Dapper so here you have to replace the version with the right ones yourself. I hope this is clear. Here we go
Installing the .deb's I have made
If you don't want the trouble of patching yourself you can just use the packages I have made from the patched source-code. They have a slightly different version-number so they will install as an update to the current version of Metacity (2.14.5). This prevents apt to just replace them the next time you run update. But this also means that the next time there do come some new Metacity packages you will have to do this again. But no worries, it easy, it doesn't happen that often and I will keep supplying .deb's for the purpose. Enough talk already. To install simply do the following.
Code:
cd /to/whereever/you/keep/temporary/files
In Dapper do:
Code:
wget http://www.student.dtu.dk/~s021749/metacitydebs/metacity-2.14.5-0ubuntu2_i386.tar.gz
In Edgy do:
Code:
wget http://www.student.dtu.dk/~s021749/metacitydebs/metacity_2.16.3-0ubuntu3_i386.tar.gz
Then:
Code:
tar -xvzf metacity*.tar.gz
cd metacity*
sudo dpkg -i *.deb
That's it. Restart X, CTRL-ALT-BACKSPACE and we're done.
Patching the source-code and repackaging
First of all, the "apt-get install" command for dapper might be missing some packages, but for edgy it should be sufficient. Ok, download the patch and the source-code, and install the extra packages we need.
Code:
cd /to/whereever/you/keep/temporary/files
Now in Dapper do:
Code:
wget http://www.student.dtu.dk/~s021749/metacitydebs/2.14.5_i386/021-twinview-modification.patch
sudo apt-get install devscripts fakeroot cdbs debhelper liborbit2-dev libpopt-dev libxml2-dev libgconf2-dev libglade2-dev libstartup-notification0-dev libxml-parser-perl gnome-pkg-tools
In Edgy do:
Code:
wget http://www.student.dtu.dk/~s021749/metacitydebs/2.16.3_i386/021-twinview-modification.patch
sudo apt-get install devscripts fakeroot cdbs debhelper libgtk2.0-dev liborbit2-dev libpopt-dev libxml2-dev libgconf2-dev libglade2-dev libice-dev libsm-dev libx11-dev libxt-dev libxext-dev libxinerama-dev libxrandr-dev x-dev libxinerama-dev libstartup-notification0-dev gnome-pkg-tools
Then:
Code:
apt-get source metacity
That was the download. So now we copy the patch into it's right place and edit the change-log so the new package will work like an update.
Code:
cd metacity-2.14.5/
cp ../021-twinview-modification.patch debian/patches/
debchange -i
Now an editor should pop up. Here you can add a change log entry. It's not necessary as it has already automatically created the one important line that describes the new version so you can just save and exit. But if you want to you can add something. This is the entry I added in the ready-made .deb's:
Code:
metacity (1:2.14.5-0ubuntu2) dapper-updates; urgency=low
* debian/patches/021-twinview-modification.patch
- Keeps newly opened windows on the same twinview display
as the mouse is on
-- Kenneth Nielsen <k.nielsen81@gmail.com> Mon, 21 Aug 2006 15:29:38 +0200
Now all we need to do is to repackage and install
Code:
fakeroot dpkg-buildpackage -us -uc
sudo dpkg -i ../*.deb
That's it.
My story:
Ok so if you are still not sure about the reason for installing this, here is a description of my system and the way I use, maybe it'll clear it up.
My second monitor is the television. What I wanted from this setup is to be able to watch movies from my computer on the television, so that when I wanted to watch a movie I could open a movies player an drag it to the television and blow it up to full-screen. This also means that I NEVER want anything to open on the television per default, I'll drag whatever need to go there myself. This is however not possible because Metacity will always place a new window where there is more space, until is has all been used, then another algorithm kicks in. So after I got the Twinview setup to work, I would constantly have to drag windows from the television, which is a real pain in the.....
Credits
- ookami from the forum, for encouraging me to snope around to find a solution to this problem, and has also tested it
- Christoph Willing from the University of Queensland. He supplied the patch and pointed me in direction of Klaus Reimer's website
- Klaus Reimer. On his website there is a extensive guide about this patch and some other ATI stuff for Breezy. In fact this HOWTO is largely based on this page
- The guys at #ubuntu-motu for answering some of all my newbie questions about repackaging
Please give me feedback. I would very much like to know, of course, if something doesn't work, but also, please write a post, if you used it and it worked just fine, so that I can see how many has this problem.
Bookmarks