Added support for loginwindow masking when run at loginwindow.

git-svn-id: http://munki.googlecode.com/svn/trunk@67 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2009-05-18 20:18:32 +00:00
parent 577f0a0c73
commit babd41b221
9 changed files with 305 additions and 14 deletions

View File

@@ -0,0 +1,32 @@
//
// BorderlessWindow.h
// MunkiStatus
//
// Created by Greg Neagle on 5/16/09.
// Copyright 2009 Greg Neagle.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Cocoa/Cocoa.h>
@interface BorderlessWindow : NSWindow
- (id) initWithContentRect: (NSRect) contentRect
styleMask: (unsigned int) aStyle
backing: (NSBackingStoreType) bufferingType
defer: (BOOL) flag;
@end

View File

@@ -0,0 +1,42 @@
//
// BorderlessWindow.m
// MunkiStatus
//
// Created by Greg Neagle on 5/16/09.
// Copyright 2009 Greg Neagle.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "BorderlessWindow.h"
@implementation BorderlessWindow
- (id) initWithContentRect: (NSRect) contentRect
styleMask: (unsigned int) aStyle
backing: (NSBackingStoreType) bufferingType
defer: (BOOL) flag
{
if (self = [super initWithContentRect: contentRect
styleMask: NSBorderlessWindowMask
backing: bufferingType
defer: flag])
{
// other initialization
}
return self;
}
@end

View File

@@ -2,14 +2,14 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9G3553</string>
<string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.43</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="430"/>
<integer value="293"/>
<integer value="452"/>
<integer value="431"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -160,8 +160,56 @@
</object>
<string key="NSName">_NSMainMenu</string>
</object>
<object class="NSWindowTemplate" id="471574353">
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{384, 244}, {640, 480}}</string>
<int key="NSWTFlags">603984896</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">BorderlessWindow</string>
<nil key="NSViewClass"/>
<object class="NSView" key="NSWindowView" id="934017884">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSImageView" id="446692486">
<reference key="NSNextResponder" ref="934017884"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple PNG pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
</object>
</object>
<string key="NSFrameSize">{640, 480}</string>
<reference key="NSSuperview" ref="934017884"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="510718553">
<int key="NSCellFlags">130560</int>
<int key="NSCellFlags2">33554432</int>
<int key="NSAlign">0</int>
<int key="NSScale">3</int>
<int key="NSStyle">0</int>
<bool key="NSAnimates">NO</bool>
</object>
<bool key="NSEditable">YES</bool>
</object>
</object>
<string key="NSFrameSize">{640, 480}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSWindowTemplate" id="395427424">
<int key="NSWindowStyleMask">5</int>
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{443, 498}, {508, 123}}</string>
<int key="NSWTFlags">1946157056</int>
@@ -554,6 +602,39 @@
<reference key="object" ref="96254482"/>
<reference key="parent" ref="465293275"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">452</int>
<reference key="object" ref="471574353"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="934017884"/>
</object>
<reference key="parent" ref="328754663"/>
<string key="objectName">Backdrop</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">453</int>
<reference key="object" ref="934017884"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="446692486"/>
</object>
<reference key="parent" ref="471574353"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">454</int>
<reference key="object" ref="446692486"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="510718553"/>
</object>
<reference key="parent" ref="934017884"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">455</int>
<reference key="object" ref="510718553"/>
<reference key="parent" ref="446692486"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -621,18 +702,34 @@
<string>438.IBPluginDependency</string>
<string>439.IBPluginDependency</string>
<string>440.IBPluginDependency</string>
<string>452.IBAttributePlaceholdersKey</string>
<string>452.IBEditorWindowLastContentRect</string>
<string>452.IBPluginDependency</string>
<string>452.IBWindowTemplateEditedContentRect</string>
<string>452.NSWindowTemplate.visibleAtLaunch</string>
<string>453.IBPluginDependency</string>
<string>454.IBAttributePlaceholdersKey</string>
<string>454.IBPluginDependency</string>
<string>455.IBAttributePlaceholdersKey</string>
<string>455.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string key="NS.key.0">IBAppleScriptAttributeName</string>
<object class="IBAppleScriptInfoAttribute" key="NS.object.0">
<string key="name">IBAppleScriptAttributeName</string>
<reference key="object" ref="324411882"/>
<int key="appleScriptObjectID">0</int>
<int key="appleScriptScriptScope">0</int>
<object class="NSArray" key="appleScriptEventHandlerNames">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>DidResignActive</string>
</object>
<string key="appleScriptScriptName">MunkiStatus.applescript</string>
<string key="appleScriptObjectName">MunkiStatusApp</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -685,7 +782,7 @@
</object>
<string>{{112, 97}, {508, 123}}</string>
<string>{{112, 97}, {508, 123}}</string>
<boolean value="NO"/>
<boolean value="NO" id="6"/>
<string>{{238, 285}, {480, 360}}</string>
<boolean value="YES" id="5"/>
<string>{213, 107}</string>
@@ -765,6 +862,49 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBAppleScriptAttributeName</string>
<object class="IBAppleScriptInfoAttribute" key="NS.object.0">
<string key="name">IBAppleScriptAttributeName</string>
<reference key="object" ref="471574353"/>
<int key="appleScriptObjectID">0</int>
<int key="appleScriptScriptScope">0</int>
<object class="NSArray" key="appleScriptEventHandlerNames">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>AwakeFromNib</string>
</object>
<string key="appleScriptScriptName">MunkiStatus.applescript</string>
<string key="appleScriptObjectName">backdropWindow</string>
</object>
</object>
<string>{{33, 287}, {640, 480}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{33, 287}, {640, 480}}</string>
<reference ref="6"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBAppleScriptAttributeName</string>
<object class="IBAppleScriptInfoAttribute" key="NS.object.0">
<string key="name">IBAppleScriptAttributeName</string>
<reference key="object" ref="446692486"/>
<int key="appleScriptObjectID">0</int>
<int key="appleScriptScriptScope">0</int>
<nil key="appleScriptEventHandlerNames"/>
<string key="appleScriptScriptName">MunkiStatus.applescript</string>
<string key="appleScriptObjectName">imageFld</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -787,11 +927,19 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">440</int>
<int key="maxID">455</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">BorderlessWindow</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BorderlessWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FirstResponder</string>
<string key="superclassName">NSObject</string>
@@ -800,6 +948,20 @@
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSApplication</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">SystemConfigurationInterface.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>

