Handle multiple screens.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@13531 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2002-04-23 21:05:50 +00:00
parent 4965a374aa
commit ab401b8440
12 changed files with 517 additions and 450 deletions

View file

@ -1,3 +1,28 @@
2002-04-23 Adam Fedor <fedor@gnu.org>
* Headers/x11/XGServer.h: Rework to handle multiple screens.
* Headers/xlib/XGContext.h: Simplify.
* Source/win32/WIN32Server.m (-mouseLocationOnScreen:window:):
Implement.
* Source/x11/XGServer.m: Rework to handle multiple screens. New
XScreenContext class.
(-initXContext): Use it.
(-_screenContextForScreen:): Implement.
(-xrContextForScreen:): Idem.
(-drawMechanismForScreen:): Idem.
(-xDisplayRootWindowForScreen:): Idem.
(-xColorFromColor:forScreen:): Idem.
* Source/x11/XGServerEvent.m (-mouseLocationOnScreen:window:):
Implement.
* Source/x11/XGServerWindow.m (-window::::): Use screen arg.
(_blankCursor): Use default screen for drawable (?).
(imagecursor::::::): Idem.
* Source/xlib/XGBitmapImageRep.m: Update for new server interface.
* Source/xlib/XGGState.m: Idem.
2002-04-22 Georg Fleischmann
* back/Source/xlib/XGGState.m

View file

