]> git.sesse.net Git - vlc/commitdiff
* fixed build of skins2 interface on MacOS X (renamed Rect into SkinsRect
authorCyril Deguet <asmax@videolan.org>
Sun, 25 Feb 2007 19:29:21 +0000 (19:29 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 25 Feb 2007 19:29:21 +0000 (19:29 +0000)
  to avoid a conflict with Carbon API)

22 files changed:
configure.ac
modules/gui/skins2/macosx/macosx_factory.cpp
modules/gui/skins2/macosx/macosx_factory.hpp
modules/gui/skins2/macosx/macosx_graphics.cpp
modules/gui/skins2/macosx/macosx_graphics.hpp
modules/gui/skins2/macosx/macosx_loop.cpp
modules/gui/skins2/macosx/macosx_loop.hpp
modules/gui/skins2/macosx/macosx_timer.cpp
modules/gui/skins2/macosx/macosx_timer.hpp
modules/gui/skins2/macosx/macosx_window.cpp
modules/gui/skins2/macosx/macosx_window.hpp
modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/os_factory.hpp
modules/gui/skins2/src/window_manager.cpp
modules/gui/skins2/src/window_manager.hpp
modules/gui/skins2/utils/position.cpp
modules/gui/skins2/utils/position.hpp
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/win32/win32_factory.hpp
modules/gui/skins2/x11/x11_factory.cpp
modules/gui/skins2/x11/x11_factory.hpp

index aeb1368234d86acbf7bcffd5153a31b4d1d6c109..b81eabdf13d214e098c028e4198e77d56fb43ee5 100644 (file)
@@ -4620,13 +4620,20 @@ if test "${enable_skins2}" = "yes" ||
     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
     VLC_ADD_LDFLAGS([skins2],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32])
 
+  else if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "darwin"); then
+    VLC_ADD_PLUGINS([skins2])
+    ALIASES="${ALIASES} svlc"
+    VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 -DMACOSX_SKINS])
+    VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
+    VLC_ADD_LDFLAGS([skins2],[-framework Carbon])
+
   else if test "${skins2_missing_lib}" = "no"; then
     VLC_ADD_PLUGINS([skins2])
     ALIASES="${ALIASES} svlc"
     VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} -DX11_SKINS])
     VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
     VLC_ADD_LDFLAGS([skins2],[${X_LIBS} ${X_PRE_LIBS} -lXext -lX11])
-  fi fi
+  fi fi fi
 fi
 
 
index be00008591b887338f5801267b3836ebdc7ceb36..3efac86e7b69037ca9f108a60d9b23ade1738bd8 100644 (file)
@@ -99,9 +99,9 @@ void MacOSXFactory::removeFromTaskBar()
     // TODO
 }
 
-OSTimer *MacOSXFactory::createOSTimer( const Callback &rCallback )
+OSTimer *MacOSXFactory::createOSTimer( CmdGeneric &rCmd )
 {
-    return new MacOSXTimer( getIntf(), rCallback );
+    return new MacOSXTimer( getIntf(), rCmd );
 }
 
 
@@ -139,10 +139,10 @@ int MacOSXFactory::getScreenHeight() const
 }
 
 
-Rect MacOSXFactory::getWorkArea() const
+SkinsRect MacOSXFactory::getWorkArea() const
 {
     // XXX
-    return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
+    return SkinsRect( 0, 0, getScreenWidth(), getScreenHeight() );
 }
 
 
index f2cd09a02fa03f2a5dc880150eba83c43178a63d..33d4f2d8a57cc0a8e9cf7a8bcf9e981d0bb1ce77 100644 (file)
@@ -47,7 +47,7 @@ class MacOSXFactory: public OSFactory
         virtual void destroyOSLoop();
 
         /// Instantiate an OSTimer with the given callback
-        virtual OSTimer *createOSTimer( const Callback &rCallback );
+        virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
 
         /// Minimize all the windows
         virtual void minimize();
@@ -90,7 +90,7 @@ class MacOSXFactory: public OSFactory
         virtual int getScreenHeight() const;
 
         /// Get the work area (screen area without taskbars)
-        virtual Rect getWorkArea() const;
+        virtual SkinsRect getWorkArea() const;
 
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const;
index 5e071e79e0dfe5718969a10c53a7213ae6e747ed..23aea45431919ae0c5f3a4c991646ab8048705f4 100644 (file)
@@ -24,6 +24,7 @@
 #ifdef MACOSX_SKINS
 
 #include "macosx_graphics.hpp"
+#include "macosx_window.hpp"
 
 
 MacOSXGraphics::MacOSXGraphics( intf_thread_t *pIntf, int width, int height ):
@@ -55,7 +56,7 @@ void MacOSXGraphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
 
 void MacOSXGraphics::drawBitmap( const GenericBitmap &rBitmap, int xSrc,
                                  int ySrc, int xDest, int yDest, int width,
-                                 int height )
+                                 int height, bool blend )
 {
     // TODO
 }
@@ -84,7 +85,18 @@ void MacOSXGraphics::applyMaskToWindow( OSWindow &rWindow )
 void MacOSXGraphics::copyToWindow( OSWindow &rWindow, int xSrc,  int ySrc,
                                 int width, int height, int xDest, int yDest )
 {
-    // TODO
+    // Get the graphics context
+    WindowRef win = ((MacOSXWindow&)rWindow).getWindowRef();
+    SetPortWindowPort( win );
+    GrafPtr port = GetWindowPort( win );
+    CGContextRef gc;
+    QDBeginCGContext( port, &gc );
+
+//    CGContextSetRGBFillColor( gc, 1, 0, 0, 1 );
+//    CGContextFillRect( gc, CGRectMake( 0, 0, 50, 50 ));
+
+    // Release the graphics context
+    QDEndCGContext( port, &gc );
 }
 
 
index e6ff84813a31b6e34a7cafde526a15dd3ff733af..9e78284c7af0433a2b08b60c21181787428e7475 100644 (file)
@@ -25,6 +25,7 @@
 #define MACOSX_GRAPHICS_HPP
 
 #include "../src/os_graphics.hpp"
+#include <Carbon/Carbon.h>
 
 class GenericWindow;
 class GenericBitmap;
@@ -48,7 +49,8 @@ class MacOSXGraphics: public OSGraphics
         /// Render a bitmap on this graphics
         virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
                                  int ySrc = 0, int xDest = 0, int yDest = 0,
-                                 int width = -1, int height = -1 );
+                                 int width = -1, int height = -1,
+                                                                bool blend = false );
 
         /// Draw a filled rectangle on the grahics (color is #RRGGBB)
         virtual void fillRect( int left, int top, int width, int height,
index 194067b0bfd68df83c0a3a2d5b52fe57f9f224a1..f36bad33411366079b7b561fdd24c27d60245f64 100644 (file)
 
 #ifdef MACOSX_SKINS
 
-#include <Carbon/Carbon.h>
 #include "macosx_loop.hpp"
+#include "macosx_window.hpp"
+#include "../src/generic_window.hpp"
+#include "../events/evt_refresh.hpp"
+
+static pascal OSStatus WinEventHandler( EventHandlerCallRef handler,
+                                        EventRef event, void *data )
+{
+    GenericWindow *pWin = (GenericWindow*)data;
+    intf_thread_t *pIntf = pWin->getIntf();
+
+    //fprintf(stderr, "event\n" );
+    UInt32 evclass = GetEventClass( event );
+    UInt32 evkind = GetEventKind( event );
+
+    switch( evclass )
+    {
+    case kEventClassWindow:
+        EvtRefresh evt( pIntf, 0, 0, -1, -1);
+        pWin->processEvent( evt );
+        break;
+    }
+}
 
 
 MacOSXLoop::MacOSXLoop( intf_thread_t *pIntf ):
@@ -64,41 +85,7 @@ void MacOSXLoop::run()
     // Main event loop
     while( !m_exit )
     {
-        EventRef pEvent;
-        OSStatus err = ReceiveNextEvent( 0, NULL, kEventDurationForever, true,
-                                         &pEvent );
-        if( err != noErr )
-        {
-            // Get the event type
-            UInt32 evClass = GetEventClass( pEvent );
-
-            switch( evClass )
-            {
-                case kEventClassMouse:
-                {
-                    break;
-                }
-
-                case kEventClassKeyboard:
-                {
-                    break;
-                }
-
-                case kEventClassWindow:
-                {
-                    handleWindowEvent( pEvent );
-                    break;
-                }
-
-                default:
-                {
-                    EventTargetRef pTarget;
-                    pTarget = GetEventDispatcherTarget();
-                    SendEventToEventTarget( pEvent, pTarget );
-                    ReleaseEvent( pEvent );
-                }
-            }
-        }
+        sleep(1);
     }
 }
 
