What controls saved/default window sizes and positions in OS X?

4

2

I am running both Chrome and Chromium on my Mac. I never notice a problem with Chrome but with Chromium it always seems to start off in a very odd and much too small size and position on the screen.

I know there are some good utilities for window management , but what controls the default size / position of windows in OS X?

image

cwd

Posted 2012-02-23T16:32:09.950

Reputation: 13 508

FYI - Chrome has command line switches you can use to set the window size and position: --window-position=x,y and --window-size=w,h

– cwd – 2012-06-22T23:01:13.710

Answers

3

It depends on the program. Most of these "main" window settings (or, more precisely, "document" window settings) are sort of hardcoded. I believe they use what Apple provides in their window management frameworks, like for example Preview.app.

For most apps, only the NSWindow properties of auxiliary windows are stored in the program's Property Lists, while the document window settings may be stored somewhere else. This is what Chrome does, since it is cross-platform and uses a shared preferences format across multiple computers.


For example, com.macromates.textmate.plist has the following entry:

NSWindow Frame New File Sheet
568 932 386 209 0 0 1920 1178

You can change these, and I believe they use rectangle coordinates and origins for representation, the first four values being the NSRect:

  • top left X coordinate
  • top left Y coordinate
  • width
  • height

TextMate does store its main window position under OakDocumentWindowFrame, but as I already mentioned, this is not the case for all document-based applications.


Google Chrome uses its own way of dealing with this, namely in a JSON file. It has a window_placement setting, and you can find it in:

~/Library/Application Support/Google/Chrome/Default/Preferences

Here's what it looks like:

"window_placement": {
         "always_on_top": false,
         "bottom": 1046,
         "left": 0,
         "maximized": false,
         "right": 1680,
         "top": 22,
         "work_area_bottom": 1046,
         "work_area_left": 0,
         "work_area_right": 1680,
         "work_area_top": 22
      },

slhck

Posted 2012-02-23T16:32:09.950

Reputation: 182 472

Looking at ~/Library/Preferences/com.google.Chrome.plist and I don't see too much helpful info. Post updated with screenshot... – cwd – 2012-02-23T17:02:44.903

@cwd Read this answer again, it only mentions auxiliary windows, like inspectors. – Daniel Beck – 2012-02-23T17:25:47.300

@DanielBeck So am I right that most applications will not use Preference Lists for storing document window properties, but resort to their own settings (like Chrome does)? Couldn't find a reference for this. – slhck – 2012-02-23T17:31:57.567

1@slhck You're mostly right, from what I can tell. Here's what I think: Inspectors (like fonts dialog, open/save dialogs, etc.) are handled by the system frameworks and just add their preferences to the application's .plist. Application authors are free to store this somewhere else (like the cross-platform Chrome does with the JSON file you found), or also in the .plist, like e.g. Safari (grep for NSWindow Frame BrowserWindowFrame) or Terminal (grep for NSWindow Frame $ProfileName, e.g. NSWindow Frame TTWindow Basic) do. Programs without defaults (e.g. Preview) can just skip this. – Daniel Beck – 2012-02-23T17:39:15.223

Note that TextMate does store the window position and size in the .plist, as OakDocumentWindowFrame. – Daniel Beck – 2012-02-23T17:45:26.893

1AFAIK, no window size/positions used to be saved at all by default. The developer has to add a unique autosaveName value for the NSWindow (or NSPanel) in the nib file, or programmatically at runtime. This string value is what's used after the NSWindow Frame part: like BrowserWindowFrame. If no autosaveName is set, no information is saved for that window. Not exactly sure how NSDocument-based windows are handled WRT autosaveName. Note that the new Lion restore feature may potentially allow windows to be saved even if theres no autosaveNames set for the windows in question (not sure). – NSGod – 2012-02-24T22:26:47.150