Window gets moved to the wrong location when changing screen resolution
Window gets moved to the wrong location when changing screen resolution
- Subject: Window gets moved to the wrong location when changing screen resolution
- From: "Mills, Steve" <email@hidden>
- Date: Thu, 22 May 2014 21:27:08 +0000
- Thread-topic: Window gets moved to the wrong location when changing screen resolution
Our app has a bunch of palettes (NSPanels). One of them is usually flush against the menubar and against the left edge of the monitor. These palettes have setMovable:NO set on them, because we needed to handle moving them ourselves so they will snap into place. When the screen res changes, we also need to handle that, since having movable set to NO means Cocoa tries to keep them locked to the bottom edge instead of the top (hence, they don't "move" in Cocoa's weird bottom-up coordinate space, but to the user's normal top-down coordinate space, they DO move).
In my case, I'm running on an external monitor on the right (main screen), and my MacBook Pro's monitor on the left. That puts this palette up against the menubar and snapped to the left edge of the right monitor (x is 0). If I then change the right monitor's resolution to a smaller size, the palette gets a setFrame:display message, giving the same rect that it was at before. This in turn calls constrainFrameRect:toScreen: to make sure the window will still be onscreen now that the screen is smaller, but the rect that gets returned from the default implementation has it moved -40 in the x direction. It shouldn't be moving it in that direction at all! Here's the stack. Note that [SnappyPalette constrainFrameRect:toScreen:] does nothing in this case but call the super, which is NSPanel.
Note that if I swap the arrangement of the screens (MBP on right, external on left) and set the MBP screen to be the main screen, it doesn't do this. I'm also running with that goofy Displays Have Separate Spaces turned OFF. I'm running 10.9.3. Bug? Is there a workaround?
#0 0x01204e2b in -[SnappyPalette constrainFrameRect:toScreen:] at /depot/Finale_Main/FinaleDev/Finale/SRC/FIN/MAC/Cocoa/Palettes/SnappyPalette.mm:96
#1 0x968c6190 in -[NSWindow _overrideDefeatingConstrainFrameRect:toScreen:] ()
#2 0x961cdb77 in -[NSWindow _oldPlaceWindow:] ()
#3 0x961cd4ac in -[NSWindow _setFrameCommon:display:stashSize:] ()
#4 0x961cce4a in -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] ()
#5 0x961ccd12 in -[NSWindow setFrame:display:] ()
#6 0x01204fdd in -[SnappyPalette setFrame:display:] at /depot/Finale_Main/FinaleDev/Finale/SRC/FIN/MAC/Cocoa/Palettes/SnappyPalette.mm:106
#7 0x968be2b8 in -[NSWindow _adjustWindowToScreen] ()
#8 0x968be6c3 in -[NSWindow _displayChanged] ()
#9 0x90a74262 in -[NSObject performSelector:] ()
#10 0x963516d5 in __44-[NSApplication makeWindowsPerform:inOrder:]_block_invoke ()
#11 0x9609fe66 in -[NSApplication _findWindowInOrder:passingTest:] ()
#12 0x9609fc95 in -[NSApplication makeWindowsPerform:inOrder:] ()
#13 0x96461c81 in -[NSApplication _reactToDisplayChanged:resetScreens:] ()
#14 0x962525a2 in -[NSApplication sendEvent:] ()
#15 0x00574449 in -[FCApplication sendEvent:] at /depot/Finale_Main/FinaleDev/Finale/SRC/FIN/MAC/Cocoa/FCApplication.mm:145
#16 0x960971dc in -[NSApplication run] ()
#17 0x96080018 in NSApplicationMain ()
#18 0x00002dca in main at /depot/Finale_Main/FinaleDev/Finale/SRC/FIN/MAC/CocoaShell/main.mm:32
--
Steve Mills
office: 952-818-3871
home: 952-401-6255
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden