code for deminiaturisation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@28836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-10-18 06:28:50 +00:00
parent 11582bf1c1
commit 23904f379f
3 changed files with 68 additions and 12 deletions

View file

@ -1,3 +1,10 @@
2009-10-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/x11/XGServerWindow.m:
* Source/x11/XGServerEvent.m:
Experimental code to try to spot window deminiaturisation and send
an event to the gui so that it knows about it.
2009-07-31 Adam Fedor <fedor@gnu.org>
* Version 0.17.1

View file

@ -560,8 +560,9 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
NSTimeInterval time;
DndClass dnd = xdnd ();
NSDebugLLog(@"NSEvent", @"%d ClientMessage\n",
xEvent.xclient.window);
NSDebugLLog(@"NSEvent", @"%d ClientMessage - %s\n",
xEvent.xclient.window,
XGetAtomName(dpy, xEvent.xclient.message_type));
if (cWin == 0 || xEvent.xclient.window != cWin->ident)
{
generic.cachedWindow
@ -1393,9 +1394,9 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
* windows by their window properties. Fortunately, Window Maker
* will send us client message when a window is miniaturized.
*/
if ((generic.wm & XGWM_WINDOWMAKER) == 0 &&
xEvent.xproperty.atom == generic.netstates.net_wm_state_atom &&
xEvent.xproperty.state == PropertyNewValue)
if ((generic.wm & XGWM_WINDOWMAKER) == 0
&& xEvent.xproperty.atom == generic.netstates.net_wm_state_atom
&& xEvent.xproperty.state == PropertyNewValue)
{
if (cWin == 0 || xEvent.xproperty.window != cWin->ident)
{
@ -1423,6 +1424,22 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
data1: 0
data2: 0];
}
else if ([GSWindowWithNumber(cWin->number) isMiniaturized])
{
/* A miniaturised window is now visible ... send event
* to let the gui know it deminiaturised.
*/
eventLocation = NSMakePoint(0,0);
e = [NSEvent otherEventWithType: NSAppKitDefined
location: eventLocation
modifierFlags: 0
timestamp: xEvent.xproperty.time / 1000
windowNumber: cWin->number
context: gcontext
subtype: GSAppKitWindowDeminiaturize
data1: 0
data2: 0];
}
}
}
}

View file

@ -28,6 +28,7 @@
#include <math.h>
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSUserDefaults.h>
@ -326,18 +327,14 @@ static void setWindowHintsForStyle (Display *dpy, Window window,
if (styleMask & NSIconWindowMask)
{
// FIXME
hints->flags |= MWM_HINTS_DECORATIONS;
hints->flags |= MWM_HINTS_FUNCTIONS;
hints->flags &= ~MWM_HINTS_DECORATIONS;
hints->decorations = 0;
hints->functions = 0;
}
if (styleMask & NSMiniWindowMask)
{
// FIXME
hints->flags |= MWM_HINTS_DECORATIONS;
hints->flags |= MWM_HINTS_FUNCTIONS;
hints->flags &= ~MWM_HINTS_DECORATIONS;
hints->decorations = 0;
hints->functions = 0;
}
}
@ -2537,9 +2534,10 @@ NSLog(@"styleoffsets ... guessing offsets\n");
- (void) miniwindow: (int) win
{
gswindow_device_t *window;
XEvent e;
window = WINDOW_WITH_TAG(win);
if (window == 0 || (window->win_attrs.window_style & NSIconWindowMask) != 0)
if (window == 0)
{
return;
}
@ -2567,6 +2565,14 @@ NSLog(@"styleoffsets ... guessing offsets\n");
}
}
}
/* First discard all existing events for thsi window ... we don't need them
* because the window is being miniaturised, and they might confuse us when
* we try to find the event telling us that the miniaturisation worked.
*/
XSync(dpy, False);
while (XCheckWindowEvent(dpy, window->ident, 0xffffffff, &e) == True) ;
/*
* When the application owns the mini window, we withdraw the window itself
* during miniaturization and put up the mini window instead. However, this
@ -2578,6 +2584,27 @@ NSLog(@"styleoffsets ... guessing offsets\n");
XIconifyWindow(dpy, window->ident, window->screen);
else
XWithdrawWindow(dpy, window->ident, window->screen);
/* Now discard all events for this window up to (and including) the
* property notify which tells us it is in a miniaturised state.
* This measns we can safely assume that the next event showing the
* window in a mapped state will mean it has been deminiaturised.
*
* FIXME ... what if the window manager doesn't tell us that the window
* has gone? Presumably we shouldn't wait forever?
*/
XSync(dpy, False);
for (;;)
{
XWindowEvent(dpy, window->ident, 0xffffffff, &e);
if (e.type == PropertyNotify
&& e.xproperty.atom == generic.netstates.net_wm_state_atom
&& e.xproperty.state == PropertyNewValue
&& [self _ewmh_isMinimized: e.xproperty.window])
{
break;
}
}
}
/**
@ -4625,6 +4652,11 @@ _computeDepth(int class, int bpp)
for (i = 0; i < count; i++)
{
if (data[i] != 0)
{
NSDebugLLog(@"NSEvent", @"%d PropertyNotify detail - '%s'\n",
win, XGetAtomName(dpy, data[i]));
}
if (data[i] == generic.netstates.net_wm_state_hidden_atom)
{
XFree(data);