]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/x11/x11_loop.cpp
Copyright fixes
[vlc] / modules / gui / skins2 / x11 / x11_loop.cpp
index b38f7ae137d2eb320f237297f3484561e8c7b186..f4b9888b1aa81e924edda5d3a43a831df47cd287 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * x11_loop.cpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: x11_loop.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  *          Olivier Teulière <ipkiss@via.ecp.fr>
@@ -31,6 +31,8 @@
 #include "x11_factory.hpp"
 #include "x11_timer.hpp"
 #include "../src/generic_window.hpp"
+#include "../src/theme.hpp"
+#include "../src/window_manager.hpp"
 #include "../events/evt_focus.hpp"
 #include "../events/evt_key.hpp"
 #include "../events/evt_mouse.hpp"
@@ -39,6 +41,7 @@
 #include "../events/evt_refresh.hpp"
 #include "../events/evt_scroll.hpp"
 #include "../commands/async_queue.hpp"
+#include "../utils/var_bool.hpp"
 #include "vlc_keys.h"
 
 
@@ -127,7 +130,10 @@ void X11Loop::run()
 
         // Wait for the next timer and execute it
         // The sleep is interrupted if an X11 event is received
-        pTimerLoop->waitNextTimer();
+        if( !m_exit )
+        {
+            pTimerLoop->waitNextTimer();
+        }
     }
 }
 
@@ -138,12 +144,6 @@ void X11Loop::exit()
 }
 
 
-void X11Loop::flush()
-{
-    XFlush( XDISPLAY );
-}
-
-
 void X11Loop::handleX11Event()
 {
     XEvent event;
@@ -152,9 +152,24 @@ void X11Loop::handleX11Event()
     // Look for the next event in the queue
     XNextEvent( XDISPLAY, &event );
 
+    if( event.xany.window == m_rDisplay.getMainWindow() )
+    {
+        if( event.type == MapNotify )
+        {
+            // When the "parent" window is mapped, show all the visible
+            // windows, as it is not automatic, unfortunately
+            Theme *pTheme = getIntf()->p_sys->p_theme;
+            if( pTheme )
+            {
+                pTheme->getWindowManager().synchVisibility();
+            }
+        }
+        return;
+    }
+
     // Find the window to which the event is sent
-    X11Factory *pFactory = (X11Factory*)X11Factory::instance( getIntf() );
-    GenericWindow *pWin = pFactory->m_windowMap[event.xany.window];
+    GenericWindow *pWin =
+        ((X11Factory*)pOsFactory)->m_windowMap[event.xany.window];
 
     if( !pWin )
     {
@@ -348,9 +363,9 @@ void X11Loop::handleX11Event()
             // Get the message type
             string type = XGetAtomName( XDISPLAY, event.xclient.message_type );
 
-            // Find the D&D object for this window
-            X11DragDrop *pDnd = (X11DragDrop*)
-                    retrievePointer( event.xany.window, "DND_OBJECT" );
+            // Find the DnD object for this window
+            X11DragDrop *pDnd =
+                ((X11Factory*)pOsFactory)->m_dndMap[event.xany.window];
             if( !pDnd )
             {
                 msg_Err( getIntf(), "No associated D&D object !!" );
@@ -375,34 +390,7 @@ void X11Loop::handleX11Event()
             }
             break;
         }
-
-        default:
-            // XXX
-            fprintf(stderr, "unknown event: %d\n", event.type );
-            break;
     }
 }
 
-
-void *X11Loop::retrievePointer( Window wnd, const char *pName )
-{
-    Atom typeRet;
-    int fmtRet;
-    unsigned long nRet, bRet;
-    unsigned char *propRet;
-    void *ptr;
-
-    // Retrieve the pointer on the generic window, which was
-    // stored as a window property
-    Atom prop = XInternAtom( XDISPLAY, pName, False );
-    Atom type = XInternAtom( XDISPLAY, "POINTER", False );
-    XGetWindowProperty( XDISPLAY, wnd, prop, 0,
-                        ((sizeof(void*)+3)/4), False, type,
-                        &typeRet, &fmtRet, &nRet, &bRet, &propRet );
-    memcpy( &ptr, propRet, sizeof(void*));
-    XFree( propRet );
-
-    return ptr;
-}
-
 #endif