Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/cocoa/nswindow_local_state.mm

Issue 536086: Mac: Save/restore task manager window pos and size. (Closed)
Patch Set: comments Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6 #include "chrome/common/pref_service.h"
7
8 @implementation NSWindow (LocalStateAdditions)
9
10 - (void)saveWindowPositionToPrefs:(PrefService*)prefs
11 withPath:(const wchar_t*)path {
12 DCHECK(prefs);
13 // Save the origin of the window.
14 DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path);
15 NSRect frame = [self frame];
16 windowPrefs->SetInteger(L"x", frame.origin.x);
17 windowPrefs->SetInteger(L"y", frame.origin.y);
18 }
19
20 - (void)restoreWindowPositionFromPrefs:(PrefService*)prefs
21 withPath:(const wchar_t*)path {
22 DCHECK(prefs);
23 // Get the positioning information.
24 DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path);
25 int x = 0, y = 0;
26 windowPrefs->GetInteger(L"x", &x);
27 windowPrefs->GetInteger(L"y", &y);
28 // Turn the origin (lower-left) into an upper-left window point.
29 NSPoint upperLeft = NSMakePoint(x, y + [self frame].size.height);
30 NSPoint cascadePoint = [self cascadeTopLeftFromPoint:upperLeft];
31 // Cascade again to get the offset when opening new windows.
32 [self cascadeTopLeftFromPoint:cascadePoint];
33 // Force a save of the pref.
34 [self saveWindowPositionToPrefs:prefs withPath:path];
35 }
36
37 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698