mass rename and rebranding from xwt to ibex - fixed to use ixt files
[org.ibex.core.git] / src / org / ibex / plat / X11.cc
similarity index 93%
rename from src/org/xwt/plat/X11.cc
rename to src/org/ibex/plat/X11.cc
index 2bdb083..81e61fb 100644 (file)
 #include <X11/Xmu/StdCmap.h>
 
 #include <java/lang/String.h>
-#include <org/xwt/Surface.h>
-#include <org/xwt/Picture.h>
-#include <org/xwt/Box.h>
-#include <org/xwt/plat/X11.h>
-#include <org/xwt/plat/X11$X11Surface.h>
-#include <org/xwt/plat/X11$X11Picture.h>
-#include <org/xwt/plat/X11$X11PixelBuffer.h>
-#include <org/xwt/util/Semaphore.h>
-#include <org/xwt/Platform.h>
+#include <org/ibex/Surface.h>
+#include <org/ibex/Picture.h>
+#include <org/ibex/Box.h>
+#include <org/ibex/plat/X11.h>
+#include <org/ibex/plat/X11$X11Surface.h>
+#include <org/ibex/plat/X11$X11Picture.h>
+#include <org/ibex/plat/X11$X11PixelBuffer.h>
+#include <org/ibex/util/Semaphore.h>
+#include <org/ibex/Platform.h>
 #include <java/lang/Long.h>
 #include <java/util/Hashtable.h>
-#include <org/xwt/util/Log.h>
+#include <org/ibex/util/Log.h>
 
 #include <java/lang/System.h>
 #include <java/io/PrintStream.h>
@@ -66,9 +66,9 @@ static void ensureShmSize(int size) {
     }
 }
 
-void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s,
+void org::ibex::plat::X11$X11PixelBuffer::fastDrawPicture(org::ibex::Picture* s,
                                                          jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) {
-    org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
+    org::ibex::plat::X11$X11Picture* source = (org::ibex::plat::X11$X11Picture*)s;
 
     if (source->doublebuf->stipple != NULL) {
         XSetClipMask(display, (*((GC*)clipped_gc)), *((Pixmap*)source->doublebuf->stipple));
@@ -82,11 +82,11 @@ void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s,
               cx1 - dx, cy1 - dy, cx2 - cx1, cy2 - cy1, cx1, cy1);
 }
 
-void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
+void org::ibex::plat::X11$X11PixelBuffer::slowDrawPicture(org::ibex::Picture* s,
                                                          jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2,
                                                          jint rgb, jboolean alphaOnly) {
 
-    org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s;
+    org::ibex::plat::X11$X11Picture* source = (org::ibex::plat::X11$X11Picture*)s;
     XImage* xi; 
 
     // FASTEST: shared pixmap; twiddle bits in video ram directly
@@ -138,7 +138,7 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
                            (((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!"));
+                default: org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
                 }
                 targetpixel -= colormap_info->base_pixel;
 
@@ -173,7 +173,7 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
                 break;
             }
             case 32: *((uint32_t*)current_pixel) = destpixel; break;
-            default: org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
+            default: org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!"));
             }
         }
     }
@@ -191,7 +191,7 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s,
     }
 }
 
