In XwindowBuffer get the default visual and depth from the XGServer.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26961 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-10-24 16:42:38 +00:00
parent c6c8160a30
commit 1802f35b22
4 changed files with 312 additions and 283 deletions

View file

@ -1,3 +1,11 @@
2008-10-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServer.m (-visualForScreen:, -depthForScreen:):
New methods that hide RContext details.
* Headers/x11/XGServer.h: Declare these new methods.
* Source/x11/XWindowBuffer.m: Get the default visual and depth
from the XGServer.
2008-10-22 Fred Kiefer <FredKiefer@gmx.de> 2008-10-22 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (-_checkStyle:): Correct code * Source/x11/XGServerWindow.m (-_checkStyle:): Correct code

View file

@ -63,6 +63,9 @@ typedef enum {
- (Window) xAppRootWindow; - (Window) xAppRootWindow;
- (void *) xrContextForScreen: (int)screen_number; - (void *) xrContextForScreen: (int)screen_number;
- (Visual *) visualForScreen: (int)screen_number;
- (int) depthForScreen: (int)screen_number;
- (XGDrawMechanism) drawMechanismForScreen: (int)screen_number; - (XGDrawMechanism) drawMechanismForScreen: (int)screen_number;
- (void) getForScreen: (int)screen_number pixelFormat: (int *)bpp_number - (void) getForScreen: (int)screen_number pixelFormat: (int *)bpp_number
masks: (int *)red_mask : (int *)green_mask : (int *)blue_mask; masks: (int *)red_mask : (int *)green_mask : (int *)blue_mask;

View file

@ -518,6 +518,16 @@ _parse_display_name(NSString *name, int *dn, int *sn)
return [[self _screenContextForScreen: screen_number] context]; return [[self _screenContextForScreen: screen_number] context];
} }
- (Visual *) visualForScreen: (int)screen_number
{
return [[self _screenContextForScreen: screen_number] context]->visual;
}
- (int) depthForScreen: (int)screen_number
{
return [[self _screenContextForScreen: screen_number] context]->depth;
}
/** /**
Returns the XGDrawMechanism, which roughly describes the depth of Returns the XGDrawMechanism, which roughly describes the depth of
the screen and how pixels should be drawn to the screen for maximum the screen and how pixels should be drawn to the screen for maximum

View file

@ -57,7 +57,7 @@ static int test_xshm_error_handler(Display *d, XErrorEvent *ev)
return 0; return 0;
} }
static void test_xshm(Display *display, int drawing_depth) static void test_xshm(Display *display, Visual *visual, int drawing_depth)
{ {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
@ -93,8 +93,7 @@ static void test_xshm(Display *display, int drawing_depth)
old_error_handler = XSetErrorHandler(test_xshm_error_handler); old_error_handler = XSetErrorHandler(test_xshm_error_handler);
ximage = XShmCreateImage(display, ximage = XShmCreateImage(display, visual,
DefaultVisual(display, DefaultScreen(display)),
drawing_depth, ZPixmap, NULL, &shminfo, drawing_depth, ZPixmap, NULL, &shminfo,
1, 1); 1, 1);
XSync(display, False); XSync(display, False);
@ -166,11 +165,19 @@ no_xshm:
@implementation XWindowBuffer @implementation XWindowBuffer
+ (void) initialize
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
use_shape_hack = [ud boolForKey: @"XWindowBuffer-shape-hack"];
}
+ windowBufferForWindow: (gswindow_device_t *)awindow + windowBufferForWindow: (gswindow_device_t *)awindow
depthInfo: (struct XWindowBuffer_depth_info_s *)aDI depthInfo: (struct XWindowBuffer_depth_info_s *)aDI
{ {
int i; int i;
XWindowBuffer *wi; XWindowBuffer *wi;
int drawing_depth;
Visual *visual;
for (i = 0; i < num_window_buffers; i++) for (i = 0; i < num_window_buffers; i++)
{ {
@ -205,6 +212,15 @@ no_xshm:
wi->window->gdriverProtocol = GDriverHandlesExpose | GDriverHandlesBacking; wi->window->gdriverProtocol = GDriverHandlesExpose | GDriverHandlesBacking;
wi->window->gdriver = wi; wi->window->gdriver = wi;
#if 0
drawing_depth = aDI->drawing_depth;
visual = DefaultVisual(wi->display, DefaultScreen(wi->display));
#else
// Better to get the used visual from the XGServer.
visual = [(XGServer*)GSCurrentServer() visualForScreen: awindow->screen];
drawing_depth = [(XGServer*)GSCurrentServer() depthForScreen: awindow->screen];
#endif
/* TODO: resolve properly. /* TODO: resolve properly.
-x11 is creating buffers before I have a chance to tell it not to, so -x11 is creating buffers before I have a chance to tell it not to, so
I'm freeing them here to reduce memory consumption (and prevent I'm freeing them here to reduce memory consumption (and prevent
@ -225,7 +241,6 @@ no_xshm:
wi->sx != awindow->xframe.size.width || wi->sx != awindow->xframe.size.width ||
wi->sy != awindow->xframe.size.height) wi->sy != awindow->xframe.size.height)
{ {
wi->sx = wi->window->xframe.size.width;
/* printf("%@ updating image for %p (%gx%g)\n", wi, wi->window, /* printf("%@ updating image for %p (%gx%g)\n", wi, wi->window,
wi->window->xframe.size.width, wi->window->xframe.size.height);*/ wi->window->xframe.size.width, wi->window->xframe.size.height);*/
if (wi->ximage) if (wi->ximage)
@ -269,16 +284,15 @@ no_xshm:
goto no_xshm; goto no_xshm;
if (!did_test_xshm) if (!did_test_xshm)
test_xshm(wi->display, aDI->drawing_depth); test_xshm(wi->display, visual, drawing_depth);
if (!use_xshm) if (!use_xshm)
goto no_xshm; goto no_xshm;
/* Use XShm if possible, else fall back to normal XImage: s */ /* Use XShm if possible, else fall back to normal XImage: s */
wi->use_shm = 1; wi->use_shm = 1;
wi->ximage = XShmCreateImage(wi->display, wi->ximage = XShmCreateImage(wi->display, visual,
DefaultVisual(wi->display, DefaultScreen(wi->display)), drawing_depth, ZPixmap, NULL, &wi->shminfo,
aDI->drawing_depth, ZPixmap, NULL, &wi->shminfo,
wi->window->xframe.size.width, wi->window->xframe.size.width,
wi->window->xframe.size.height); wi->window->xframe.size.height);
if (!wi->ximage) if (!wi->ximage)
@ -330,7 +344,7 @@ no_xshm:
wi->ximage->data, &wi->shminfo, wi->ximage->data, &wi->shminfo,
wi->window->xframe.size.width, wi->window->xframe.size.width,
wi->window->xframe.size.height, wi->window->xframe.size.height,
aDI->drawing_depth); drawing_depth);
if (wi->pixmap) /* TODO: this doesn't work */ if (wi->pixmap) /* TODO: this doesn't work */
{ {
XSetWindowBackgroundPixmap(wi->display, wi->window->ident, XSetWindowBackgroundPixmap(wi->display, wi->window->ident,
@ -351,9 +365,10 @@ no_xshm:
{ {
no_xshm: no_xshm:
wi->use_shm = 0; wi->use_shm = 0;
wi->ximage = XCreateImage(wi->display, DefaultVisual(wi->display, wi->ximage = XCreateImage(wi->display, visual, drawing_depth,
DefaultScreen(wi->display)), aDI->drawing_depth, ZPixmap, 0, NULL, ZPixmap, 0, NULL,
wi->window->xframe.size.width, wi->window->xframe.size.height, wi->window->xframe.size.width,
wi->window->xframe.size.height,
8, 0); 8, 0);
wi->ximage->data = malloc(wi->ximage->height * wi->ximage->bytes_per_line); wi->ximage->data = malloc(wi->ximage->height * wi->ximage->bytes_per_line);
@ -688,13 +703,6 @@ static int warn = 0;
} }
+ (void) initialize
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
use_shape_hack = [ud boolForKey: @"XWindowBuffer-shape-hack"];
}
+ (void) _gotShmCompletion: (Drawable)d + (void) _gotShmCompletion: (Drawable)d
{ {
int i; int i;