ecere/src/gui/XInterface: (#678) System cursors support on X
[sdk] / ecere / src / gui / GuiApplication.ec
index f41d366..8ebc5e8 100644 (file)
@@ -47,6 +47,7 @@ default:
 #define set _set
 #include <sys/time.h>
 #include <unistd.h>
+#include <sys/select.h>
 
 #include <netinet/in.h>
 #include <netdb.h>
@@ -184,15 +185,15 @@ public class GuiApplication : Application
    char appName[1024];
    uint timerResolution;
 
-   Size virtualScreen;   
+   Size virtualScreen;
    Point virtualScreenPos;
 
-   int mainThread;
+   int64 mainThread;
 
    GuiApplication()
    {
       SystemCursor c;
-      
+
       mainThread = GetCurrentThreadID();
       if(!guiApp)
          guiApp = this;
@@ -302,16 +303,16 @@ public class GuiApplication : Application
    }
 
    // --- Mouse-based window movement ---
-   void SetCurrentCursor(Cursor cursor)
+   void SetCurrentCursor(Window window, Cursor cursor)
    {
       currentCursor = cursor;
       if(cursor)
       {
          if(fullScreenMode && cursor.bitmap)
-            interfaceDriver.SetMouseCursor((SystemCursor)-1);
+            interfaceDriver.SetMouseCursor(window ? window : desktop, (SystemCursor)-1);
          else
          {
-            interfaceDriver.SetMouseCursor(cursor.systemCursor);
+            interfaceDriver.SetMouseCursor(window ? window : desktop, cursor.systemCursor);
             cursorBackground.Free();
          }
       }
@@ -395,7 +396,7 @@ public class GuiApplication : Application
    bool IsModeSwitching()
    {
       return modeSwitching;
-   }  
+   }
 
    public bool SetDesktopPosition(int x, int y, int w, int h, bool moveChildren)
    {
@@ -434,11 +435,11 @@ public class GuiApplication : Application
                {
                   child.x = desktop.x;
                   child.y = desktop.y;
-                  child.ComputeAnchors(, 
-                     A_LEFT,A_LEFT,A_OFFSET,A_OFFSET, 
+                  child.ComputeAnchors(,
+                     A_LEFT,A_LEFT,A_OFFSET,A_OFFSET,
                      &x, &y, &w, &h);
                   child.Position(, x, y, w, h, false, true, true, true, false);
-               }           
+               }
             }
          }*/
          if(desktop.display)
@@ -465,7 +466,7 @@ public class GuiApplication : Application
    }
 
    void SetAppFocus(bool state)
