X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FX11.cc;h=ccbac132e885b8e2c8c29bb2040dd1795aa10a6b;hb=cf3587e2fd5966b7ebfd721d9413674224d1ad2a;hp=684f3bb363821dffdd779c13db4428bbc7e83ea4;hpb=be2d711e27133f883605d804cf23cf83bd258370;p=org.ibex.core.git diff --git a/src/org/xwt/plat/X11.cc b/src/org/xwt/plat/X11.cc index 684f3bb..ccbac13 100644 --- a/src/org/xwt/plat/X11.cc +++ b/src/org/xwt/plat/X11.cc @@ -1,8 +1,8 @@ // Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] // see below for copyright information on the second portion of this file -#include -#include +#include "POSIX.cc" + #include #include #include @@ -11,12 +11,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include @@ -35,15 +29,13 @@ #include #include -#include "POSIX.cc" - // static (per-xserver) data static Visual* visual; static Colormap s_colormap; static XStandardColormap* colormap_info; static XShmSegmentInfo shm_info; static Window selectionWindow; -static int shm_supported; +static int shm_supported = 0; static int shm_pixmaps_supported; static int screen_num; static int colorDepth = 0; @@ -141,7 +133,7 @@ void org::xwt::plat::X11$X11DoubleBuffer::slowDrawPicture(org::xwt::Picture* s, int targetpixel; switch (xi->bits_per_pixel) { case 8: targetpixel = (int)(*current_pixel); break; - case 16: targetpixel = (int)(*((u_int16_t*)current_pixel)); break; + case 16: targetpixel = (int)(*((uint16_t*)current_pixel)); break; case 24: targetpixel = (((int)*current_pixel) << 16) | (((int)*(current_pixel + 1)) << 8) | (((int)*(current_pixel + 2))); break; case 32: targetpixel = *((int*)current_pixel); break; default: org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!")); @@ -164,21 +156,21 @@ void org::xwt::plat::X11$X11DoubleBuffer::slowDrawPicture(org::xwt::Picture* s, red = ((source_red * colormap_info->red_max * alpha) + (red * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); green = ((source_green * colormap_info->green_max * alpha) + (green * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); blue = ((source_blue * colormap_info->blue_max * alpha) + (blue * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); - u_int32_t destpixel = red * colormap_info->red_mult + green * colormap_info->green_mult + + uint32_t destpixel = red * colormap_info->red_mult + green * colormap_info->green_mult + blue * colormap_info->blue_mult + colormap_info->base_pixel; switch (xi->bits_per_pixel) { case 8: *current_pixel = (char)(destpixel & 0xFF); break; - case 16: *((u_int16_t*)current_pixel) = (u_int16_t)destpixel; break; + case 16: *((uint16_t*)current_pixel) = (uint16_t)destpixel; break; case 24: { int offset = (int)current_pixel & 0x3; - u_int64_t dest = ((u_int64_t)destpixel) << (8 * offset); - u_int64_t mask = ((u_int64_t)0xffffff) << (8 * offset); - u_int64_t* base = (u_int64_t*)(current_pixel - offset); + uint64_t dest = ((uint64_t)destpixel) << (8 * offset); + uint64_t mask = ((uint64_t)0xffffff) << (8 * offset); + uint64_t* base = (uint64_t*)(current_pixel - offset); *base = (*base & ~mask) | dest; break; } - case 32: *((u_int32_t*)current_pixel) = destpixel; break; + case 32: *((uint32_t*)current_pixel) = destpixel; break; default: org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!")); } } @@ -585,8 +577,8 @@ void org::xwt::plat::X11$X11Surface::dispatchEvent(gnu::gcj::RawData* ev) { int x_out, y_out; XConfigureEvent* xce = (XConfigureEvent*)(e); XTranslateCoordinates(display, (*((Window*)window)), RootWindow(display, screen_num), 0, 0, &x_out, &y_out, &child); - if (xce->width != width || xce->height != height) SizeChange(xce->width, xce->height); - if (x_out != root->abs(0) || y_out != root->abs(1)) PosChange(x_out, y_out); + if (xce->width != root->width || xce->height != root->height) SizeChange(xce->width, xce->height); + if (x_out != root->x || y_out != root->y) PosChange(x_out, y_out); } } @@ -708,12 +700,19 @@ void org::xwt::plat::X11::natInit() { if (!XInitThreads()) org::xwt::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs")); - display = XOpenDisplay(NULL); + char* DISPLAY = getenv("DISPLAY"); + if (DISPLAY == NULL || strlen(DISPLAY) == 0) DISPLAY = ":0.0"; + display = XOpenDisplay(DISPLAY); + + if (display == 0) + org::xwt::Platform::criticalAbort(JvNewStringLatin1("Unable to connect to X11 display server")); + screen_num = XDefaultScreen(display); colorDepth = (jint)(DefaultDepth(((Display*)display), 0)); shm_info.shmaddr = NULL; - shm_supported = (XShmQueryExtension(display) == True); + // FIXME: SHM doesn't work on Darwin + //shm_supported = (XShmQueryExtension(display) == True); if (shm_supported) { X11ErrorHandler* oldHandler = XSetErrorHandler(errorHandler); XShmSegmentInfo sinfo;