1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

Minor SystemTrayIconComponent tweak to keep OSX10.3 builds happy.

This commit is contained in:
jules 2015-04-13 16:07:44 +01:00
parent 45a0cf35ab
commit c1355fa11a

View file

@ -45,6 +45,8 @@ public:
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: NSSquareStatusItemLength] retain];
[statusItem setView: view];
SystemTrayViewClass::frameChanged (view, SEL(), nullptr);
[[NSNotificationCenter defaultCenter] addObserver: view
selector: @selector (frameChanged:)
name: NSWindowDidMoveNotification
@ -134,9 +136,9 @@ private:
[statusIcon setSize: NSMakeSize (20.0f, 20.0f)];
}
struct SystemTrayViewClass : public ObjCClass <NSControl>
struct SystemTrayViewClass : public ObjCClass<NSControl>
{
SystemTrayViewClass() : ObjCClass <NSControl> ("JUCESystemTrayView_")
SystemTrayViewClass() : ObjCClass<NSControl> ("JUCESystemTrayView_")
{
addIvar<Pimpl*> ("owner");
addIvar<NSImage*> ("image");
@ -154,6 +156,17 @@ private:
static void setOwner (id self, Pimpl* owner) { object_setInstanceVariable (self, "owner", owner); }
static void setImage (id self, NSImage* image) { object_setInstanceVariable (self, "image", image); }
static void frameChanged (id self, SEL, NSNotification*)
{
if (Pimpl* const owner = getOwner (self))
{
NSRect r = [[[owner->statusItem view] window] frame];
NSRect sr = [[[NSScreen screens] objectAtIndex: 0] frame];
r.origin.y = sr.size.height - r.origin.y - r.size.height;
owner->owner.setBounds (convertToRectInt (r));
}
}
private:
static void handleEventDown (id self, SEL, NSEvent* e)
{
@ -184,17 +197,6 @@ private:
fraction: 1.0f];
}
}
static void frameChanged (id self, SEL, NSNotification*)
{
if (Pimpl* const owner = getOwner (self))
{
NSRect r = [[[owner->statusItem view] window] frame];
NSRect sr = [[[NSScreen screens] objectAtIndex: 0] frame];
r.origin.y = sr.size.height - r.origin.y - r.size.height;
owner->owner.setBounds (convertToRectInt (r));
}
}
};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)