View File

@@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.disneyanimation.MunkiStatus</string>
<key>CFBundleInfoDictionaryVersion</key>

View File

@@ -35,6 +35,29 @@ property kCGStatusWindowLevel : 25
property kCGScreenSaverWindowLevel : 1000
on awake from nib theObject
if name of theObject is "backdropWindow" then
copy "" to cfuser
copy (call method "consoleUser") to cfuser
if cfuser is "" then
call method "setCanBecomeVisibleWithoutLogin:" of theObject with parameter 1
call method "setLevel:" of theObject with parameter (kCGStatusWindowLevel)
copy (call method "mainScreenRect") to screenRect
call method "setFrame:display:" of theObject with parameters {screenRect, true}
try
tell application "System Events"
set DesktopPicture to value of property list item "DesktopPicture" of property list file "/Library/Preferences/com.apple.loginwindow.plist"
if exists (POSIX file DesktopPicture as file) then
--do nothing; just trying to trigger an error
end if
end tell
on error
set DesktopPicture to "/Library/Desktop Pictures/Aqua Blue.jpg"
end try
set bgPicture to load image DesktopPicture
set contents of image view "imageFld" of theObject to bgPicture
show theObject
end if
end if
if name of theObject is "mainWindow" then
-- Leopard is picky about what we can display over the loginwindow
call method "setCanBecomeVisibleWithoutLogin:" of theObject with parameter 1
@@ -50,3 +73,14 @@ on awake from nib theObject
activate
end if
end awake from nib
on resigned active theObject
copy "" to cfuser
copy (call method "consoleUser") to cfuser
if cfuser is "" then
tell me to activate
end if
end resigned active

Binary file not shown.

View File