-void org::xwt::plat::X11$X11PixelBuffer::finalize() {
+void org::ibex::plat::X11$X11PixelBuffer::finalize() {
     if (shared_pixmap) {
         XShmSegmentInfo *sinfo = (XShmSegmentInfo*)shm_segment;
         XShmDetach(display, sinfo);
@@ -209,7 +209,7 @@ void org::xwt::plat::X11$X11PixelBuffer::finalize() {
     XFreeGC(display, *((GC*)clipped_gc));
 }
 
-void org::xwt::plat::X11$X11PixelBuffer::natInit() {
+void org::ibex::plat::X11$X11PixelBuffer::natInit() {
     
     if (width == 0 || height == 0) return;
     shared_pixmap &= shm_supported & shm_pixmaps_supported; // refuse to use shared pixmaps if we don't have shm
@@ -242,7 +242,7 @@ void org::xwt::plat::X11$X11PixelBuffer::natInit() {
     XChangeGC(display, (*((GC*)clipped_gc)), GCGraphicsExposures, &vm);
 }    
 
-void org::xwt::plat::X11$X11PixelBuffer::createStipple(org::xwt::plat::X11$X11Picture* xpi) {
+void org::ibex::plat::X11$X11PixelBuffer::createStipple(org::ibex::plat::X11$X11Picture* xpi) {
 
     stipple = (gnu::gcj::RawData*)malloc(sizeof(Pixmap));
     (*((Pixmap*)stipple)) = XCreatePixmap(display, RootWindow(display, screen_num), width, height, 1);
@@ -275,13 +275,13 @@ void org::xwt::plat::X11$X11PixelBuffer::createStipple(org::xwt::plat::X11$X11Pi
     XPutImage(display, (*((Pixmap*)stipple)), stipple_gc, &xi, 0, 0, 0, 0, width, height);
 }
 
-void org::xwt::plat::X11$X11Surface::blit(org::xwt::PixelBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
-    org::xwt::plat::X11$X11PixelBuffer *xdb = (org::xwt::plat::X11$X11PixelBuffer*)db;
+void org::ibex::plat::X11$X11Surface::blit(org::ibex::PixelBuffer* db, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
+    org::ibex::plat::X11$X11PixelBuffer *xdb = (org::ibex::plat::X11$X11PixelBuffer*)db;
     XCopyArea(display, *((Pixmap*)xdb->pm), *((Window*)window), *((GC*)gc), sx, sy, dx2 - dx, dy2 - dy, dx, dy);
     XFlush(display);
 }
 
-void org::xwt::plat::X11$X11PixelBuffer::fillRect (jint x, jint y, jint x2, jint y2, jint argb) {
+void org::ibex::plat::X11$X11PixelBuffer::fillRect (jint x, jint y, jint x2, jint y2, jint argb) {
     
     jint w = x2 - x;
     jint h = y2 - y;
@@ -304,9 +304,9 @@ void org::xwt::plat::X11$X11PixelBuffer::fillRect (jint x, jint y, jint x2, jint
 
 // X11Surface //////////////////////////////////////////////////////////////////////
 
-void org::xwt::plat::X11$X11Surface::setIcon(org::xwt::Picture* pic) {
-    org::xwt::plat::X11$X11Picture* p = ((org::xwt::plat::X11$X11Picture*)pic);
-    org::xwt::plat::X11$X11PixelBuffer* old_dbuf = p->doublebuf;
+void org::ibex::plat::X11$X11Surface::setIcon(org::ibex::Picture* pic) {
+    org::ibex::plat::X11$X11Picture* p = ((org::ibex::plat::X11$X11Picture*)pic);
+    org::ibex::plat::X11$X11PixelBuffer* old_dbuf = p->doublebuf;
     p->buildPixelBuffer(1);
     XWMHints xwmh;
     memset(&xwmh, 0, sizeof(XWMHints));
@@ -317,7 +317,7 @@ void org::xwt::plat::X11$X11Surface::setIcon(org::xwt::Picture* pic) {
     p->doublebuf = old_dbuf;
 }
 
-void org::xwt::plat::X11$X11Surface::setTitleBarText(java::lang::String* s) {
+void org::ibex::plat::X11$X11Surface::setTitleBarText(java::lang::String* s) {
     int len = min(JvGetStringUTFLength(s), 1024);
     char buf[len + 1];
     JvGetStringUTFRegion(s, 0, len, buf);
@@ -332,7 +332,7 @@ void org::xwt::plat::X11$X11Surface::setTitleBarText(java::lang::String* s) {
     XSetTextProperty(display, (*((Window*)window)), &tp, XA_WM_ICON_NAME);
 }
 
-void org::xwt::plat::X11$X11Surface::setLimits(jint minw, jint minh, jint maxw, jint maxh) {
+void org::ibex::plat::X11$X11Surface::setLimits(jint minw, jint minh, jint maxw, jint maxh) {
     XSizeHints hints;
     hints.min_width = minw;
     hints.min_height = minh;
@@ -342,35 +342,35 @@ void org::xwt::plat::X11$X11Surface::setLimits(jint minw, jint minh, jint maxw,
     XSetWMNormalHints(display, (*((Window*)window)), &hints);
 }
 
-void org::xwt::plat::X11$X11Surface::_setSize (jint width, jint height) {
+void org::ibex::plat::X11$X11Surface::_setSize (jint width, jint height) {
     if (width <= 0 || height <= 0) return;
     XResizeWindow(display, (*((Window*)window)), width, height);
     XFlush(display);
 }
 
-void org::xwt::plat::X11$X11Surface::setLocation () { XMoveWindow(display, (*((Window*)window)), root->x, root->y); }
-void org::xwt::plat::X11$X11Surface::toFront() { XRaiseWindow(display, (*((Window*)window))); }
-void org::xwt::plat::X11$X11Surface::toBack() { XLowerWindow(display, (*((Window*)window))); }
+void org::ibex::plat::X11$X11Surface::setLocation () { XMoveWindow(display, (*((Window*)window)), root->x, root->y); }
+void org::ibex::plat::X11$X11Surface::toFront() { XRaiseWindow(display, (*((Window*)window))); }
+void org::ibex::plat::X11$X11Surface::toBack() { XLowerWindow(display, (*((Window*)window))); }
 
-void org::xwt::plat::X11$X11Surface::_dispose() {
+void org::ibex::plat::X11$X11Surface::_dispose() {
     // without this we get phantom messages after the window is gone
-    org::xwt::plat::X11::windowToSurfaceMap->remove(new java::lang::Long(*((Window*)window)));
+    org::ibex::plat::X11::windowToSurfaceMap->remove(new java::lang::Long(*((Window*)window)));
     XDestroyWindow(display, (*((Window*)window)));
 }
 
-void org::xwt::plat::X11$X11Surface::setInvisible(jboolean i) {
+void org::ibex::plat::X11$X11Surface::setInvisible(jboolean i) {
     if (i) XUnmapWindow(display, (*((Window*)window)));
     else XMapRaised(display, (*((Window*)window)));
     XFlush(display);
 }
 
-void org::xwt::plat::X11$X11Surface::_setMinimized(jboolean b) {
+void org::ibex::plat::X11$X11Surface::_setMinimized(jboolean b) {
     if (b) XIconifyWindow(display, (*((Window*)window)), screen_num);
     else XMapRaised(display, (*((Window*)window)));
     XFlush(display);
 }
 
-void org::xwt::plat::X11$X11Surface::natInit() {
+void org::ibex::plat::X11$X11Surface::natInit() {
     XSetWindowAttributes xswa;
     window = (gnu::gcj::RawData*)malloc(sizeof(Window));
     xswa.bit_gravity = NorthWestGravity;
@@ -396,7 +396,7 @@ void org::xwt::plat::X11$X11Surface::natInit() {
     }
     
     XTextProperty tp;
-    tp.value = (unsigned char*)"XWT";
+    tp.value = (unsigned char*)"Ibex";
     tp.nitems = 3;
     tp.encoding = XA_STRING;
     tp.format = 8;
@@ -406,7 +406,7 @@ void org::xwt::plat::X11$X11Surface::natInit() {
     XSetWMProtocols(display, (*((Window*)window)), &proto, 1);
     
     XSelectInput(display, (*((Window*)window)), StructureNotifyMask);
-    org::xwt::plat::X11::windowToSurfaceMap->put(new java::lang::Long(*((Window*)window)), this);
+    org::ibex::plat::X11::windowToSurfaceMap->put(new java::lang::Long(*((Window*)window)), this);
 
     XEvent e;
     XMapRaised(display, (*((Window*)window)));
@@ -425,7 +425,7 @@ void org::xwt::plat::X11$X11Surface::natInit() {
 }
 
 
-void org::xwt::plat::X11$X11Surface::dispatchEvent(gnu::gcj::RawData* ev) {
+void org::ibex::plat::X11$X11Surface::dispatchEvent(gnu::gcj::RawData* ev) {
 
     XEvent* e = (XEvent*)ev;
     if (e->type == Expose) {
@@ -561,7 +561,7 @@ static Cursor crosshair_cursor, east_cursor, hand_cursor, move_cursor, north_cur
     northeast_cursor, northwest_cursor, south_cursor, southeast_cursor,
     southwest_cursor, text_cursor, west_cursor, wait_cursor, default_cursor;
 
-void org::xwt::plat::X11$X11Surface::syncCursor() {
+void org::ibex::plat::X11$X11Surface::syncCursor() {
     
     Cursor curs;
     if (cursor->equals(crosshair)) curs = crosshair_cursor;
@@ -586,13 +586,13 @@ void org::xwt::plat::X11$X11Surface::syncCursor() {
 
 // X11 ///////////////////////////////////////////////////////////////////
 
-jint org::xwt::plat::X11::_getScreenWidth() { return WidthOfScreen(DefaultScreenOfDisplay(display)); }
-jint org::xwt::plat::X11::_getScreenHeight() { return HeightOfScreen(DefaultScreenOfDisplay(display)); }
+jint org::ibex::plat::X11::_getScreenWidth() { return WidthOfScreen(DefaultScreenOfDisplay(display)); }
+jint org::ibex::plat::X11::_getScreenHeight() { return HeightOfScreen(DefaultScreenOfDisplay(display)); }
 
 static void dispatchSelectionEvent(XEvent* e) {
     if (e->type == SelectionNotify) {
         XSelectionEvent* xsn = (XSelectionEvent*)(e);
-        if (xsn->property == None) org::xwt::plat::X11::clipboard = JvNewStringLatin1("", 0);
+        if (xsn->property == None) org::ibex::plat::X11::clipboard = JvNewStringLatin1("", 0);
         else {
             Atom returntype;
             int returnformat;
@@ -602,10 +602,10 @@ static void dispatchSelectionEvent(XEvent* e) {
             XGetWindowProperty(display, xsn->requestor, xsn->property, 0, 4096,
                                True, AnyPropertyType, &returntype, &returnformat,
                                &numitems, &bytes_after, &ret);
-            org::xwt::plat::X11::clipboard =
+            org::ibex::plat::X11::clipboard =
                 (returntype == None ? JvNewStringLatin1("", 0) : JvNewStringLatin1((char*)ret, strlen((char*)ret)));
         }
-        org::xwt::plat::X11::waiting_for_selection_event->release();
+        org::ibex::plat::X11::waiting_for_selection_event->release();
         
     } else if (e->type == SelectionRequest) {
         XSelectionRequestEvent* xsr = (XSelectionRequestEvent*)(e);
@@ -620,9 +620,9 @@ static void dispatchSelectionEvent(XEvent* e) {
         xsn.property = xsr->property;
         xsn.time = xsr->time;
         
-        int len = min(1024, JvGetStringUTFLength(org::xwt::plat::X11::clipboard));
+        int len = min(1024, JvGetStringUTFLength(org::ibex::plat::X11::clipboard));
         char buf[len + 1];
-        JvGetStringUTFRegion(org::xwt::plat::X11::clipboard, 0, len, buf);
+        JvGetStringUTFRegion(org::ibex::plat::X11::clipboard, 0, len, buf);
         buf[len] = '\0';
         
         XChangeProperty(display, xsr->requestor, xsr->property, xsr->target, 8, PropModeReplace, (unsigned char*)buf, len + 1);
@@ -630,28 +630,28 @@ static void dispatchSelectionEvent(XEvent* e) {
     }        
 }
 
-void org::xwt::plat::X11::eventThread() {
+void org::ibex::plat::X11::eventThread() {
     XEvent e;
     while(true) {
         XNextEvent(display, &e);
         if (e.type == SelectionNotify || e.type == SelectionRequest) {
             dispatchSelectionEvent(&e);
         } else {
-            org::xwt::plat::X11$X11Surface* surface =
-                (org::xwt::plat::X11$X11Surface*)windowToSurfaceMap->get(new java::lang::Long(((XAnyEvent*)&e)->window));
+            org::ibex::plat::X11$X11Surface* surface =
+                (org::ibex::plat::X11$X11Surface*)windowToSurfaceMap->get(new java::lang::Long(((XAnyEvent*)&e)->window));
             if (surface != NULL) surface->dispatchEvent((gnu::gcj::RawData*)&e);
         }
     }
 }
 
-jstring org::xwt::plat::X11::_getClipBoard() {
+jstring org::ibex::plat::X11::_getClipBoard() {
     XConvertSelection(display, XA_PRIMARY, XA_STRING, XInternAtom(display, "VT_SELECTION", False), selectionWindow, CurrentTime);
     XFlush(display);
-    org::xwt::plat::X11::waiting_for_selection_event->block();
+    org::ibex::plat::X11::waiting_for_selection_event->block();
     return clipboard;
 }
 
-void org::xwt::plat::X11::_setClipBoard(jstring s) {
+void org::ibex::plat::X11::_setClipBoard(jstring s) {
     clipboard = s;
     int len = JvGetStringUTFLength(clipboard);
     char buf[len + 1];
@@ -667,17 +667,17 @@ int errorHandler(Display* d, XErrorEvent* e) {
     shm_supported = 0;
 }
 
-void org::xwt::plat::X11::natInit() {
+void org::ibex::plat::X11::natInit() {
 
     if (!XInitThreads())
-        org::xwt::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs"));
 
     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"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("Unable to connect to X11 display server"));
 
     screen_num = XDefaultScreen(display);
     colorDepth = (jint)(DefaultDepth(((Display*)display), 0));
@@ -731,36 +731,36 @@ void org::xwt::plat::X11::natInit() {
     visual = DefaultVisual(display, screen_num);
     char buf[255];
     sprintf(buf, "X11 DISPLAY: %s", XDisplayString(display));
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "X11 SHM:     %s", shm_supported ? "enabled" : "disabled");
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "X11 Visual:  %x %x %x bits: %i visualid: %i depth: %i",
             visual->red_mask, visual->green_mask, visual->blue_mask, visual->bits_per_rgb, visual->visualid, colorDepth);
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
 
     // FIXME: don't know why (True, False) is the best solution...
     if(XmuLookupStandardColormap(display, screen_num, visual->visualid, colorDepth, XA_RGB_BEST_MAP, True, False) == 0)
-        org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColormap failed"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColormap failed"));
     
     XStandardColormap* best_map_info = NULL;
     int count;
     if (XGetRGBColormaps(display, RootWindow(display, screen_num), &best_map_info, &count, XA_RGB_BEST_MAP) == 0)
-        org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: couldn't allocate a standard colormap"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: couldn't allocate a standard colormap"));
     if (!best_map_info->colormap)
-        org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColomap succeded, but no colormap was found on the root window"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: XmuLookupStandardColomap succeded, but no colormap was found on the root window"));
     if (best_map_info->red_max == 0)
-        org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: standard colormap exists, but was improperly allocated"));
+        org::ibex::Platform::criticalAbort(JvNewStringLatin1("ERROR: standard colormap exists, but was improperly allocated"));
     s_colormap = best_map_info->colormap;
     colormap_info = best_map_info;
 
     sprintf(buf, "            red_max / red_mult: %x %x", colormap_info->red_max, colormap_info->red_mult);
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            green_max / green_mult: %x %x", colormap_info->green_max, colormap_info->green_mult);
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            blue_max / blue_mult: %x %x", colormap_info->blue_max, colormap_info->blue_mult);
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
     sprintf(buf, "            base_pixel: %x", colormap_info->base_pixel);
-    org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
+    org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
 }