Better styleoffsets implementation by Yen-Ju Chen <yjchenx@hotmail.com>.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@22853 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2006-05-03 23:14:08 +00:00
parent 6dcb213152
commit 1bb8a0aea7
2 changed files with 70 additions and 7 deletions

View file

@ -1,3 +1,13 @@
2006-05-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (-styleoffsets::::::): New method to
compute window frame offset based on the _NET_FRAME_EXTENTS or
_KDE_NET_WM_FRAME_STRUT property. This is based on a slightly
extended patch by Yen-Ju Chen <yjchenx@hotmail.com>.
Call this new method from [styleoffsets:::::] and [_OSFrameToXHints:].
* Source/x11/XGServerWindow.m (-iconTileImage): Make sure the
window pointer gets freed.
2006-05-03 Fred Kiefer <FredKiefer@gmx.de> 2006-05-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (-nativeWindow:::::): Implemented to * Source/x11/XGServerWindow.m (-nativeWindow:::::): Implemented to

View file

@ -353,6 +353,11 @@ static void setWindowHintsForStyle (Display *dpy, Window window,
} }
@end @end
@interface XGServer (WindowOps)
- (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b
: (unsigned int) style : (Window) win;
@end
@implementation XGServer (WindowOps) @implementation XGServer (WindowOps)
-(BOOL) handlesWindowDecorations -(BOOL) handlesWindowDecorations
@ -420,15 +425,15 @@ NSDebugLLog(@"Frame", @"O2X %d, %@, %@", win->number,
NSRect x; NSRect x;
float t, b, l, r; float t, b, l, r;
[self styleoffsets: &l : &r : &t : &b : win->win_attrs.window_style]; [self styleoffsets: &l : &r : &t : &b : win->win_attrs.window_style : win->ident];
x.size.width = o.size.width; x.size.width = o.size.width;
x.size.height = o.size.height; x.size.height = o.size.height;
x.origin.x = o.origin.x - l; x.origin.x = o.origin.x - l;
x.origin.y = o.origin.y + o.size.height; x.origin.y = o.origin.y + o.size.height;
x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y - t; x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y - t;
NSDebugLLog(@"Frame", @"O2H %d, %@, %@", win->number, NSDebugLLog(@"Frame", @"O2H %d, %@, %@", win->number,
NSStringFromRect(o), NSStringFromRect(x)); NSStringFromRect(o), NSStringFromRect(x));
return x; return x;
} }
@ -1443,6 +1448,15 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
- (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b - (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b
: (unsigned int) style : (unsigned int) style
{ {
[self styleoffsets: l : r : t : b : style : (Window) 0];
}
- (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b
: (unsigned int) style : (Window) win
{
static Atom _net_frame_extents = None;
static Atom _kde_frame_strut = None;
if (!handlesWindowDecorations) if (!handlesWindowDecorations)
{ {
/* /*
@ -1454,7 +1468,44 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
return; return;
} }
/* First try to get the offset information that we have obtained from /* First check _NET_FRAME_EXTENTS */
if (win && ((generic.wm & XGWM_EWMH) != 0))
{
int count;
unsigned long *extents;
if (_net_frame_extents == None)
{
_net_frame_extents = XInternAtom (dpy, "_NET_FRAME_EXTENTS", False);
}
extents = (unsigned long *)PropGetCheckProperty(dpy, win, _net_frame_extents,
XA_CARDINAL, 32, 4, &count);
if (!extents && (generic.wm & XGWM_KDE))
{
if (_kde_frame_strut == None)
{
_kde_frame_strut = XInternAtom (dpy, "_KDE_NET_WM_FRAME_STRUT", False);
}
extents = (unsigned long *)PropGetCheckProperty(dpy, win, _kde_frame_strut,
XA_CARDINAL, 32, 4, &count);
}
if (extents)
{
NSDebugLLog(@"Frame", @"Window %d, left %d, right %d, top %d, bottom %d",
win, extents[0], extents[1], extents[2], extents[3]);
*l = extents[0];
*r = extents[1];
*t = extents[2];
*b = extents[3];
XFree(extents);
return;
}
}
/* Nextt try to get the offset information that we have obtained from
the WM. This will only work if the application has already created the WM. This will only work if the application has already created
a window that has been reparented by the WM. Otherwise we have to a window that has been reparented by the WM. Otherwise we have to
guess. guess.
@ -3296,6 +3347,7 @@ _computeDepth(int class, int bpp)
Atom icon_tile_atom; Atom icon_tile_atom;
Atom rgba_image_atom; Atom rgba_image_atom;
Window win; Window win;
Window *pwin;
int count; int count;
unsigned char *tile; unsigned char *tile;
NSImage *iconTileImage; NSImage *iconTileImage;
@ -3311,13 +3363,14 @@ _computeDepth(int class, int bpp)
rgba_image_atom = XInternAtom(dpy,"_RGBA_IMAGE", False); rgba_image_atom = XInternAtom(dpy,"_RGBA_IMAGE", False);
win = DefaultRootWindow(dpy); win = DefaultRootWindow(dpy);
win = *(Window *)PropGetCheckProperty(dpy, win, noticeboard_atom, XA_WINDOW, pwin = (Window *)PropGetCheckProperty(dpy, win, noticeboard_atom, XA_WINDOW,
32, -1, &count); 32, -1, &count);
if (win == (Window)NULL) if (pwin == NULL)
return [super iconTileImage]; return [super iconTileImage];
tile = PropGetCheckProperty(dpy, win, icon_tile_atom, rgba_image_atom, tile = PropGetCheckProperty(dpy, *pwin, icon_tile_atom, rgba_image_atom,
8, -1, &count); 8, -1, &count);
XFree(pwin);
if (tile == NULL || count < 4) if (tile == NULL || count < 4)
return [super iconTileImage]; return [super iconTileImage];