@ -47,23 +47,22 @@ typedef enum {
@interface XGServer : GSDisplayServer
{
@public
void *context;
Window grabWindow;
XGDrawMechanism drawMechanism;
struct XGGeneric generic;
id inputServer;
Display *dpy;
int defScreen;
NSMapTable *screenList;
Window grabWindow;
struct XGGeneric generic;
id inputServer;
}
+ (Display*) currentXDisplay;
- (XGDrawMechanism) drawMechanism;
- (Display*)xDisplay;
- (Window)xDisplayRootWindow;
- (Window)xAppRootWindow;
- (Display*) xDisplay;
- (Window) xAppRootWindow;
- (XColor)xColorFromColor: (XColor)color;
- (void *) xrContext;
- (void *) xrContextForScreen: (int)screen_number;
- (XGDrawMechanism) drawMechanismForScreen: (int)screen_number;
- (Window) xDisplayRootWindowForScreen: (int)screen_number;
- (XColor) xColorFromColor: (XColor)color forScreen: (int)screen_number;
+ (void) waitAllContexts;
@end

View file

@ -28,20 +28,10 @@
#define _XGContext_h_INCLUDE
#include "gsc/GSContext.h"
#include "x11/XGServer.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@interface XGContext : GSContext
{
XGDrawMechanism drawMechanism;
}
- (XGDrawMechanism) drawMechanism;
- (Display*) xDisplay;
- (void *) xrContext;
@end
#endif /* _XGContext_h_INCLUDE */

View file

@ -30,6 +30,7 @@
#include "gsc/GSGState.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "x11/XGServer.h"
#include "xlib/xrtools.h"
@class NSBezierPath;
@ -40,6 +41,7 @@
@public
void *context;
void *windevice;
XGDrawMechanism drawMechanism;
GC xgcntxt;
XGCValues gcv;
Drawable draw;

View file

@ -33,6 +33,7 @@
#include "x11/wraster.h"
#endif
#include "x11/XGServer.h"
#include "xlib/XGContext.h"
#include "xlib/xrtools.h"
#include <AppKit/GSFontInfo.h>

View file

@ -543,6 +543,11 @@ DWORD windowStyleForGSStyle(int style)
return MSScreenPointToGS(p.x, p.y);
}
- (NSPoint) mouseLocationOnScreen: (int)screen window: (void *)win
{
return [self mouselocation];
}
- (BOOL) capturemouse: (int) winNum
{
SetCapture((HWND)winNum);

View file

@ -62,31 +62,18 @@ extern int XGErrorHandler(Display *display, XErrorEvent *err);
- (void) setupRunLoopInputSourcesForMode: (NSString*)mode;
@end
#define XDPY (((RContext *)context)->dpy)
#define XSCR (((RContext *)context)->screen_number)
/**
<unit>
<heading>XGServer</heading>
</unit>
*/
@implementation XGServer
/* Initialize AppKit backend */
+ (void)initializeBackend
@interface XGScreenContext : NSObject
{
NSDebugLog(@"Initializing GNUstep x11 backend.\n");
[GSDisplayServer setDefaultServerClass: [XGServer class]];
RContext *rcontext;
XGDrawMechanism drawMechanism;
}
/**
Returns a pointer to the current X-Windows display variable for
the current context.
*/
+ (Display*) currentXDisplay
{
return [(XGServer*)GSCurrentServer() xDisplay];
}
- initForDisplay: (Display *)dpy screen: (int)screen_number;
- (XGDrawMechanism) drawMechanism;
- (RContext *) context;
@end
@implementation XGScreenContext
- (RContextAttributes *) _getXDefaults
{
@ -113,16 +100,148 @@ extern int XGErrorHandler(Display *display, XErrorEvent *err);
return attribs;
}
- _initXContext
- initForDisplay: (Display *)dpy screen: (int)screen_number
{
Display *dpy;
int screen_number;
NSString *display_name;
NSRange disnum;
RContext *rcontext;
RContextAttributes *attribs;
XColor testColor;
unsigned char r, g, b;
/* Get the visual information */
attribs = NULL;
//attribs = [self _getXDefaults];
rcontext = RCreateContext(dpy, screen_number, attribs);
/*
* If we have shared memory available, only use it when the XGPS-Shm
* default is set to YES
*/
if (rcontext->attribs->use_shared_memory == True
&& [[NSUserDefaults standardUserDefaults] boolForKey: @"XGPS-Shm"] != YES)
rcontext->attribs->use_shared_memory = False;
/*
* Crude tests to see if we can accelerate creation of pixels from
* 8-bit red, green and blue color values.
*/
if (rcontext->depth == 12 || rcontext->depth == 16)
{
drawMechanism = XGDM_FAST16;
r = 8;
g = 9;
b = 7;
testColor.pixel = (((r << 5) + g) << 6) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 11) != r)
|| ((testColor.green >> 11) != g)
|| ((testColor.blue >> 11) != b))
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 16-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else if (rcontext->depth == 15)
{
drawMechanism = XGDM_FAST15;
r = 8;
g = 9;
b = 7;
testColor.pixel = (((r << 5) + g) << 5) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 11) != r)
|| ((testColor.green >> 11) != g)
|| ((testColor.blue >> 11) != b))
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 15-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else if (rcontext->depth == 24 || rcontext->depth == 32)
{
drawMechanism = XGDM_FAST32;
r = 32;
g = 33;
b = 31;
testColor.pixel = (((r << 8) + g) << 8) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 8) == r)
&& ((testColor.green >> 8) == g)
&& ((testColor.blue >> 8) == b))
{
drawMechanism = XGDM_FAST32;
}
else if (((testColor.red >> 8) == b)
&& ((testColor.green >> 8) == g)
&& ((testColor.blue >> 8) == r))
{
drawMechanism = XGDM_FAST32_BGR;
}
else
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 32-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else
{
NSLog(@"WARNING - XGServer is unable to use a "
@"fast algorithm for writing to the display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
return self;
}
- (XGDrawMechanism) drawMechanism
{
return drawMechanism;
}
- (RContext *) context
{
return rcontext;
}
@end
/**
<unit>
<heading>XGServer</heading>
</unit>
*/
@implementation XGServer
/* Initialize AppKit backend */
+ (void)initializeBackend
{
NSDebugLog(@"Initializing GNUstep x11 backend.\n");
[GSDisplayServer setDefaultServerClass: [XGServer class]];
}
/**
Returns a pointer to the current X-Windows display variable for
the current context.
*/
+ (Display*) currentXDisplay
{
return [(XGServer*)GSCurrentServer() xDisplay];
}
- _initXContext
{
int screen_number;
NSString *display_name;
NSRange disnum;
XGScreenContext *screen;
display_name = [server_info objectForKey: GSDisplayName];
if (display_name == nil)
@ -236,99 +355,15 @@ extern int XGErrorHandler(Display *display, XErrorEvent *err);
forKey: GSDisplayNumber];
[server_info setObject: [display_name pathExtension] forKey: GSScreenNumber];
/* Get the visual information */
attribs = NULL;
//attribs = [self _getXDefaults];
rcontext = RCreateContext(dpy, screen_number, attribs);
context = (void *)rcontext;
/* Setup screen*/
if (screenList == NULL)
screenList = NSCreateMapTable(NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 20);
/*
* If we have shared memory available, only use it when the XGPS-Shm
* default is set to YES
*/
if (rcontext->attribs->use_shared_memory == True
&& [[NSUserDefaults standardUserDefaults] boolForKey: @"XGPS-Shm"] != YES)
rcontext->attribs->use_shared_memory = False;
/*
* Crude tests to see if we can accelerate creation of pixels from
* 8-bit red, green and blue color values.
*/
if (rcontext->depth == 12 || rcontext->depth == 16)
{
drawMechanism = XGDM_FAST16;
r = 8;
g = 9;
b = 7;
testColor.pixel = (((r << 5) + g) << 6) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 11) != r)
|| ((testColor.green >> 11) != g)
|| ((testColor.blue >> 11) != b))
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 16-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else if (rcontext->depth == 15)
{
drawMechanism = XGDM_FAST15;
r = 8;
g = 9;
b = 7;
testColor.pixel = (((r << 5) + g) << 5) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 11) != r)
|| ((testColor.green >> 11) != g)
|| ((testColor.blue >> 11) != b))
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 15-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else if (rcontext->depth == 24 || rcontext->depth == 32)
{
drawMechanism = XGDM_FAST32;
r = 32;
g = 33;
b = 31;
testColor.pixel = (((r << 8) + g) << 8) + b;
XQueryColor(rcontext->dpy, rcontext->cmap, &testColor);
if (((testColor.red >> 8) == r)
&& ((testColor.green >> 8) == g)
&& ((testColor.blue >> 8) == b))
{
drawMechanism = XGDM_FAST32;
}
else if (((testColor.red >> 8) == b)
&& ((testColor.green >> 8) == g)
&& ((testColor.blue >> 8) == r))
{
drawMechanism = XGDM_FAST32_BGR;
}
else
{
NSLog(@"WARNING - XGServer is unable to use the "
@"fast algorithm for writing to a 32-bit display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
}
else
{
NSLog(@"WARNING - XGServer is unable to use a "
@"fast algorithm for writing to the display on "
@"this host - perhaps you'd like to adjust the code "
@"to work ... and submit a patch.");
drawMechanism = XGDM_PORTABLE;
}
screen = [[XGScreenContext alloc] initForDisplay: dpy screen: screen_number];
AUTORELEASE(screen);
NSMapInsert(screenList, (void *)screen_number, (void *)screen);
defScreen = screen_number;
XSetErrorHandler(XGErrorHandler);
@ -365,43 +400,87 @@ extern int XGErrorHandler(Display *display, XErrorEvent *err);
NSDebugLog(@"Destroying X11 Server");
DESTROY(inputServer);
[self _destroyServerWindows];
XCloseDisplay(XDPY);
NSFreeMapTable(screenList);
XCloseDisplay(dpy);
[super dealloc];
}
/**
Returns a pointer to the X windows display variable
*/
- (Display *) xDisplay
{
return dpy;
}
- (XGScreenContext *) _screenContextForScreen: (int)screen_number
{
int count = ScreenCount(dpy);
XGScreenContext *screen;
if (screen_number >= count)
{
[NSException raise: NSInvalidArgumentException
format: @"Request for invalid screen"];
}
screen = NSMapGet(screenList, (void *)screen_number);
if (screen == NULL)
{
XGScreenContext *screen;
screen = [[XGScreenContext alloc]
initForDisplay: dpy screen: screen_number];
AUTORELEASE(screen);
NSMapInsert(screenList, (void *)screen_number, (void *)screen);
}
return screen;
}
/**
Returns a pointer to a structure which describes aspects of the
X windows display
*/
- (void *) xrContextForScreen: (int)screen_number
{
return [[self _screenContextForScreen: screen_number] context];
}
/**
Returns the XGDrawMechanism, which roughly describes the depth of
the screen and how pixels should be drawn to the screen for maximum
speed.
*/
- (XGDrawMechanism) drawMechanism
- (XGDrawMechanism) drawMechanismForScreen: (int)screen_number
{
return drawMechanism;
}
/**
Returns a pointer to a structure which describes aspects of the
X windows display
*/
- (void *) xrContext
{
return context;
}
/*
Returns a pointer to the X windows display variable
*/
- (Display *) xDisplay
{
return XDPY;
return [[self _screenContextForScreen: screen_number] drawMechanism];
}
/**
Returns the root window of the display
*/
- (Window) xDisplayRootWindow
- (Window) xDisplayRootWindowForScreen: (int)screen_number;
{
return RootWindow(XDPY, XSCR);
return RootWindow(dpy, screen_number);
}
/**
Returns the closest color in the current colormap to the indicated
X color
*/
- (XColor)xColorFromColor: (XColor)color forScreen: (int)screen_number
{
Status ret;
RColor rcolor;
RContext *context = [self xrContextForScreen: screen_number];
XAllocColor(dpy, context->cmap, &color);
rcolor.red = color.red / 256;
rcolor.green = color.green / 256;
rcolor.blue = color.blue / 256;
ret = RGetClosestXColor(context, &rcolor, &color);
if (ret == False)
NSLog(@"Failed to alloc color (%d,%d,%d)\n",
(int)rcolor.red, (int)rcolor.green, (int)rcolor.blue);
return color;
}
/**
@ -413,25 +492,6 @@ extern int XGErrorHandler(Display *display, XErrorEvent *err);
return generic.appRootWindow;
}
/**
Returns the closest color in the current colormap to the indicated
X color
*/
- (XColor)xColorFromColor: (XColor)color
{
Status ret;
RColor rcolor;
Colormap colormap = XDefaultColormap(XDPY, XSCR);
XAllocColor(XDPY, colormap, &color);
rcolor.red = color.red / 256;
rcolor.green = color.green / 256;
rcolor.blue = color.blue / 256;
ret = RGetClosestXColor((RContext *)context, &rcolor, &color);
if (ret == False)
NSLog(@"Failed to alloc color (%d,%d,%d)\n",
(int)rcolor.red, (int)rcolor.green, (int)rcolor.blue);
return color;
}
/**
Wait for all contexts to finish processing. Only used with XDPS graphics.

View file

@ -121,9 +121,6 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
return (xEvent->xkeymap.key_vector[key_code / 8] & (1 << (key_code % 8)));
}
#define XDPY (((RContext *)context)->dpy)
#define XSCR (((RContext *)context)->screen_number)
@implementation XGServer (X11Methods)
- (int) XGErrorHandler: (Display*)display : (XErrorEvent*)err
@ -174,7 +171,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
- (void) setupRunLoopInputSourcesForMode: (NSString*)mode
{
int xEventQueueFd = XConnectionNumber(XDPY);
int xEventQueueFd = XConnectionNumber(dpy);
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
#if defined(LIB_FOUNDATION_LIBRARY)
@ -253,9 +250,9 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
gcontext = GSCurrentContext();
// loop and grab all of the events from the X queue
while (XPending(XDPY) > 0)
while (XPending(dpy) > 0)
{
XNextEvent(XDPY, &xEvent);
XNextEvent(dpy, &xEvent);
#ifdef USE_XIM
if (XFilterEvent(&xEvent, None))
@ -369,10 +366,10 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
if (cWin->parent == None)
break;
xEvent.xbutton.window = cWin->parent;
XUngrabPointer(XDPY, CurrentTime);
XSendEvent(XDPY, cWin->parent, True,
XUngrabPointer(dpy, CurrentTime);
XSendEvent(dpy, cWin->parent, True,
ButtonPressMask, &xEvent );
XFlush(XDPY);
XFlush(dpy);
break;
}
}
@ -461,7 +458,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
{
generic.lastTime = (Time)xEvent.xclient.data.l[1];
NSDebugLLog(@"NSEvent", @"WM Protocol - %s\n",
XGetAtomName(XDPY, xEvent.xclient.data.l[0]));
XGetAtomName(dpy, xEvent.xclient.data.l[0]));
if (xEvent.xclient.data.l[0] == generic.delete_win_atom)
{
@ -496,36 +493,17 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
else if (xEvent.xclient.data.l[0]
== generic.take_focus_atom)
{
Window rootWin;
Window childWin;
int win;
NSPoint p;
gswindow_device_t *w = 0;
int currentX;
int currentY;
int winX;
int winY;
unsigned mask;
BOOL ok;
/*
* WM is asking us to take the keyboard focus
*/
NSDebugLLog(@"Focus", @"check focus: %d",
cWin->number);
ok = XQueryPointer (XDPY, [self xDisplayRootWindow],
&rootWin, &childWin, &currentX, &currentY,
&winX, &winY, &mask);
if (ok != 0 && childWin != 0)
{
w = [XGServer _windowForXWindow: childWin];
if (w == 0)
{
/*
* Is the mouse in the border of a window?
*/
w = [XGServer _windowForXParent: childWin];
}
}
if (w == 0)
p = [self mouseLocationOnScreen: -1 window:(void *)&win];
if (win == 0)
{
/*
* If we can't locate the window under the mouse,
@ -538,10 +516,10 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
}
if (nswin != nil)
{
w = [XGServer _windowWithTag:
[nswin windowNumber]];
win = [nswin windowNumber];
}
}
w = [XGServer _windowWithTag: win];
if (w != 0)
{
cWin = w;
@ -1176,7 +1154,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
case PropertyNotify:
NSDebugLLog(@"NSEvent", @"%d PropertyNotify - '%s'\n",
xEvent.xproperty.window,
XGetAtomName(XDPY, xEvent.xproperty.atom));
XGetAtomName(dpy, xEvent.xproperty.atom));
break;
// a client successfully reparents a window
@ -1218,7 +1196,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
parent = new_parent;
NSLog(@"QueryTree window is %d (root %d cwin root %d)",
parent, root, cWin->root);
if (!XQueryTree(XDPY, parent, &root, &new_parent,
if (!XQueryTree(dpy, parent, &root, &new_parent,
&children, &nchildren))
{
new_parent = None;
@ -1235,7 +1213,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
if (new_parent && new_parent != cWin->root)
{
XWindowAttributes wattr;
XGetWindowAttributes(XDPY, parent, &wattr);
XGetWindowAttributes(dpy, parent, &wattr);
if (wattr.x || wattr.y)
{
generic.parent_offset.x = wattr.x;
@ -1749,7 +1727,7 @@ process_modifier_flags(unsigned int state)
*/
if (window->map_state != IsViewable)
{
XSync(XDPY, False);
XSync(dpy, False);
[self receivedEvent: 0 type: 0 extra: 0 forMode: nil];
}
/*
@ -1783,6 +1761,11 @@ process_modifier_flags(unsigned int state)
* Return mouse location in base coords ignoring the event loop
*/
- (NSPoint) mouselocation
{
return [self mouseLocationOnScreen: defScreen window: NULL];
}
- (NSPoint) mouseLocationOnScreen: (int)screen window: (int *)win
{
Window rootWin;
Window childWin;
@ -1793,13 +1776,43 @@ process_modifier_flags(unsigned int state)
unsigned mask;
BOOL ok;
NSPoint p;
ok = XQueryPointer (XDPY, [self xDisplayRootWindow],
int height;
int screen_number;
screen_number = (screen >= 0) ? screen : defScreen;
ok = XQueryPointer (dpy, [self xDisplayRootWindowForScreen: screen_number],
&rootWin, &childWin, &currentX, &currentY, &winX, &winY, &mask);
p = NSMakePoint(0,0);
if (ok)
p = NSMakePoint(-1,-1);
if (ok == False)
{
p = NSMakePoint(currentX, DisplayHeight(XDPY, XSCR) - currentY);
/* Mouse not on the specified screen_number */
XWindowAttributes attribs;
ok = XGetWindowAttributes(dpy, rootWin, &attribs);
if (ok == False)
{
return p;
}
screen_number = XScreenNumberOfScreen(attribs.screen);
if (screen >= 0 && screen != screen_number)
{
/* Mouse not on the requred screen, return an invalid point */
return p;
}
height = attribs.height;
}
else
height = DisplayHeight(dpy, screen_number);
p = NSMakePoint(currentX, height - currentY);
if (win)
{
gswindow_device_t *w = 0;
w = [XGServer _windowForXWindow: childWin];
if (w == NULL)
w = [XGServer _windowForXParent: childWin];
if (w)
*win = w->number;
else
*win = 0;
}
return p;
}

File diff suppressed because it is too large Load diff

View file

@ -82,6 +82,7 @@
- _initFromWrasterFile: (NSString *)filename number: (int)imageNumber
{
int screen;
RImage *image;
RContext *context;
@ -93,7 +94,8 @@
}
NSDebugLLog(@"NSImage", @"Loading %@ using wraster routines", filename);
context = [(XGContext *)GSCurrentContext() xrContext];
screen = [[[GSCurrentServer() screenList] objectAtIndex: 0] intValue];
context = [(XGServer *)GSCurrentServer() xrContextForScreen: screen];
image = RLoadImage(context, (char *)[filename cString], imageNumber);
if (!image)
{

View file

@ -106,37 +106,9 @@
/* Create a default gstate */
gstate = [[XGGState allocWithZone: [self zone]] initWithDrawContext: self];
drawMechanism = [(XGServer *)server drawMechanism];
return self;
}
/**
Returns the XGDrawMechanism, which roughly describes the depth of
the screen and how pixels should be drawn to the screen for maximum
speed.
*/
- (XGDrawMechanism) drawMechanism
{
return drawMechanism;
}
/**
Returns a pointer to a structure which describes aspects of the
X windows display
*/
- (void *) xrContext
{
return [(XGServer *)server xrContext];
}
/**
Returns a pointer to the X windows display variable
*/
- (Display *) xDisplay
{
return [(XGServer *)server xDisplay];
}
- (void) flushGraphics
{
XFlush([(XGServer *)server xDisplay]);

View file

@ -103,8 +103,7 @@ static Region emptyRegion;
{
[super initWithDrawContext: drawContext];
context = (void *)[(XGContext *)drawContext xrContext];
NSParameterAssert((RContext *)context);
drawMechanism = -1;
draw = 0;
alpha_buffer = 0;
color.field[AINDEX] = 1.0;
@ -145,6 +144,7 @@ static Region emptyRegion;
- (void) setWindowDevice: (void *)device
{
XGServer *srv;
gswindow_device_t *gs_win;
gs_win = (gswindow_device_t *)windevice = device;
@ -153,6 +153,11 @@ static Region emptyRegion;
alpha_buffer = 0;
drawingAlpha = NO;
/* We know the current server sent us this */
srv = (XGServer *)GSCurrentServer();
context = [srv xrContextForScreen: gs_win->screen];
drawMechanism = [srv drawMechanismForScreen: gs_win->screen];
if (gs_win != NULL && gs_win->alpha_buffer != 0)
{
alpha_buffer = gs_win->alpha_buffer;
@ -235,7 +240,12 @@ static Region emptyRegion;
float alpha = color.field[AINDEX];
color = acolor;
acolor = xrColorToRGB(acolor);
gcv.foreground = xrRGBToPixel((RContext *)context, acolor);
if (context == NULL)
{
/* Window device isn't set yet */
return;
}
gcv.foreground = xrRGBToPixel(context, acolor);
[self setGCValues: gcv withMask: GCForeground];
color.field[AINDEX] = alpha;
}
@ -484,12 +494,12 @@ static Region emptyRegion;
if (draw == dest_win->ident && dest_win->visibility < 0)
{
/* Non-backingstore window isn't visible, so just make up the image */
dest_im = RCreateXImage((RContext *)context, dest_win->depth,
dest_im = RCreateXImage(context, dest_win->depth,
XGWidth(drect), XGHeight(drect));
}
else
{
dest_im = RGetXImage((RContext *)context, draw, XGMinX(drect), XGMinY (drect),
dest_im = RGetXImage(context, draw, XGMinX(drect), XGMinY (drect),
XGWidth (drect), XGHeight (drect));
}
@ -534,7 +544,7 @@ static Region emptyRegion;
_pixmap_combine_alpha((RContext *)context, source_im, source_alpha,
dest_im, dest_alpha, xdrect,
op, [(XGContext *)drawcontext drawMechanism], delta);
op, drawMechanism, delta);
}
@ -1837,7 +1847,7 @@ typedef enum {
cspace, one_is_black,
isPlanar, hasAlpha, fast_min,
dest_im, dest_alpha, sr, dr,
0, [(XGContext *)drawcontext drawMechanism]);
0, drawMechanism);
/* Draw into the window/buffer */
RPutXImage((RContext *)context, draw, xgcntxt, dest_im, 0, 0,