@@ -109,11 +96,16 @@ void MacOSXLoop::exit()
 }
 
 
-void MacOSXLoop::handleWindowEvent( EventRef pEvent )
+void MacOSXLoop::registerWindow( GenericWindow &rGenWin, WindowRef win )
 {
-    UInt32 evKind = GetEventKind( pEvent );
-
+    // Create the event handler
+    EventTypeSpec evList[] = {
+        { kEventClassWindow, kEventWindowUpdate },
+        { kEventClassMouse, kEventMouseMoved }
+    };
+    EventHandlerUPP handler = NewEventHandlerUPP( WinEventHandler );
+    InstallWindowEventHandler( win, handler, GetEventTypeCount( evList ),
+                               evList, &rGenWin, NULL );
 }
 
-
 #endif
index 49eed8f356233cc9b945481bf825f791a30d5655..f818d5454e060c943d105f4bfe097b9c809564b0 100644 (file)
@@ -25,6 +25,7 @@
 #define MACOSX_LOOP_HPP
 
 #include "../src/os_loop.hpp"
+#include <Carbon/Carbon.h>
 
 class MacOSXDisplay;
 class GenericWindow;
@@ -45,15 +46,15 @@ class MacOSXLoop: public OSLoop
         /// Exit the main loop
         virtual void exit();
 
+        // Handle a window event
+        void registerWindow( GenericWindow &rGenWin, WindowRef win );
+
     private:
         // Private because it's a singleton
         MacOSXLoop( intf_thread_t *pIntf );
         virtual ~MacOSXLoop();
         // Flag set to exit the loop
         bool m_exit;
-
-        // Handle a window event
-        void handleWindowEvent( EventRef pEvent );
 };
 
 #endif
index bc78e840ebbd1d10da88968710bf21b572fcb039..7c1d7cd08ee0b171fe80617c5cc908d596df9c2e 100644 (file)
 #ifdef MACOSX_SKINS
 
 #include "macosx_timer.hpp"
+#include "../commands/cmd_generic.hpp"
 
 
-MacOSXTimer::MacOSXTimer( intf_thread_t *pIntf, const Callback &rCallback ):
-    OSTimer( pIntf ), m_callback( rCallback )
+MacOSXTimer::MacOSXTimer( intf_thread_t *pIntf,  CmdGeneric &rCmd ):
+    OSTimer( pIntf ), m_rCommand( rCmd )
 {
     // TODO
 }
index ef71b537c5e21d567360de5d3d9467e1b2baf02d..18ad9661b66c0aa761784bb0f17037ba22dc3103 100644 (file)
 
 // Forward declaration
 class MacOSXTimerLoop;
+class CmdGeneric;
 
 
 // MacOSX specific timer
 class MacOSXTimer: public OSTimer
 {
     public:
-        MacOSXTimer( intf_thread_t *pIntf, const Callback &rCallback );
+        MacOSXTimer( intf_thread_t *pIntf, CmdGeneric &rCmd );
         virtual ~MacOSXTimer();
 
         /// (Re)start the timer with the given delay (in ms). If oneShot is
@@ -45,8 +46,8 @@ class MacOSXTimer: public OSTimer
         virtual void stop();
 
     private:
-        /// Callback to execute
-        Callback m_callback;
+        /// Command to execute
+        CmdGeneric &m_rCommand;
 };
 
 
index ad88ead968f50c1d028cb8af2a667d47bb54e4b6..2e035df47a5ee5aa9b86d7c1ca77c97cf84f39f1 100644 (file)
@@ -24,6 +24,8 @@
 #ifdef MACOSX_SKINS
 
 #include "macosx_window.hpp"