@@ -29,6 +29,9 @@
C001935C0FA117A800AC90B0 /* SystemConfigurationInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = C001935B0FA117A800AC90B0 /* SystemConfigurationInterface.h */; };
C001935E0FA118A400AC90B0 /* SystemConfigurationInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = C001935D0FA118A400AC90B0 /* SystemConfigurationInterface.m */; };
C00193920FA11D5C00AC90B0 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C00193910FA11D5C00AC90B0 /* SystemConfiguration.framework */; };
C00B239E0FC096670016293D /* MunkiStatus.icns in Resources */ = {isa = PBXBuildFile; fileRef = C00B239D0FC096670016293D /* MunkiStatus.icns */; };
C01D090F0FBF7216001ED249 /* BorderlessWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = C01D090D0FBF7216001ED249 /* BorderlessWindow.h */; };
C01D09100FBF7216001ED249 /* BorderlessWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = C01D090E0FBF7216001ED249 /* BorderlessWindow.m */; };
C0C84CCF0F98FF7800B6518D /* Installer.tiff in Resources */ = {isa = PBXBuildFile; fileRef = C0C84CCE0F98FF7800B6518D /* Installer.tiff */; };
C0C84CD10F98FF8400B6518D /* package.tiff in Resources */ = {isa = PBXBuildFile; fileRef = C0C84CD00F98FF8400B6518D /* package.tiff */; };
/* End PBXBuildFile section */
@@ -46,6 +49,9 @@
C001935B0FA117A800AC90B0 /* SystemConfigurationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemConfigurationInterface.h; sourceTree = "<group>"; };
C001935D0FA118A400AC90B0 /* SystemConfigurationInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SystemConfigurationInterface.m; sourceTree = "<group>"; };
C00193910FA11D5C00AC90B0 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
C00B239D0FC096670016293D /* MunkiStatus.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = MunkiStatus.icns; sourceTree = "<group>"; };
C01D090D0FBF7216001ED249 /* BorderlessWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderlessWindow.h; sourceTree = "<group>"; };
C01D090E0FBF7216001ED249 /* BorderlessWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BorderlessWindow.m; sourceTree = "<group>"; };
C0C84CCE0F98FF7800B6518D /* Installer.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Installer.tiff; sourceTree = "<group>"; };
C0C84CD00F98FF8400B6518D /* package.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = package.tiff; sourceTree = "<group>"; };
DA206CF1015C4E2903C91932 /* AppleScriptKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppleScriptKit.framework; path = /System/Library/Frameworks/AppleScriptKit.framework; sourceTree = "<absolute>"; };
@@ -117,6 +123,8 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
C01D090D0FBF7216001ED249 /* BorderlessWindow.h */,
C01D090E0FBF7216001ED249 /* BorderlessWindow.m */,
29B97316FDCFA39411CA2CEA /* main.m */,
C001935B0FA117A800AC90B0 /* SystemConfigurationInterface.h */,
C001935D0FA118A400AC90B0 /* SystemConfigurationInterface.m */,
@@ -127,6 +135,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
C00B239D0FC096670016293D /* MunkiStatus.icns */,
C0C84CD00F98FF8400B6518D /* package.tiff */,
C0C84CCE0F98FF7800B6518D /* Installer.tiff */,
60A014C20DBD2AA20071D9A8 /* MainMenu.xib */,
@@ -153,6 +162,7 @@
buildActionMask = 2147483647;
files = (
C001935C0FA117A800AC90B0 /* SystemConfigurationInterface.h in Headers */,
C01D090F0FBF7216001ED249 /* BorderlessWindow.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -205,6 +215,7 @@
60A014C40DBD2AA20071D9A8 /* MainMenu.xib in Resources */,
C0C84CCF0F98FF7800B6518D /* Installer.tiff in Resources */,
C0C84CD10F98FF8400B6518D /* package.tiff in Resources */,
C00B239E0FC096670016293D /* MunkiStatus.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -217,6 +228,7 @@
files = (
257572CA072881A4000BE9CA /* main.m in Sources */,
C001935E0FA118A400AC90B0 /* SystemConfigurationInterface.m in Sources */,
C01D09100FBF7216001ED249 /* BorderlessWindow.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -27,5 +27,6 @@
@interface NSApplication (ASKAMultiLanguage)
- (NSString *)consoleUser;
- (NSRect)mainScreenRect;
@end

View File

@@ -21,6 +21,7 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import "SystemConfigurationInterface.h"
@@ -42,4 +43,11 @@
return username;
}
- (NSRect)mainScreenRect
{
NSRect screenRect;
screenRect = [[NSScreen mainScreen] frame];
return screenRect;
}
@end