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>
* Source/x11/XGServerWindow.m (-_checkStyle:): Correct code

View file

@ -63,6 +63,9 @@ typedef enum {
- (Window) xAppRootWindow;
- (void *) xrContextForScreen: (int)screen_number;
- (Visual *) visualForScreen: (int)screen_number;
- (int) depthForScreen: (int)screen_number;
- (XGDrawMechanism) drawMechanismForScreen: (int)screen_number;
- (void) getForScreen: (int)screen_number pixelFormat: (int *)bpp_number
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];
}
- (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
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;
}
static void test_xshm(Display *display, int drawing_depth)
static void test_xshm(Display *display, Visual *visual, int drawing_depth)
{
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);
ximage = XShmCreateImage(display,
DefaultVisual(display, DefaultScreen(display)),
ximage = XShmCreateImage(display, visual,
drawing_depth, ZPixmap, NULL, &shminfo,
1, 1);
XSync(display, False);
@ -166,11 +165,19 @@ no_xshm:
@implementation XWindowBuffer
+ (void) initialize
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
use_shape_hack = [ud boolForKey: @"XWindowBuffer-shape-hack"];
}
+ windowBufferForWindow: (gswindow_device_t *)awindow
depthInfo: (struct XWindowBuffer_depth_info_s *)aDI
{
int i;
XWindowBuffer *wi;
int drawing_depth;
Visual *visual;
for (i = 0; i < num_window_buffers; i++)
{
@ -205,6 +212,15 @@ no_xshm:
wi->window->gdriverProtocol = GDriverHandlesExpose | GDriverHandlesBacking;
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.
-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
@ -225,7 +241,6 @@ no_xshm:
wi->sx != awindow->xframe.size.width ||
wi->sy != awindow->xframe.size.height)
{
wi->sx = wi->window->xframe.size.width;
/* printf("%@ updating image for %p (%gx%g)\n", wi, wi->window,
wi->window->xframe.size.width, wi->window->xframe.size.height);*/
if (wi->ximage)
@ -269,16 +284,15 @@ no_xshm:
goto no_xshm;
if (!did_test_xshm)
test_xshm(wi->display, aDI->drawing_depth);
test_xshm(wi->display, visual, drawing_depth);
if (!use_xshm)
goto no_xshm;
/* Use XShm if possible, else fall back to normal XImage: s */
wi->use_shm = 1;
wi->ximage = XShmCreateImage(wi->display,
DefaultVisual(wi->display, DefaultScreen(wi->display)),
aDI->drawing_depth, ZPixmap, NULL, &wi->shminfo,
wi->ximage = XShmCreateImage(wi->display, visual,
drawing_depth, ZPixmap, NULL, &wi->shminfo,
wi->window->xframe.size.width,
wi->window->xframe.size.height);
if (!wi->ximage)
@ -330,7 +344,7 @@ no_xshm:
wi->ximage->data, &wi->shminfo,
wi->window->xframe.size.width,
wi->window->xframe.size.height,
aDI->drawing_depth);
drawing_depth);
if (wi->pixmap) /* TODO: this doesn't work */
{
XSetWindowBackgroundPixmap(wi->display, wi->window->ident,
@ -351,9 +365,10 @@ no_xshm:
{
no_xshm:
wi->use_shm = 0;
wi->ximage = XCreateImage(wi->display, DefaultVisual(wi->display,
DefaultScreen(wi->display)), aDI->drawing_depth, ZPixmap, 0, NULL,
wi->window->xframe.size.width, wi->window->xframe.size.height,
wi->ximage = XCreateImage(wi->display, visual, drawing_depth,
ZPixmap, 0, NULL,
wi->window->xframe.size.width,
wi->window->xframe.size.height,
8, 0);
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
{
int i;