+#include "macosx_loop.hpp"
+#include "../src/os_factory.hpp"
 
 
 MacOSXWindow::MacOSXWindow( intf_thread_t *pIntf, GenericWindow &rWindow,
@@ -31,43 +33,52 @@ MacOSXWindow::MacOSXWindow( intf_thread_t *pIntf, GenericWindow &rWindow,
                             MacOSXWindow *pParentWindow ):
     OSWindow( pIntf ), m_pParent( pParentWindow ), m_dragDrop( dragDrop )
 {
-    // TODO
+    // Create the window
+    Rect rect;
+    SetRect( &rect, 0, 0, 0, 0 );
+    CreateNewWindow( kDocumentWindowClass, kWindowNoShadowAttribute |
+                     kWindowNoTitleBarAttribute, &rect, &m_win );
+
+    // Create the event handler for this window
+    OSFactory *pOSFactory = OSFactory::instance( getIntf() );
+    ((MacOSXLoop*)pOSFactory->getOSLoop())->registerWindow( rWindow, m_win );
 }
 
 
 MacOSXWindow::~MacOSXWindow()
 {
-    // TODO
+    DisposeWindow( m_win );
 }
 
 
 void MacOSXWindow::show( int left, int top ) const
 {
-    // TODO
+    ShowWindow( m_win );
 }
 
 
 void MacOSXWindow::hide() const
 {
-    // TODO
+    HideWindow( m_win );
 }
 
 
 void MacOSXWindow::moveResize( int left, int top, int width, int height ) const
 {
-    // TODO
+    MoveWindow( m_win, left, top, false );
+    SizeWindow( m_win, width, height, true );
 }
 
 
 void MacOSXWindow::raise() const
 {
-    // TODO
+    SelectWindow( m_win );
 }
 
 
 void MacOSXWindow::setOpacity( uint8_t value ) const
 {
-    // TODO
+    SetWindowAlpha( m_win, (float)value / 255.0 );
 }
 
 
index a239358ca3221a795437953cf03a8c8d15924cb1..8c58d447510a59186c2c3e6e454fb432b4c670b7 100644 (file)
@@ -25,6 +25,7 @@
 #define MACOSX_WINDOW_HPP
 
 #include "../src/os_window.hpp"
+#include <Carbon/Carbon.h>
 
 class MacOSXDisplay;
 class MacOSXDragDrop;
@@ -59,11 +60,16 @@ class MacOSXWindow: public OSWindow
         /// Toggle the window on top
         virtual void toggleOnTop( bool onTop ) const;
 
+        /// Get the Carbon window handle
+        WindowRef getWindowRef() const { return m_win; };
+
     private:
         /// Parent window
         MacOSXWindow *m_pParent;
         /// Indicates whether the window handles drag&drop events
         bool m_dragDrop;
+        /// Carbon Window object
+        WindowRef m_win;
 };
 
 
