3 #if defined(__unix__) || defined(__APPLE__)
4 #define property _property
9 #define Window X11Window
10 #define Cursor X11Cursor
12 #define Display X11Display
14 #define KeyCode X11KeyCode
15 #define Picture X11Picture
17 #include <X11/Xutil.h>
34 #if !defined(ECERE_VANILLA) && !defined(ECERE_NONET)
35 #if defined(__WIN32__)
37 #define WIN32_LEAN_AND_MEAN
39 static WSADATA wsaData;
41 #elif defined(__unix__) || defined(__APPLE__)
48 #include <netinet/in.h>
50 #include <sys/socket.h>
52 #include <sys/types.h>
54 #include <arpa/inet.h>
59 typedef struct hostent HOSTENT;
60 typedef struct sockaddr SOCKADDR;
61 typedef struct sockaddr_in SOCKADDR_IN;
62 typedef struct in_addr IN_ADDR;
63 #define closesocket(s) close(s)
70 #if defined(__unix__) || defined(__APPLE__)
76 GuiApplication guiApp;
79 enum GuiErrorCode : ErrorCode
81 driverNotSupported = ErrorCode { VeryFatal, 1 },
82 windowCreationFailed = ErrorCode { VeryFatal, 2 },
83 graphicsLoadingFailed = ErrorCode { VeryFatal, 3 },
84 modeSwitchFailed = ErrorCode { VeryFatal, 4 }
87 static char * errorMessages[] =
90 "Graphics driver not supported by any user interface system",
91 "Window creation failed",
92 "Window graphics loading failed",
93 "Driver/Mode switch failed"
96 public class GuiApplication : Application
105 subclass(Interface) interfaceDriver;
106 subclass(Skin) currentSkin;
113 bool fullScreenMode; // Needs to start at true for the desktop to resize
116 Resolution resolution;
117 PixelFormat pixelFormat;
120 char * defaultDisplayDriver;
122 Cursor systemCursors[SystemCursor];
126 OldList customCursors;
129 OldList windowTimers;
132 Window prevWindow; // Used for OnMouseLeave
133 Window windowCaptured;
135 // Mouse based moving & resizing
137 Point windowMovingStart;
138 Point windowMovingBefore;
139 Size windowResizingBefore;
141 bool windowIsResizing;
142 bool resizeX, resizeEndX;
143 bool resizeY, resizeEndY;
145 // Mouse based scrolling
146 Window windowScrolling;
147 Point windowScrollingBefore, windowScrollingStart;
150 Bitmap cursorBackground { };
151 int cursorBackgroundX, cursorBackgroundY;
152 int cursorBackgroundW, cursorBackgroundH;
158 Window acquiredWindow;
159 int acquiredMouseX, acquiredMouseY;
161 Cursor currentCursor;
163 uint errorLevel, lastErrorCode;
171 Window interimWindow;
175 uint timerResolution;
178 Point virtualScreenPos;
187 strcpy(appName, "ECERE Application");
192 // customCursors.offset = OFFSET(Cursor, prev);
193 windowTimers.offset = (uint)&((Timer)0).prev;
195 for(c = 0; c<SystemCursor::enumSize; c++)
196 systemCursors[c] = Cursor { systemCursor = c; };
198 globalSystem.eventSemaphore = Semaphore { };
199 globalSystem.fileMonitorMutex = Mutex { };
200 globalSystem.fileMonitors.offset = (uint)&((FileMonitor)0).prev;
211 customCursors.Clear();
213 #if defined(__unix__)
215 XUnlockDisplay(xGlobalDisplay);
222 interfaceDriver.Terminate();
225 // interfaceDrivers.Free(null);
231 for(c = 0; c<SystemCursor::enumSize; c++)
232 delete systemCursors[c];
234 #if !defined(ECERE_VANILLA) && !defined(ECERE_NONET)
238 delete globalSystem.eventSemaphore;
239 delete globalSystem.fileMonitorMutex;
240 delete globalSystem.fileMonitorThread;
242 UnapplySkin(class(Window));
248 Time time = GetTime();
251 for(timer = windowTimers.first; timer; timer = timer.next)
252 timer.dispatched = false;
255 for(timer = windowTimers.first; timer; timer = timer.next)
257 if(!timer.dispatched)
259 if((timer.delay - (Seconds)(time - timer.lastTime)) < Seconds { 0.00001 })
262 timer.lastTime = time;
263 if(timer.DelayExpired(timer.window))
265 timer.dispatched = true;
267 eInstance_DecRef(timer);
277 // --- Mouse-based window movement ---
278 void SetCurrentCursor(Cursor cursor)
280 currentCursor = cursor;
283 if(fullScreenMode && cursor.bitmap)
284 interfaceDriver.SetMouseCursor((SystemCursor)-1);
287 interfaceDriver.SetMouseCursor(cursor.systemCursor);
288 cursorBackground.Free();
294 void PreserveAndDrawCursor()
297 if(!acquiredWindow && cursorUpdate && currentCursor && currentCursor->bitmap)
301 Box against = {0,0, desktop.w-1,desktop.h-1};
302 Box box = {0, 0, currentCursor->bitmap->width,currentCursor->bitmap->height};
304 interfaceDriver->GetMousePosition(&mouseX, &mouseY);
306 mouseX -= currentCursor->hotSpotX;
307 mouseY -= currentCursor->hotSpotY;
309 // Preserve Background
310 if(!(eDisplay_GetFlags(desktop.display) & DISPLAY_FLIPPING))
312 cursorBackgroundX = mouseX;
313 cursorBackgroundY = mouseY;
314 cursorBackgroundW = currentCursor->bitmap->width;
315 cursorBackgroundH = currentCursor->bitmap->height;
316 eDisplay_Grab(desktop.display, cursorBackground,
317 mouseX, mouseY, cursorBackgroundW, cursorBackgroundH);
320 eBox_ClipOffset(&box, &against, mouseX, mouseY);
322 if(!(eDisplay_GetFlags(desktop.display) & DISPLAY_FLIPPING))
323 eDisplay_StartUpdate(desktop.display);
325 surface = eDisplay_GetSurface(desktop.display, mouseX, mouseY, &box);
328 eSurface_SetForeground(surface, WHITE);
329 eSurface_Blit(surface, currentCursor->bitmap, 0,0, 0,0,
330 currentCursor->bitmap->width,currentCursor->bitmap->height);
331 eInstance_Delete(surface);
333 if(!(eDisplay_GetFlags(desktop.display) & DISPLAY_FLIPPING))
338 box.bottom += mouseY;
339 eDisplay_Update(desktop.display, &box);
342 if(!(eDisplay_GetFlags(desktop.display) & DISPLAY_FLIPPING))
343 eDisplay_EndUpdate(desktop.display);
348 void RestoreCursorBackground()
351 // Restore Cursor Background
352 if(cursorBackground && desktop.active)
354 Box box = {0, 0, cursorBackgroundW-1,cursorBackgroundH-1};
355 Box against = {0,0, desktop.w-1,desktop.h-1};
358 eBox_ClipOffset(&box, &against, cursorBackgroundX, cursorBackgroundY);
359 if((surface = eDisplay_GetSurface(desktop.display, cursorBackgroundX,cursorBackgroundY, &box)))
361 eSurface_Blit(surface, cursorBackground, 0, 0, 0,0, cursorBackgroundW,cursorBackgroundH);
362 eInstance_Delete(surface);
368 bool IsModeSwitching()
370 return modeSwitching;
373 public bool SetDesktopPosition(int x, int y, int w, int h, bool moveChildren)
376 bool windowResized = desktop.size.w != w || desktop.size.h != h;
377 bool windowMoved = desktop.clientStart.x != x || desktop.clientStart.y != y;
379 if((windowResized || windowMoved) && moveChildren)
382 desktop.Position(x, y, w, h, true, true, true, true, false, false);
383 /*for(child = desktop.children.first; child; child = child.next)
385 if(!child.systemParent)
390 child.ComputeAnchors(
391 child.ax, child.ay, child.aw, child.ah,
393 child.Position(x, y, w, h, true, true, true, true, false);
395 if(child.state == Maximized)
399 child.ComputeAnchors(,
400 A_LEFT,A_LEFT,A_OFFSET,A_OFFSET,
402 child.Position(, x, y, w, h, false, true, true, true, false);
408 desktop.display.Lock(true);
411 if(!desktop.display.Resize(desktop.size.w, desktop.size.h))
414 desktop.dirty = true;
415 if(!desktop.display.flags.flipping)
416 desktop.Update(null);
418 // When does the desktop have a display in not fullscreen mode?
419 if(!fullScreenMode && !modeSwitching)
420 desktop.UpdateDisplay();
421 desktop.display.Unlock();
425 desktop.SetPosition(x, y, w, h, false, false, false);
429 void SetAppFocus(bool state)
431 // Shouldn't be property here
432 desktop.active = state;
435 bool SelectSkin(char * skinName)
441 for(link = class(Skin).derivatives.first; link; link = link.next)
444 if(skin.name && !strcmp(skin.name, skinName))
447 if(!link) skin = null;
451 if(skin != currentSkin || !currentSkin)
453 // Try finding a driver to support this mode
454 if(skin.textMode != textMode)
460 bool needReload = false;
462 if(!modeSwitching && currentSkin)
464 modeSwitching = true;
465 desktop.UnloadGraphics(true);
469 UnapplySkin(class(Window));
473 ApplySkin(class(Window), skin.name, null);
477 if(desktop.SetupDisplay())
478 if(desktop.LoadGraphics(false, true))
480 modeSwitching = false;
492 void Initialize(bool switchMode)
494 static bool initialized = false;
497 // if(!initialized && eClass_IsDerived(__ecereModule->app->module.inst.class, guiApplicationClass))
500 char * defaultDriver = null;
501 #if defined(ECERE_VANILLA)
502 char * driver = null;
505 // char * driver = getenv("ECERE_DRIVER");
506 char * driver = null;
507 static char driverStorage[1024];
508 GetEnvironment("ECERE_DRIVER", driverStorage, sizeof(driverStorage));
509 if(driverStorage[0]) driver = driverStorage;
513 fullScreenMode = true; // Needs to start at true for the desktop to resize
514 // Set this to true earlier so we can override it!
520 #if defined(__unix__)
522 XLockDisplay(xGlobalDisplay);
528 desktop = Window { };
531 desktop.childrenOrder.circ = true;
532 desktop.childrenCycle.circ = true;
533 desktop.background = blue;
534 desktop.rootWindow = desktop;
535 desktop.cursor = GetCursor(arrow);
536 desktop.caption = new char[strlen(appName) + 1];
537 strcpy(desktop.caption, appName);
538 *&desktop.visible = true;
539 desktop.position = Point { };
540 desktop.mutex = Mutex { };
541 desktop.created = true;
544 #if defined(__WIN32__)
547 defaultDriver = driver;
548 else if(this.isGUIApp && !textMode)
549 defaultDriver = "GDI";
551 defaultDriver = "Win32Console";
554 if(this.isGUIApp && !textMode)
556 char * display = getenv("DISPLAY");
558 if(!display || !display[0] || !SwitchMode(false, "X", 0, 0, 0, null, true))
559 defaultDriver = "NCurses";
560 // SwitchMode(true, "NCurses", 0, PixelFormatText, 0, null, true);
564 defaultDriver = driver;
567 defaultDriver = "NCurses";
572 SwitchMode(false, defaultDriver, 0, 0, 0, null, true);
576 #if defined(__WIN32__)
577 SwitchMode(true, "Win32Console", 0, PixelFormatText, 0, null, true);
582 SwitchMode(true, "SVGA", Res640x480, PixelFormat8, 0, null, true);
585 #if defined(__unix__) || defined(__APPLE__)
586 #if defined(ECERE_MINIGLX)
587 SwitchMode(true, "OpenGL", 0, 0, 0, null, true);
595 defaultDisplayDriver = defaultDriver;
600 virtual bool Init(void);
601 virtual bool Cycle(bool idle);
602 virtual void Terminate(void);
612 // better solution when designing tab order/activated window etc, why do windows move in the list?
615 for(window = desktop.children.first; window; window = window.next)
617 if(window.autoCreate && !window.created)
631 while(desktop && interfaceDriver)
635 if(terminateX != terminated)
637 terminated = terminateX;
643 //printf("Resetting terminate X to 0\n");
647 for(child = desktop.children.first; child; child = child.next)
648 if(child.created && child.visible)
652 for(window = desktop.children.first; window; window = window.next)
653 if(window.mutex) window.mutex.Wait();
655 for(window = desktop.children.first; window; window = window.next)
656 if(window.mutex) window.mutex.Release();
657 wait = !ProcessInput(true);
665 #if defined(__unix__)
667 XUnlockDisplay(xGlobalDisplay);
673 #if defined(__unix__)
675 XLockDisplay(xGlobalDisplay);
679 eInstance_DecRef(desktop);
687 #if defined(__unix__)
689 XUnlockDisplay(xGlobalDisplay);
697 interfaceDriver.Wait();
703 #if defined(__unix__)
705 XLockDisplay(xGlobalDisplay);
709 bool ProcessInput(bool useProcessAll)
715 #if !defined(ECERE_VANILLA) && !defined(ECERE_NONET)
716 ProcessNetworkEvents();
720 result = interfaceDriver.ProcessInput(useProcessAll && processAll);
721 if(!desktop || !interfaceDriver) return;
725 for(child = app.desktop.children.first; child; child = child.next)
726 if(child.created && child.visible)
728 if(!child) return result;
731 result |= UpdateTimers();
732 result |= ProcessFileNotifications();
735 result |= ProcessFileNotifications();
736 result |= UpdateTimers();
737 result |= interfaceDriver.ProcessInput(useProcessAll && processAll);
744 void UpdateDisplay(void)
746 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
747 if(Desktop3DUpdateDisplay()) return;
752 if(fullScreenMode && desktop.display)
754 desktop.mutex.Wait();
757 desktop.display.Lock(true);
759 if(desktop.dirty || cursorUpdate)
761 if(desktop.display.flags.flipping)
762 desktop.Update(null);
763 desktop.UpdateDisplay();
766 if(cursorUpdate || desktop.dirty)
768 PreserveAndDrawCursor();
769 cursorUpdate = false;
770 desktop.dirty = false;
771 RestoreCursorBackground();
774 desktop.display.Unlock();
776 desktop.mutex.Release();
782 for(window = desktop.children.first; window; window = window.next)
784 if(window.mutex) window.mutex.Wait();
785 if(window.visible && window.dirty)
787 // Logf("Updating %s\n", window.name);
788 interfaceDriver.Lock(window);
791 if(window.display.current)
795 window.display.Lock(true);
796 window.UpdateDisplay();
797 window.display.Unlock();
800 window.dirty = false;
801 interfaceDriver.Unlock(window);
803 Log("--------------\n");
807 if(window.mutex) window.mutex.Release();
815 globalSystem.eventSemaphore.Wait();
818 #if !defined(ECERE_VANILLA) && !defined(ECERE_NONET)
819 bool ProcessNetworkEvents()
821 bool gotEvent = false;
822 #if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
823 if(network.networkInitialized)
827 struct timeval tv = {0, 0};
832 PauseNetworkEvents();
833 network.mutex.Wait();
836 if(network.connectEvent || network.networkEvent)
837 Log("[P] [NProcess]\n");
839 rs = network.readSet;
840 ws = network.writeSet;
841 es = network.exceptSet;
843 if((network.ns && select(network.ns, &rs, &ws, &es, &tv)) || network.leftOverBytes)
845 network.leftOverBytes = false;
847 // Danger here? Why looping with a next and not unlocking anything?
848 for(socket = network.connectSockets.first; socket; socket = next)
851 if(!socket.processAlone && FD_ISSET(socket.s, &ws))
853 network.mutex.Release();
854 socket.connectThread.Wait();
855 network.mutex.Wait();
858 for(socket = network.sockets.first; socket; socket = next)
861 if(!socket.processAlone)
863 network.mutex.Release();
864 gotEvent |= socket.ProcessSocket(&rs, &ws, &es);
865 network.mutex.Wait();
869 for(service = network.services.first; service; service = nextService)
871 nextService = service.next;
872 if(!service.processAlone)
874 if(FD_ISSET(service.s, &rs))
877 Logf("[P] Accepting connection (%x)\n", service.s);
879 service.accepted = false;
881 if(!service.accepted)
885 int addrLen = sizeof(a);
886 s = accept(service.s,(SOCKADDR *)&a,&addrLen);
892 Log("[P] Connection accepted\n");
896 for(socket = service.sockets.first; socket; socket = next)
899 if(!socket.processAlone)
901 network.mutex.Release();
902 gotEvent |= socket.ProcessSocket(&rs, &ws, &es);
903 network.mutex.Wait();
908 if(network.connectEvent)
914 for(socket = network.connectSockets.first; socket; socket = next)
917 if(socket._connected && socket._connected != -2)
919 network.connectSockets.Remove(socket);
920 delete socket.connectThread;
922 // printf("%s is connected = %d\n", socket._class.name, socket._connected);
923 if(socket._connected == -1)
926 Logf("[P] Processing disconnected connect (%x)\n", socket.s);
929 if(socket.disconnectCode == ResolveFailed)
930 Logf("Error resolving address %s\n", socket.address);
932 if(socket.s == network.ns - 1)
933 Network_DetermineMaxSocket();
938 else if(socket._connected == 1)
941 Log("[P] Processing connected connect\n");
943 FD_CLR(socket.s, &network.writeSet);
944 FD_SET(socket.s, &network.readSet);
945 FD_SET(socket.s, &network.exceptSet);
946 network.mutex.Release();
948 // printf("Calling OnConnect on %s\n", socket._class.name);
950 network.mutex.Wait();
951 network.sockets.Add(socket);
959 network.connectEvent = false;
961 if(network.networkEvent)
963 network.networkEvent = false;
964 network.selectSemaphore.Release();
969 for(semPtr = network.mtSemaphores.first; semPtr; semPtr = semPtr.next)
971 ((Semaphore)semPtr.data).Release();
975 network.mutex.Release();
976 ResumeNetworkEvents();
982 void WaitNetworkEvent()
984 if(network.networkInitialized)
986 if(GetCurrentThreadID() == network.mainThreadID)
992 Semaphore semaphore { };
993 OldLink semPtr { data = semaphore };
994 network.mutex.Wait();
995 network.mtSemaphores.Add(semPtr);
996 network.mutex.Release();
998 ResumeNetworkEvents();
1000 PauseNetworkEvents();
1001 network.mutex.Wait();
1002 network.mtSemaphores.Delete(semPtr);
1003 network.mutex.Release();
1009 void PauseNetworkEvents()
1011 if(network.networkInitialized)
1013 network.processMutex.Wait();
1017 void ResumeNetworkEvents()
1019 if(network.networkInitialized)
1021 network.processMutex.Release();
1026 void SignalEvent(void)
1028 globalSystem.eventSemaphore.Release();
1031 // TODO: Might want to make this private with simpler public version?
1032 bool SwitchMode(bool fullScreen, char * driverName, Resolution resolution, PixelFormat colorDepth, int refreshRate, char * skinName, bool fallBack)
1034 bool result = false;
1037 bool fbFullScreen = 0;
1038 Resolution fbResolution = 0;
1039 PixelFormat fbColorDepth = 0;
1040 int fbRefreshRate = 0;
1041 subclass(Interface) inter;
1042 subclass(Skin) skin = null;
1048 for(link = class(Skin).derivatives.first; link; link = link.next)
1051 if(skin.name && !strcmp(skin.name, skinName))
1054 if(!link) skin = null;
1059 fbDriver = defaultDisplayDriver;
1060 inter = interfaceDriver;
1063 interfaceDriver.GetCurrentMode(&fbFullScreen, &fbResolution, &fbColorDepth, &fbRefreshRate);
1065 if(!driverName && !interfaceDriver)
1066 driverName = defaultDisplayDriver;
1068 if(driverName || (skin && skin.textMode != textMode))
1070 for(link = class(Interface).derivatives.first; link; link = link.next)
1072 bool foundDriver = false;
1074 char ** graphicsDrivers;
1077 graphicsDrivers = inter.GraphicsDrivers(&numDrivers);
1079 for(c=0; c<numDrivers; c++)
1080 if(!driverName || !strcmp(driverName, graphicsDrivers[c]))
1082 if(!skin || skin.textMode == IsDriverTextMode(graphicsDrivers[c]))
1084 driverName = graphicsDrivers[c];
1099 #if defined(__WIN32__)
1100 #if !defined(ECERE_VANILLA)
1101 if(!strcmp(driverName, "Win32Console")) inter = (subclass(Interface))class(Win32ConsoleInterface); else
1103 inter = (subclass(Interface))class(Win32Interface);
1105 if(!strcmp(driverName, "X")) inter = (subclass(Interface))class(XInterface);
1106 else inter = (subclass(Interface))class(NCursesInterface);
1111 if(interfaceDriver && (!driverName || (fbDriver && !strcmp(fbDriver, driverName))) &&
1112 fullScreen == fbFullScreen &&
1113 (!resolution || resolution == fbResolution) &&
1114 (!colorDepth || colorDepth == fbColorDepth) &&
1115 (!refreshRate || refreshRate == fbRefreshRate) &&
1116 (currentSkin && (!skinName || !strcmp(currentSkin.name, skinName))))
1120 bool wasFullScreen = fullScreenMode;
1121 subclass(Skin) oldSkin = currentSkin;
1124 modeSwitching = true;
1127 desktop.UnloadGraphics(true);
1129 if(inter != interfaceDriver)
1133 interfaceDriver.Terminate();
1135 result = inter.Initialize();
1143 interfaceDriver = inter;
1144 interfaceDriver.SetTimerResolution(timerResolution);
1145 inter.EnsureFullScreen(&fullScreen);
1146 fullScreenMode = fullScreen;
1148 if((!wasFullScreen && !fullScreen) ||
1149 inter.ScreenMode(fullScreen, resolution, colorDepth, refreshRate, &textMode))
1151 if(!fbDriver || (driverName && strcmp(fbDriver, driverName)))
1152 defaultDisplayDriver = driverName;
1154 if(!skinName || !SelectSkin(skinName))
1156 if(!currentSkin || currentSkin.textMode != textMode ||
1157 !SelectSkin(currentSkin.name))
1160 subclass(Skin) skin = null;
1162 for(link = class(Skin).derivatives.first; link; link = link.next)
1165 if(skin.textMode == textMode)
1168 if(!link) skin = null;
1171 SelectSkin(skin.name);
1175 if(currentSkin && desktop.SetupDisplay())
1177 desktop.active = true;
1181 desktop.display.Lock(false);
1182 desktop.display.Position(0,0);
1183 desktop.display.Unlock();
1186 if(desktop.LoadGraphics(false, oldSkin != currentSkin))
1190 desktop.UpdateDisplay();
1193 this.fullScreen = fullScreen;
1199 modeSwitching = false;
1201 LogErrorCode(modeSwitchFailed, driverName ? driverName : defaultDisplayDriver);
1204 LogErrorCode(driverNotSupported, driverName ? driverName : defaultDisplayDriver);
1206 if(!result && fallBack && fbDriver)
1208 if(!SwitchMode(fbFullScreen, fbDriver, fbResolution, fbColorDepth, fbRefreshRate, null, false))
1209 Log("Error falling back to previous video mode.\n");
1214 bool ProcessFileNotifications()
1216 bool activity = false;
1217 FileMonitor monitor, next;
1218 static int reentrant = 0;
1220 // printf("[%d] Waiting in ProcessFileNotifications for fileMonitor Mutex %x...\n", GetCurrentThreadID(), globalSystem.fileMonitorMutex);
1221 globalSystem.fileMonitorMutex.Wait();
1223 for(monitor = globalSystem.fileMonitors.first; monitor; monitor = next)
1227 next = monitor.next;
1230 if(!monitor.reentrant && !monitor.toBeFreed)
1232 monitor.reentrant = true;
1233 while((notify = monitor.fileNotifies.first))
1235 monitor.fileNotifies.Remove(notify);
1239 if(monitor.directory)
1241 if(!monitor.OnDirNotify(monitor.data, notify.action, notify.fileName, notify.param))
1242 monitor.StopMonitoring();
1246 if(!monitor.OnFileNotify(monitor.data, notify.action, notify.param))
1247 monitor.StopMonitoring();
1250 monitor.reentrant = false;
1256 monitor.reentrant = false;
1263 for(monitor = globalSystem.fileMonitors.first; monitor; monitor = next)
1265 next = monitor.next;
1266 if(monitor.toBeFreed && !monitor.reentrant)
1267 monitor.FreeMonitor();
1270 // printf("[%d] Releasing in ProcessFileNotifications fileMonitor Mutex %x...\n", GetCurrentThreadID(), globalSystem.fileMonitorMutex);
1271 globalSystem.fileMonitorMutex.Release();
1278 #if defined(__unix__)
1280 XLockDisplay(xGlobalDisplay);
1286 #if defined(__unix__)
1288 XUnlockDisplay(xGlobalDisplay);
1290 lockMutex.Release();
1293 Cursor GetCursor(SystemCursor cursor)
1295 return systemCursors[cursor];
1298 bool GetKeyState(Key key)
1300 return interfaceDriver.GetKeyState(key);
1303 bool GetMouseState(MouseButtons * buttons, int * x, int * y)
1305 return interfaceDriver.GetMouseState(buttons, x, y);
1309 property char * appName
1313 strcpy(appName, value);
1314 if(desktop) desktop.text = appName;
1318 return (char *)(this ? appName : null);
1321 property Semaphore semaphore { get { return globalSystem.eventSemaphore; } };
1322 property bool alwaysEmptyInput{ set { processAll = value; } get { return processAll; } };
1323 property bool fullScreen
1327 SwitchMode(value, defaultDisplayDriver, resolution,
1328 pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
1330 get { return this ? fullScreen : false; }
1332 property char * driver
1336 SwitchMode( fullScreen, value, resolution, pixelFormat, refreshRate,
1337 currentSkin ? currentSkin.name : null, true);
1339 get { return this ? defaultDisplayDriver : null; }
1341 property Resolution resolution
1345 SwitchMode(fullScreen, defaultDisplayDriver, value, pixelFormat, refreshRate,
1346 currentSkin ? currentSkin.name : null, true);
1348 get { return this ? resolution : 0; }
1350 property PixelFormat pixelFormat
1354 SwitchMode(fullScreen, defaultDisplayDriver, resolution,
1355 pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
1357 get { return this ? pixelFormat : 0; }
1359 property int refreshRate
1363 SwitchMode(fullScreen, defaultDisplayDriver, resolution,
1364 pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
1366 get { return this ? refreshRate : 0; }
1368 property char * skin
1370 set { SelectSkin(value); }
1371 get { return (this && currentSkin) ? currentSkin.name : null; }
1373 property bool textMode
1375 set { textMode = value; } // TODO: Implement switching
1376 get { return this ? textMode : false; }
1378 property Window desktop { get { return this ? desktop : null; } };
1379 property char ** drivers { get { return null; } };
1380 property char ** skins { get { return null; } };
1381 property subclass(Skin) currentSkin { get { return this ? currentSkin : null; } };
1382 property int numDrivers { get { return 0; } };
1383 property int numSkins { get { return 0; } };
1384 property uint timerResolution
1386 set { timerResolution = value; if(interfaceDriver) interfaceDriver.SetTimerResolution(value); }