Patch by German Arias <german@xelalug.org>.

Allows to get icon placement from separate process.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29153 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-12-21 17:27:56 +00:00
parent 4433753e94
commit fc783c92d6
6 changed files with 214 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2009-12-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSIconManager.h,
* Source/GSIconManager.m: New files. Allows to get icon placement
from separate process.
* Source/GNUmakefile: Add new file.
* Source/NSWindow.m,
* Source/NSApplication.m: Move icon handling into new file.
Patch by German Arias <german@xelalug.org>.
2009-12-20 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSColorWell.m: Draw a black-and-white pattern behind

View file

@ -217,6 +217,7 @@ GSLayoutManager.m \
GSTypesetter.m \
GSHorizontalTypesetter.m \
GSGormLoading.m \
GSIconManager.m \
GSNibLoading.m \
GSTitleView.m \
GSToolTips.m \

36
Source/GSIconManager.h Normal file
View file

@ -0,0 +1,36 @@
/* Copyright (C) 2009 Free Software Foundation, Inc.
Written by: German Arias <german@xelalug.org>
Created: December 2009
This file is part of the GNUstep Project
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSGeometry.h>
#import "AppKit/NSWindow.h"
NSSize
GSGetIconSize(void);
void
GSRemoveIcon(NSWindow *window);
NSRect
GSGetIconFrame(NSWindow *window);

142
Source/GSIconManager.m Normal file
View file

@ -0,0 +1,142 @@
/* Copyright (C) 2009 Free Software Foundation, Inc.
Written by: German Arias <german@xelalug.org>
Created: December 2009
This file is part of the GNUstep Project
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSConnection.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSProcessInfo.h>
#import <GNUstepGUI/GSDisplayServer.h>
#import "AppKit/NSGraphics.h"
#import "GSIconManager.h"
@protocol GSIconManager
- (NSRect) setWindow: (unsigned int)aWindowNumber appProcessId: (int)aProcessId;
- (void) removeWindow: (unsigned int)aWindowNumber;
- (NSSize) getSizeWindow;
- (id) retain;
- (void) release;
@end
static BOOL verify = NO;
static id <GSIconManager>gsim = nil;
static int appId = 0;
static int iconCount = 0;
static void
GSGetIconManager(void)
{
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSUseIconManager"])
{
appId = [[NSProcessInfo processInfo] processIdentifier];
gsim = (id <GSIconManager>)[NSConnection rootProxyForConnectionWithRegisteredName: @"GSIconManager"
host: @""];
if (gsim == nil)
{
NSLog (@"Error: could not connect to server GSIconManager");
}
[gsim retain];
}
}
static inline void
checkVerify()
{
if (!verify)
{
GSGetIconManager();
verify = YES;
}
}
NSSize
GSGetIconSize(void)
{
NSSize iconSize;
checkVerify();
if (gsim != nil)
{
iconSize = [gsim getSizeWindow];
}
else
{
iconSize = [GSCurrentServer() iconSize];
}
return iconSize;
}
void
GSRemoveIcon(NSWindow *window)
{
checkVerify();
if (gsim != nil)
{
unsigned int winNum = 0;
NSConvertWindowNumberToGlobal([window windowNumber], &winNum);
[gsim removeWindow: winNum];
iconCount--;
if (iconCount == 0)
{
DESTROY(gsim);
verify = NO;
}
}
}
NSRect
GSGetIconFrame(NSWindow *window)
{
NSRect iconRect;
checkVerify();
if (gsim != nil)
{
unsigned int winNum = 0;
NSConvertWindowNumberToGlobal([window windowNumber], &winNum);
iconRect = [gsim setWindow: winNum
appProcessId: appId];
iconCount++;
}
else
{
NSSize iconSize;
iconSize = [GSCurrentServer() iconSize];
iconRect = NSMakeRect(0, 0, iconSize.height, iconSize.width);
}
return iconRect;
}

View file

@ -79,6 +79,7 @@
#include "AppKit/NSScreen.h"
#include "AppKit/PSOperators.h"
#include "GSIconManager.h"
#include "GNUstepGUI/GSDisplayServer.h"
#include "GNUstepGUI/GSServicesManager.h"
#include "GSGuiPrivate.h"
@ -466,7 +467,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{
NSSize iconSize, retSize;
iconSize = [GSCurrentServer() iconSize];
iconSize = GSGetIconSize();
retSize.width = imageSize.width * iconSize.width / 64;
retSize.height = imageSize.height * iconSize.height / 64;
return retSize;
@ -477,7 +478,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
NSImage *tileImage;
NSSize iconSize;
iconSize = [GSCurrentServer() iconSize];
iconSize = GSGetIconSize();
/* _appIconInit will set our image */
dragCell = [[NSCell alloc] initImageCell: nil];
[dragCell setBordered: NO];
@ -515,7 +516,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
- (void) drawRect: (NSRect)rect
{
NSSize iconSize = [GSCurrentServer() iconSize];
NSSize iconSize = GSGetIconSize();
[tileCell drawWithFrame: NSMakeRect(0, 0, iconSize.width, iconSize.height)
inView: self];
@ -3391,6 +3392,7 @@ struct _DelegateWrapper
if (termination == NSTerminateNow)
{
GSRemoveIcon(_app_icon_window);
[self replyToApplicationShouldTerminate: YES];
}
/*
@ -3668,8 +3670,7 @@ struct _DelegateWrapper
- _appIconInit
{
NSAppIconView *iv;
NSSize iconSize = [GSCurrentServer() iconSize];
NSRect iconRect = NSMakeRect(0, 0, iconSize.width, iconSize.height);
NSRect iconRect;
unsigned mask = NSIconWindowMask;
BOOL suppress;
@ -3682,12 +3683,15 @@ struct _DelegateWrapper
}
#endif
_app_icon_window = [[NSIconWindow alloc] initWithContentRect: iconRect
_app_icon_window = [[NSIconWindow alloc] initWithContentRect: NSZeroRect
styleMask: mask
backing: NSBackingStoreRetained
defer: NO
screen: nil];
iconRect = GSGetIconFrame(_app_icon_window);
[_app_icon_window setFrame: iconRect display: YES];
iv = [[NSAppIconView alloc] initWithFrame: iconRect];
[iv setImage: _app_icon];
[_app_icon_window setContentView: iv];

View file

@ -82,6 +82,7 @@
#include "GNUstepGUI/GSDisplayServer.h"
#include "GSGuiPrivate.h"
#include "GSToolTips.h"
#include "GSIconManager.h"
#include "GSWindowDecorationView.h"
#include "NSToolbarFrameworkPrivate.h"
@ -386,7 +387,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{
NSSize iconSize, retSize;
iconSize = [GSCurrentServer() iconSize];
iconSize = GSGetIconSize();
retSize.width = imageSize.width * iconSize.width / 64;
retSize.height = imageSize.height * iconSize.height / 64;
return retSize;
@ -399,7 +400,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
NSImage *tileImage;
NSSize iconSize;
iconSize = [GSCurrentServer() iconSize];
iconSize = GSGetIconSize();
tileImage = [[GSCurrentServer() iconTileImage] copy];
[tileImage setScalesWhenResized: YES];
@ -424,7 +425,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
- (void) drawRect: (NSRect)rect
{
NSSize iconSize = [GSCurrentServer() iconSize];
NSSize iconSize = GSGetIconSize();
[tileCell drawWithFrame: NSMakeRect(0, 0, iconSize.width, iconSize.height)
inView: self];
@ -2663,6 +2664,13 @@ resetCursorRectsForView(NSView *theView)
_f.has_opened = NO;
[NSApp removeWindowsItem: self];
[self orderOut: self];
if (_f.is_miniaturized == YES)
{
NSWindow *mini = GSWindowWithNumber(_counterpart);
GSRemoveIcon(mini);
}
RELEASE(pool);
_f.has_closed = YES;
RELEASE(self);
@ -2711,6 +2719,7 @@ resetCursorRectsForView(NSView *theView)
{
NSWindow *mini = GSWindowWithNumber(_counterpart);
GSRemoveIcon(mini);
[mini orderOut: self];
}
@ -2808,7 +2817,10 @@ resetCursorRectsForView(NSView *theView)
*/
if (_counterpart != 0)
{
NSRect iconRect;
NSWindow *mini = GSWindowWithNumber(_counterpart);
iconRect = GSGetIconFrame(mini);
[mini setFrame: iconRect display: YES];
[mini orderFront: self];
}
[nc postNotificationName: NSWindowDidMiniaturizeNotification