index d899c7d6ea529601e382c5d756602cd3c5479fc0..68a16517535a20b2a479ea9c525809cac531195b 100644 (file)
@@ -165,7 +165,7 @@ void GenericLayout::onControlUpdate( const CtrlGeneric &rCtrl,
 void GenericLayout::resize( int width, int height )
 {
     // Update the window size
-    m_rect = Rect( 0, 0 , width, height );
+    m_rect = SkinsRect( 0, 0 , width, height );
 
     // Recreate a new image
     if( m_pImage )
index 822608fd0567f71c3b464757087d568829df0791..7574f1fc087ca01f9e4fd5cd2bd05d8fbbcf4719 100644 (file)
@@ -149,7 +149,7 @@ class GenericLayout: public SkinObject
         /// Parent window of the layout
         TopWindow *m_pWindow;
         /// Layout size
-        Rect m_rect;
+        SkinsRect m_rect;
         int m_minWidth, m_maxWidth;
         int m_minHeight, m_maxHeight;
         /// Image of the layout
index cced448cb9b1a737d7feb1c2677c1bf5cf38b4b1..c16d52ef4afb996c6f6a23ee6f9fdc346278a471 100644 (file)
@@ -121,7 +121,7 @@ class OSFactory: public SkinObject
         virtual int getScreenHeight() const = 0;
 
         /// Get the work area (screen area without taskbars)
-        virtual Rect getWorkArea() const = 0;
+        virtual SkinsRect getWorkArea() const = 0;
 
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const = 0;
index f7a268ea6fd6ba27d09d99b39f1bf29a9692d80b..b2ccf99913ed0479a4ce7d85e55b10cccb9020c3 100644 (file)
@@ -320,11 +320,11 @@ void WindowManager::resize( GenericLayout &rLayout,
 void WindowManager::maximize( TopWindow &rWindow )
 {
     // Save the current position/size of the window, to be able to restore it
-    m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(),
-                           rWindow.getLeft() + rWindow.getWidth(),
-                           rWindow.getTop() + rWindow.getHeight() );
+    m_maximizeRect = SkinsRect( rWindow.getLeft(), rWindow.getTop(),
+                               rWindow.getLeft() + rWindow.getWidth(),
+                               rWindow.getTop() + rWindow.getHeight() );
 
-    Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+    SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
     // Move the window
     startMove( rWindow );
     move( rWindow, workArea.getLeft(), workArea.getTop() );
@@ -486,7 +486,7 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
     AncList_t::const_iterator itAncMov, itAncSta;
 
     // Check magnetism with screen edges first (actually it is the work area)
-    Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+    SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
     // Iterate through the moving windows
     for( itMov = m_movingWindows.begin();
          itMov != m_movingWindows.end(); itMov++ )
index 74f839ebca3df6439c49017da6e18e2639211ac8..4cdca61d166533b005f73f803b3e429b55e7fd5c 100644 (file)
@@ -209,7 +209,7 @@ class WindowManager: public SkinObject
         /// Direction of the current resizing
         Direction_t m_direction;
         /// Rect of the last maximized window
-        Rect m_maximizeRect;
+        SkinsRect m_maximizeRect;
         /// Tooltip
         Tooltip *m_pTooltip;
         /// Active popup, if any
index 9a354108d93c2d5bad5f118ca7b3e7cebe3056aa..6ba21cb3c094dc8d7b52e57e12d8d515da42c49a 100644 (file)
@@ -28,7 +28,7 @@
 const string VarBox::m_type = "box";
 
 
-Rect::Rect( int left, int top, int right, int bottom ):
+SkinsRect::SkinsRect( int left, int top, int right, int bottom ):
     m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom )
 {
 }
index a1ae5737fde97f000328934ce6452d21c76dd547..aba4b4af70d2cf41296107cae08755c72241284c 100644 (file)
@@ -52,10 +52,10 @@ class GenericRect: public Box
 
 
 /// Characterization of a rectangle
-class Rect: public GenericRect
+class SkinsRect: public GenericRect
 {
     public:
-        Rect( int left, int top, int right, int bottom );
+        SkinsRect( int left, int top, int right, int bottom );
 
         virtual int getLeft() const { return m_left; }
         virtual int getTop() const { return m_top; }
index 94e8156cf107af11678d94ba0aee1a566267e047..bb03baa6286b83493091632e13fcf634ff963162 100644 (file)
@@ -365,12 +365,12 @@ int Win32Factory::getScreenHeight() const
 }
 
 
-Rect Win32Factory::getWorkArea() const
+SkinsRect Win32Factory::getWorkArea() const
 {
     RECT r;
     SystemParametersInfo( SPI_GETWORKAREA, 0, &r, 0 );
     // Fill a Rect object
-    Rect rect( r.left, r.top, r.right, r.bottom );
+    SkinsRect SkinsRect( r.left, r.top, r.right, r.bottom );
     return rect;
 }
 
index 42a181799ed4efba9d7fbc8697aba9c55c042b27..77904d239ec3164e88bcd9fc7145964df37198cd 100644 (file)
@@ -98,7 +98,7 @@ class Win32Factory: public OSFactory
         virtual int getScreenHeight() const;
 
         /// Get the work area (screen area without taskbars)
-        virtual Rect getWorkArea() const;
+        virtual SkinsRect getWorkArea() const;
 
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const;
index 405df09026ac05cf3ccf44ba0f04251f4c9f814a..c765aeffe76583aec308259f9124ab17b6fac56f 100644 (file)
@@ -170,10 +170,10 @@ int X11Factory::getScreenHeight() const
 }
 
 
-Rect X11Factory::getWorkArea() const
+SkinsRect X11Factory::getWorkArea() const
 {
     // XXX
-    return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
+    return SkinsRect( 0, 0, getScreenWidth(), getScreenHeight() );
 }
 
 
index bf99bbb3b3426c1b769389ac9d63820604d2113a..1825f3ca9c31a81208a4f538c70cef72e977adc3 100644 (file)
@@ -103,7 +103,7 @@ class X11Factory: public OSFactory
         virtual int getScreenHeight() const;
 
         /// Get the work area (screen area without taskbars)
-        virtual Rect getWorkArea() const;
+        virtual SkinsRect getWorkArea() const;
 
         /// Get the position of the mouse
         virtual void getMousePos( int &rXPos, int &rYPos ) const;