GNOME Bugzilla – Bug 304763
A way to change the default window placement policy
Last modified: 2008-06-13 18:01:46 UTC
I've searched in internet and into GConf ("/apps/metacity" entry) for a way to change the default placement polity for windows that don't tell a position to the window manager. But I've found nothing. Is there any way to change the default window placement policy? A very useful policy is to center the window (if the application doesn't tell any position). It's easy to implement, and easy to add to the configuration tools ("gnome-window-properties" tool). And would be very very useful for many users (like me) that want windows to be centered by default (if the application doesn't tell any position). An example: I'm tired of having to center by hand the 2-5 windows of Terminal that I open every day. I don´t want they to appear in the left-up corner, I want them just in the center of the screen. Same for any new window, tool, etc that I open. Please implement it. It's easy and very useful.
Created attachment 48880 [details] [review] Patch to add new window-placement options: center, random, and cascade. I have a patch that applies against the Metacity 2.8 source that does what you want. It adds a GConf key ("/apps/metacity/general/placement_mode") that can be set to "first_fit" (the default), "random", "cascade" (like Windows and Mac OS), and "center" (what you're asking for). More info is here: http://home.uchicago.edu/~chad/metacity/ Note that I made this patch only for my own purposes, so I can't predict its limitations. In particular, I have no way of testing it with Xinerama.
Created attachment 48934 [details] [review] Window-placement options patch for Metacity 2.10 New patch for Metacity 2.10. It implements a GConf-configurable placement_mode option that can be "first_fit", "center", "origin", or "random". In this patch, I tried to be minimally invasive. Instead of calling find_first_fit() directly from meta_window_place(), I'm calling find_preferred_position() (my new function). If the user preference is still set to first_fit, then it just passes all the args on to find_first_fit(), which is unmodified. Otherwise, find_preferred_position() chooses the new window placement. None of this should affect the new focus-stealing-prevention stuff in meta_window_place(). Since I have no Xinerama system on which to test this, I tried to follow what was happening in find_first_fit() in hopes of implementing proper behavior, although I'm *not* proposing for this to to be merged into the official source. I removed the 'cascade' placement option that was in the old patch, because I did not see an obvious way of implementing it properly. Since I wanted to use existing Metacity code, I tried updating find_next_cascade() to work on a given xinerama, but somewhere else in the Metacity code, there are side-effects going on that I don't understand that are causing it not to behave as I expected. As a result, I chose to leave it alone.
Greeeeeeeeeaaaaaaaaaaat!!! ;-) Thank you very much. The patch will be useful for many people. I hope gnome guys to include it (or something equivalent) into metacity. How can we contact them? Will be they reading this thread? The rmp's you've done are very useful too. The only difficult step is to overwrite the old metacity rpm. This is the log of my installation: ------------------- # rpm -ivh metacity-2.8.6-3.i386.rpm Preparing... ########################################### [100%] file /etc/gconf/schemas/metacity.schemas from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/bin/metacity from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/bin/metacity-message from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/bin/metacity-theme-viewer from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/bin/metacity-window-demo from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/include/metacity-1/metacity-private/common.h from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/lib/libmetacity-private.a from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/lib/libmetacity-private.so.0.0.0 from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 file /usr/libexec/metacity-dialog from install of metacity-2.8.6-3 conflicts with file from package metacity-2.8.6-2 # # rpm -e metacity-2.8.6-2 error: Failed dependencies: libmetacity-private.so.0 is needed by (installed) control-center-2.8.0-12.i386 metacity is needed by (installed) ximian-doorman-1.99.29-0.ximian.6.3.i386 metacity is needed by (installed) firstboot-1.3.33-1.noarch metacity is needed by (installed) system-config-display-1.0.24-1.noarch # rpm -e metacity-2.8.6-2 --nodeps # # rpm -ivh metacity-2.8.6-3.i386.rpm Preparing... ########################################### [100%] 1:metacity ########################################### [100%] # ------------------- The key/value pair is easy to find in Gconf. A suggestion: in the "Long description" of the kay/value pair: ------------------- Metacity's original window-placement policy is first-fit, similar to the "smart" window-placement policies in some other window managers. It will try to tile windows so that they do not overlap. This is still the default behavior. Change this value to "random" to enable random window placement. Change it to "smart" or "first_fit" to change it back to the original/default method. ------------------- please, add the available values and their description. For example: ------------------- Available values: "first_fit" ("smart" is also accepted) This is the default Metacity window-placement behavior. In this mode, Metacity will attempt to tile new windows on the screen so that they do not overlap. "center" This option will cause Metacity to place each new window at the center of its workspace. "origin" In this mode, Metacity will simply place each new window at the origin (the upper-left corner) of its workspace. "random" In this mode, Metacity will choose a random position on the screen for a new window. ------------------- Great work! Hopping it to be included into gnome. Thanks!
Created attachment 49121 [details] [review] Window-placement options patch for Metacity 2.8 Your RPM problem is that you need to use the '-U' (upgrade) option, not '-i' (install). Explicitly, the command you want is this: 'rpm -Uvh metacity-2.8.6-3.i386.rpm' I updated the patch and the RPMs on my web site, (http://home.uchicago.edu/~chad/metacity/), including the 2.10 version patch, but I'm attaching the patch for Metacity 2.8 here, since that is the version for this bugzilla entry. I added the fuller help text from the 2.10 patch into the 2.8 patch. I put back the 'cascade' mode option, because somebody asked me for it, but it's not listed in the help text, because it's a cheap hack. It works correctly with multiple desktops on one screen, but it's highly unlikely to work correctly on multiple screens. I might go back and add 'cascade' to the help text with that caveat. --- As I mentioned before, this patch is *NOT* ready for consideration for the official source. For one thing, I don't currently have access to a multiscreen system on which to test this. Also, I wrote this patch to be minimally invasive to the existing code, and these features could be implemented better as part of a larger refactoring of the window-placement code. If somebody wanted these features to be an official part of Metacity, well, first you'd have to check with the maintainers and make sure they're not going to reject those features as "crackrock." Then, I think it would be necessary to find out what the consensus is on the best behavior for dealing with multiple screens and xineramas and for dealing with focus-stealing prevention. After those decisions are made, I think the placement code could be reworked to handle all these cases and features elegantly. ccg
Thanks Chad. I contacted one of the mantainers on tuesday. Waiting for his response... I don't know the meaning of "crackrock", but I suppose that, if the feature is very useful and saves time (and patience) for many people, it can be included. Thank you
It's considered too micromanagerial for Metacity (see bug 106239 comment 5 or bug 151818 comment 2) to have window placement options. However, we really do need to deal with a variety of issues with the current placement method (see bug 155460, though we probably don't have all relevant bugs tracked there) and this patch can be useful for testing out various ideas. I'll mark as a duplicate of bug 151818, but make a note of the patch in bug 155460. *** This bug has been marked as a duplicate of 151818 ***