Rss

Archives for : Linux

metacity, and focus theft

The version of metacity that ships with Debian Sarge has all of the focus theft prevention code disabled entirely, meaning that every new window ever created steals (or is given, however you want to put it) focus. I’ve spent quite a while this morning trying to figure out how to disable this behavior, finding nothing, except a few discussions where people said they disliked this behavior.

Unable to find any information about this on Google, I consulted the source, and found:
window.c:
case META_WINDOW_NORMAL:
case META_WINDOW_DIALOG:
case META_WINDOW_MODAL_DIALOG:
/* Disable the focus-stealing-prevention stuff for now; see #149028 */
return TRUE;

The bug in question, Bug 149028 – Focus stealing bugs roundup is currently not assigned to any developers (status: NEW). It seems like most of the discussion there is about how to get window focus to work the way the user expects it to — ie the way they think the user expects it to, and not to provide ways for the user to decide for themselves how they want it handled. This is the type of thing I expect from Microsoft or other commercial software, but not from Open Source software.

Anyway, the goal of this post is to get a solution out there so others in my predicament can control their window manager behavior. Power to the people, and all that.

Here’s a replacement metacity package (2.8.8_1_dpk) which adds the following keys (as can be viewed in gconf-editor):

/apps/metacity/general/focus_new_dialog_window
/apps/metacity/general/focus_new_normal_window
/apps/metacity/general/focus_new_modal_dialog_window

They default to true. Changing them to false gives you the correct..ahem..the behavior I was originally looking for. dpkg -i metacity_2.8.8_1_dpk_i386.deb will install this, and then you just have to kill the current metacity process. Gnome will restart it, at least in the default configuration.

In case you’re curious, here’s the patch against the metacity-2.8.8 directoroy that comes with Debian Sarge stable (ie, run apt-get source metacity, put this 001_dpk_focus_toggle.diff patch in metacity-2.8.8/debian/patches, and run ./debian/rules build, and away you go). If it matters I’m releasing the patch under the I don’t care what you do with it license.

Footnote: I recognize this is not the optimal solution for everyone. I just know I can’t stand having windows take over focus under any circumstances. I’m not even sure this covers every case — maybe applications can force focus theft. So, no guarantees or anything.

Edited: I was probably a bit too harsh above. I recognize that these are open source volunteer projects that I often complain about. It just doesn’t seem to me that a year of discussion (or multiple years of nothing as is the case with many FreeBSD bugs) can result in a solution. This is where leadership could step in and state “This is how it’s going to be”, and then just get it done. Open source is about choice — if the users don’t end up liking how it was done, they could change it later on, but at least these bugs won’t be sitting around effectively idle.

less, screen, vi driving you nuts?

Moving from FreeBSD to Linux, another issue that came up is that apparently Linux’s default terminal information allows the use of the “alternate screen buffer” from vt102 or some such thing. This is what causes less and vi to clear the screen when you exit, screen to not allow you to use xterm’s scrollback buffer, and other such anti-user things that really ought to be disabled by default. (Hell if I wanted that enabled, I’d just run the programs in their own xterm, so when I exit they just disappear completely).

The solution that works for me can be found here:

Exorcising the Evil Alternate Screen

Specifically, I added the line to .Xdefaults, and ran xrdb as specified, and that took care of it. The terminfo stuff at the end of the page didn’t work, but that might just be because I’m using Debian instead of another distro (maybe some look in $HOME/terminfo by default, who knows).

Debian Sarge, lynx, 400, google

and I have trouble getting the X server to see the right amount of video memory. It turns out it’s because the default Dell Dimension 3000 BIOS options only allocate 1MB to the video card, rather than the extremely beefy 8MB(!!). Anyways..

At 1MB of video RAM you are pretty much stuck with a max of 640×480 and 16 bit color. I wasn’t too interested in trying a graphical browser in such a small space, so I went to the old standby, lynx. A quick “aptitude install lynx” and I’m ready, right?

$ lynx http://www.google.com/
Alert!: HTTP/1.0 400 Bad Request
   Google
            Error
                                  Bad Request

     Your client has issued a malformed or illegal request.

What the hell? I try all sorts of things, eventually running “strace -s65536 lynx” to figure out what it is sending. Here’s what I found:


write(3, "GET / HTTP/1.0rnHost: www.google.comrnAccept: text/html, text/plain, application/vnd.sun.xml.calc, application/vnd.sun.xml.calc.template, application/vnd.sun.xml.draw, application/vnd.sun.xml.draw.template, application/vnd.sun.xml.impress, application/vnd.sun.xml.impress.templaternAccept: application/vnd.sun.xml.writer, application/vnd.sun.xml.writer.global, application/vnd.sun.xml.writer.math, application/vnd.sun.xml.writer.template, application/x-archive, application/x-bzip, application/x-gzip, application/x-lharnAccept: application/x-lzop, application/x-rar, application/x-tar, application/x-tarz, application/x-tbz, application/x-tgz, application/x-tzo, application/x-zip, application/x-zoo, application/pdf, application/x-shellscript, text/english, text/x-c++rnAccept: text/x-c++hdr, text/x-c++src, text/x-c, text/x-chdr, text/x-csrc, text/x-java, text/x-makefile, text/x-moc, text/x-pascal, text/x-tcl, text/x-tex, application/x-deb, application/x-rpm, application/x-dia-diagramrnAccept: application/x-bzip-compressed-tar, application/x-compress, application/x-compressed-tar, application/x-java-archive, application/x-stuffit, application/ghostview, application/postscript, application/x-gnumeric, text/comma-separated-valuesrnAccept: application/vnd.ms-excel, application/x-applix, application/x-troff-man, image/avs, image/bie, image/x-ms-bmp, image/cmyk, image/dcx, image/eps, image/fax, image/fits, image/gif, image/gray, image/gradation, image/hdf, image/jpeg, image/pjpegrnAccept: image/map, image/miff, image/mono, image/mtv, image/x-portable-bitmap, image/pcd, image/pcx, image/pdf, image/x-portable-graymap, image/pict, image/png, image/x-portable-anymap, image/x-portable-pixmap, image/ps, image/rad, image/x-rgbrnAccept: image/rgba, image/rla, image/rle, image/sgi, image/sun-raster, image/targa, image/tiff, image/uyvu, image/vid, image/viff, image/x-xbitmap, image/x-xpixmap, image/x-xwindowdump, image/yuv, image/svg+xml, image/svg, image/fax-g3, image/x-epsrnAccept: image/x-jng, image/x-xbm, video/x-mng, image/bmp, image/x-xpm, text/xml, application/x-ogg, application/ogg, audio/mpeg, audio/x-mpegurl, audio/x-ms-wax, audio/x-ms-wma, audio/x-pls, audio/x-scpls, audio/x-wav, video/mpeg, video/quicktimernAccept: video/x-mpeg2, video/x-mpeg, video/x-ms-afs, video/x-ms-asf, video/x-msvideo, video/x-ms-wma, video/x-ms-wmv, video/x-ms-wmx, video/x-ms-wvx, audio/mpegurl, audio/x-mp2, audio/x-mp3, application/x-staroffice, application/vnd.stardivision.calcrnAccept: application/vnd.stardivision.chart, application/vnd.stardivision.draw, application/vnd.stardivision.impress, application/vnd.stardivision.math, application/vnd.stardivision.writer-global, application/vnd.stardivision.writer, audio/x-mpegrnAccept: application/x-flac, application/x-gtar, audio/x-ogg, application/x-dvi, application/msword, application/mspowerpoint, application/vnd.ms-word, application/vnd.ms-powerpoint, application/rtf, application/x-msword, application/x-msexcelrnAccept: application/x-mspowerpoint, application/wordperfect, application/wordperfect5.1, application/vnd.wordperfect, application/x-abiword, text/abiword, text/richtext, text/rtf, text/*, application/x-debian-package, audio/basic, */*;q=0.01rnAccept-Encoding: gzip, compressrnAccept-Language: enrnUser-Agent: Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.0.16rnrn", 3348) = 3348

This is from a stock Sarge install, with nothing more added than lynx, epic4, screen, and a couple of small programs. I’m not sure why Lynx would feel the need to send all of that, by default. :) Anyways, if you get this error, here’s the fix:

DISPLAY= lynx http://www.google.com/

(mind the gap)