-   {  
+   {
       // Shouldn't be property here
       desktop.active = state;
    }
@@ -475,7 +476,7 @@ public class GuiApplication : Application
       bool result = false;
       subclass(Skin) skin;
       OldLink link;
-      
+
       for(link = class(Skin).derivatives.first; link; link = link.next)
       {
          skin = link.data;
@@ -483,7 +484,7 @@ public class GuiApplication : Application
             break;
       }
       if(!link) skin = null;
-      
+
       if(skin)
       {
          if(skin != currentSkin || !currentSkin)
@@ -505,7 +506,7 @@ public class GuiApplication : Application
                }
 
                UnapplySkin(class(Window));
-               
+
                currentSkin = skin;
 
                ApplySkin(class(Window), skin.name, null);
@@ -716,7 +717,7 @@ public:
                if(!Cycle(wait))
                   wait = false;
 
-               if(wait) 
+               if(wait)
                   Wait();
                else
                {
@@ -794,7 +795,7 @@ public:
          result |= UpdateTimers();
          result |= ProcessFileNotifications();
          */
-         
+
          result |= ProcessFileNotifications();
          result |= UpdateTimers();
          result |= interfaceDriver.ProcessInput(useProcessAll && processAll);
@@ -809,7 +810,7 @@ public:
 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
       if(Desktop3DUpdateDisplay()) return;
 #endif
-      
+
       if(interfaceDriver)
       {
          if(fullScreenMode && desktop.display)
@@ -894,7 +895,7 @@ public:
 
          PauseNetworkEvents();
          network.mutex.Wait();
-         
+
    #ifdef DEBUG_SOCKETS
          if(network.connectEvent || network.networkEvent)
             Log("[P] [NProcess]\n");
@@ -1007,7 +1008,7 @@ public:
                         FD_SET(socket.s, &network.readSet);
                         FD_SET(socket.s, &network.exceptSet);
                         network.mutex.Release();
-                        
+
                         // printf("Calling OnConnect on %s\n", socket._class.name);
                         socket.OnConnect();
                         network.mutex.Wait();
@@ -1108,7 +1109,7 @@ public:
       if(skinName)
       {
          OldLink link;
-         
+
          for(link = class(Skin).derivatives.first; link; link = link.next)
          {
             skin = link.data;
@@ -1154,12 +1155,12 @@ public:
                break;
          }
          if(!link)
-            inter = null;      
+            inter = null;
       }
-   
+
       /*
       if(driverName)
-      {   
+      {
 #if defined(__WIN32__)
 #if !defined(ECERE_VANILLA)
          if(!strcmp(driverName, "Win32Console")) inter = (subclass(Interface))class(Win32ConsoleInterface); else
@@ -1172,7 +1173,7 @@ public:
       }
       */
 
-      if(interfaceDriver && (!driverName || (fbDriver && !strcmp(fbDriver, driverName))) && 
+      if(interfaceDriver && (!driverName || (fbDriver && !strcmp(fbDriver, driverName))) &&
          fullScreen == fbFullScreen &&
          (!resolution || resolution == fbResolution) &&
          (!colorDepth || colorDepth == fbColorDepth) &&
@@ -1214,7 +1215,7 @@ public:
             {
                if(!fbDriver || (driverName && strcmp(fbDriver, driverName)))
                   defaultDisplayDriver = driverName;
-      
+
                if(!skinName || !SelectSkin(skinName))
                {
                   if(!currentSkin || currentSkin.textMode != textMode ||
@@ -1222,7 +1223,7 @@ public:
                   {
                      OldLink link;
                      subclass(Skin) skin = null;
-                     
+
                      for(link = class(Skin).derivatives.first; link; link = link.next)
                      {
                         skin = link.data;
@@ -1243,7 +1244,7 @@ public:
                if(currentSkin && desktop.SetupDisplay())
                {
                   desktop.active = true;
-               
+
                   if(fullScreen)
                   {
                      desktop.display.Lock(false);
@@ -1284,10 +1285,10 @@ public:
       bool activity = false;
       FileMonitor monitor, next;
       static int reentrant = 0;
-      
+
       // Reentrant FileNotification is asking for trouble since each monitor is spawning a Modal() MessageBox
       if(reentrant) return false;
-      // printf("[%d] Waiting in ProcessFileNotifications for fileMonitor Mutex %x...\n", GetCurrentThreadID(), globalSystem.fileMonitorMutex);
+      // printf("[%d] Waiting in ProcessFileNotifications for fileMonitor Mutex %x...\n", (int)GetCurrentThreadID(), globalSystem.fileMonitorMutex);
       globalSystem.fileMonitorMutex.Wait();
       reentrant++;
       for(monitor = globalSystem.fileMonitors.first; monitor; monitor = next)
@@ -1298,7 +1299,7 @@ public:
          incref monitor;
          if(next)
             incref next;
-         
+
          if(!monitor.reentrant && !monitor.toBeFreed)
          {
             monitor.reentrant = true;
@@ -1343,7 +1344,7 @@ public:
                monitor.FreeMonitor();
          }
       }
-      // printf("[%d] Releasing in ProcessFileNotifications fileMonitor Mutex %x...\n", GetCurrentThreadID(), globalSystem.fileMonitorMutex);
+      // printf("[%d] Releasing in ProcessFileNotifications fileMonitor Mutex %x...\n", (int)GetCurrentThreadID(), globalSystem.fileMonitorMutex);
       globalSystem.fileMonitorMutex.Release();
       return activity;
    }
@@ -1380,7 +1381,7 @@ public:
    {
       return interfaceDriver.GetMouseState(buttons, x, y);
    }
-   
+
    // Properties
    property char * appName
    {
@@ -1400,7 +1401,7 @@ public:
    {
       set
       {
-         SwitchMode(value, defaultDisplayDriver, resolution, 
+         SwitchMode(value, defaultDisplayDriver, resolution,
             pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
       }
       get { return this ? fullScreen : false; }
@@ -1409,16 +1410,16 @@ public:
    {
       set
       {
-         SwitchMode( fullScreen, value, resolution, pixelFormat, refreshRate, 
+         SwitchMode( fullScreen, value, resolution, pixelFormat, refreshRate,
             currentSkin ? currentSkin.name : null, true);
-       } 
+       }
        get { return this ? defaultDisplayDriver : null; }
    };
    property Resolution resolution
    {
       set
       {
-         SwitchMode(fullScreen, defaultDisplayDriver, value, pixelFormat, refreshRate, 
+         SwitchMode(fullScreen, defaultDisplayDriver, value, pixelFormat, refreshRate,
             currentSkin ? currentSkin.name : null, true);
       }
       get { return this ? resolution : 0; }
@@ -1427,7 +1428,7 @@ public:
    {
       set
       {
-         SwitchMode(fullScreen, defaultDisplayDriver, resolution, 
+         SwitchMode(fullScreen, defaultDisplayDriver, resolution,
             pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
       }
       get { return this ? pixelFormat : 0; }
@@ -1436,7 +1437,7 @@ public:
    {
       set
       {
-         SwitchMode(fullScreen, defaultDisplayDriver, resolution, 
+         SwitchMode(fullScreen, defaultDisplayDriver, resolution,
             pixelFormat, refreshRate, currentSkin ? currentSkin.name : null, true);
       }
       get { return this ? refreshRate : 0; }
@@ -1459,6 +1460,6 @@ public:
    property int numSkins { get { return 0; } };
    property uint timerResolution
    {
-      set { timerResolution = value; if(interfaceDriver) interfaceDriver.SetTimerResolution(value); } 
+      set { timerResolution = value; if(interfaceDriver) interfaceDriver.SetTimerResolution(value); }
    };
 };