New method -_XFrameToXHints:for:.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@22923 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2006-05-13 20:56:18 +00:00
parent c7e1737369
commit f4868d3a43
4 changed files with 52 additions and 21 deletions

View file

@ -1,3 +1,12 @@
2006-05-13 Fred Kiefer <FredKiefer@gmx.de>
* Headers/x11/XGServer.h,
* Source/x11/XGServerWindow.m (-_XFrameToXHints:for:): New method to
compute X hints directly from X frame. Previously the X frame
was converted to an OS frame and from this the X hints were computed.
* Source/x11/XGServerWindow.m, Source/x11/XGServerEvent.m:
Replaced all usages of _OSFrameToXHints:for: with _XFrameToXHints:for:.
2006-05-04 Fred Kiefer <FredKiefer@gmx.de> 2006-05-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (-styleoffsets::::::): New method to * Source/x11/XGServerWindow.m (-styleoffsets::::::): New method to

View file

@ -80,6 +80,7 @@ typedef enum {
- (NSRect) _OSFrameToXFrame: (NSRect)o for: (void*)window; - (NSRect) _OSFrameToXFrame: (NSRect)o for: (void*)window;
- (NSRect) _OSFrameToXHints: (NSRect)o for: (void*)window; - (NSRect) _OSFrameToXHints: (NSRect)o for: (void*)window;
- (NSRect) _XFrameToOSFrame: (NSRect)x for: (void*)window; - (NSRect) _XFrameToOSFrame: (NSRect)x for: (void*)window;
- (NSRect) _XFrameToXHints: (NSRect)o for: (void*)window;
@end @end
// Public interface for the input methods. // Public interface for the input methods.

View file

@ -770,7 +770,7 @@ static int check_modifier (XEvent *xEvent, KeySym key_sym,
/* /*
* Set size hints info to be up to date with new size. * Set size hints info to be up to date with new size.
*/ */
h = [self _OSFrameToXHints: n for: cWin]; h = [self _XFrameToXHints: x for: cWin];
cWin->siz_hints.width = h.size.width; cWin->siz_hints.width = h.size.width;
cWin->siz_hints.height = h.size.height; cWin->siz_hints.height = h.size.height;

View file

@ -410,8 +410,8 @@ static void setWindowHintsForStyle (Display *dpy, Window window,
x = o; x = o;
x.origin.y = x.origin.y + o.size.height; x.origin.y = x.origin.y + o.size.height;
x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y; x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y;
NSDebugLLog(@"Frame", @"O2X %d, %@, %@", win->number, NSDebugLLog(@"Frame", @"O2X %d, %@, %@", win->number,
NSStringFromRect(o), NSStringFromRect(x)); NSStringFromRect(o), NSStringFromRect(x));
return x; return x;
} }
@ -450,7 +450,7 @@ NSDebugLLog(@"Frame", @"O2X %d, %@, %@", win->number,
o.origin.x = x.origin.x; o.origin.x = x.origin.x;
o.origin.y = win->siz_hints.height - x.origin.y; o.origin.y = win->siz_hints.height - x.origin.y;
o.origin.y = o.origin.y - o.size.height; o.origin.y = o.origin.y - o.size.height;
NSDebugLLog(@"GGFrame", @"%@ %@", NSStringFromRect(x), NSStringFromRect(o)); NSDebugLLog(@"Frame", @"X2O %@ %@", NSStringFromRect(x), NSStringFromRect(o));
return o; return o;
} }
@ -467,11 +467,33 @@ NSDebugLLog(@"Frame", @"O2X %d, %@, %@", win->number,
o = x; o = x;
o.origin.y = DisplayHeight(dpy, win->screen) - o.origin.y; o.origin.y = DisplayHeight(dpy, win->screen) - o.origin.y;
o.origin.y = o.origin.y - o.size.height; o.origin.y = o.origin.y - o.size.height;
NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
NSStringFromRect(x), NSStringFromRect(o)); NSStringFromRect(x), NSStringFromRect(o));
return o; return o;
} }
/*
* Convert a window frame in X absolute screen coordinates to
* a frame suitable for setting X hints for a window manager.
*/
- (NSRect) _XFrameToXHints: (NSRect)o for: (void*)window
{
gswindow_device_t *win = (gswindow_device_t*)window;
NSRect x;
float t, b, l, r;
[self styleoffsets: &l : &r : &t : &b : win->win_attrs.window_style : win->ident];
// FIXME: When adding the frame here, we get X window errors!
x.size.width = o.size.width; // + l + r;
x.size.height = o.size.height; // + t + b;
x.origin.x = o.origin.x - l;
x.origin.y = o.origin.y - t;
NSDebugLLog(@"Frame", @"X2H %d, %@, %@", win->number,
NSStringFromRect(o), NSStringFromRect(x));
return x;
}
- (XGWMProtocols) _checkWindowManager - (XGWMProtocols) _checkWindowManager
{ {
@ -1200,8 +1222,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
* Prepare size/position hints, but don't set them now - ordering * Prepare size/position hints, but don't set them now - ordering
* the window in should automatically do it. * the window in should automatically do it.
*/ */
frame = [self _XFrameToOSFrame: window->xframe for: window]; frame = [self _XFrameToXHints: window->xframe for: window];
frame = [self _OSFrameToXHints: frame for: window];
window->siz_hints.x = NSMinX(frame); window->siz_hints.x = NSMinX(frame);
window->siz_hints.y = NSMinY(frame); window->siz_hints.y = NSMinY(frame);
window->siz_hints.width = NSWidth(frame); window->siz_hints.width = NSWidth(frame);
@ -1368,8 +1389,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
* Prepare size/position hints, but don't set them now - ordering * Prepare size/position hints, but don't set them now - ordering
* the window in should automatically do it. * the window in should automatically do it.
*/ */
xframe = [self _XFrameToOSFrame: window->xframe for: window]; xframe = [self _XFrameToXHints: window->xframe for: window];
xframe = [self _OSFrameToXHints: xframe for: window];
window->siz_hints.x = NSMinX(xframe); window->siz_hints.x = NSMinX(xframe);
window->siz_hints.y = NSMinY(xframe); window->siz_hints.y = NSMinY(xframe);
window->siz_hints.width = NSWidth(xframe); window->siz_hints.width = NSWidth(xframe);
@ -1476,17 +1496,18 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
if (_net_frame_extents == None) if (_net_frame_extents == None)
{ {
_net_frame_extents = XInternAtom (dpy, "_NET_FRAME_EXTENTS", False); _net_frame_extents = XInternAtom(dpy, "_NET_FRAME_EXTENTS", False);
} }
extents = (unsigned long *)PropGetCheckProperty(dpy, win, _net_frame_extents, extents = (unsigned long *)PropGetCheckProperty(dpy, win, _net_frame_extents,
XA_CARDINAL, 32, 4, &count); XA_CARDINAL, 32, 4, &count);
if (!extents && (generic.wm & XGWM_KDE))
if (!extents) // && (generic.wm & XGWM_KDE))
{ {
if (_kde_frame_strut == None) if (_kde_frame_strut == None)
{ {
_kde_frame_strut = XInternAtom (dpy, "_KDE_NET_WM_FRAME_STRUT", False); _kde_frame_strut = XInternAtom(dpy, "_KDE_NET_WM_FRAME_STRUT", False);
} }
extents = (unsigned long *)PropGetCheckProperty(dpy, win, _kde_frame_strut, extents = (unsigned long *)PropGetCheckProperty(dpy, win, _kde_frame_strut,
XA_CARDINAL, 32, 4, &count); XA_CARDINAL, 32, 4, &count);
@ -1607,8 +1628,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
window->win_attrs.window_style = style; window->win_attrs.window_style = style;
/* Fix up hints */ /* Fix up hints */
h = [self _XFrameToOSFrame: window->xframe for: window]; h = [self _XFrameToXHints: window->xframe for: window];
h = [self _OSFrameToXHints: h for: window];
window->siz_hints.x = NSMinX(h); window->siz_hints.x = NSMinX(h);
window->siz_hints.y = NSMinY(h); window->siz_hints.y = NSMinY(h);
window->siz_hints.width = NSWidth(h); window->siz_hints.width = NSWidth(h);
@ -2203,9 +2223,10 @@ static BOOL didCreatePixmaps;
{ {
NSEvent *e; NSEvent *e;
NSRect xVal; NSRect xVal;
NSRect xHint;
NSRect frame;
gswindow_device_t *window; gswindow_device_t *window;
NSWindow *nswin; NSWindow *nswin;
NSRect frame;
BOOL resize = NO; BOOL resize = NO;
BOOL move = NO; BOOL move = NO;
@ -2232,12 +2253,12 @@ static BOOL didCreatePixmaps;
move = YES; move = YES;
} }
xVal = [self _OSFrameToXHints: rect for: window];
window->siz_hints.width = (int)xVal.size.width;
window->siz_hints.height = (int)xVal.size.height;
window->siz_hints.x = (int)xVal.origin.x;
window->siz_hints.y = (int)xVal.origin.y;
xVal = [self _OSFrameToXFrame: rect for: window]; xVal = [self _OSFrameToXFrame: rect for: window];
xHint = [self _XFrameToXHints: xVal for: window];
window->siz_hints.width = (int)xHint.size.width;
window->siz_hints.height = (int)xHint.size.height;
window->siz_hints.x = (int)xHint.origin.x;
window->siz_hints.y = (int)xHint.origin.y;
NSDebugLLog(@"Moving", @"Place %d - o:%@, x:%@", window->number, NSDebugLLog(@"Moving", @"Place %d - o:%@, x:%@", window->number,
NSStringFromRect(rect), NSStringFromRect(xVal)); NSStringFromRect(rect), NSStringFromRect(xVal));