Commit 65e0358c authored by Cyril Deguet's avatar Cyril Deguet

* fixed build of skins2 interface on MacOS X (renamed Rect into SkinsRect

  to avoid a conflict with Carbon API)
parent e7bb450d
......@@ -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
......
......@@ -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() );
}
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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,
......
......@@ -23,8 +23,29 @@
#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
......@@ -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
......@@ -24,10 +24,11 @@
#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
}
......
......@@ -28,13 +28,14 @@
// 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;
};
......
......@@ -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 );
}
......
......@@ -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;
};
......
......@@ -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 )
......
......@@ -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
......
......@@ -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;
......
......@@ -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(),
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++ )
......
......@@ -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
......
......@@ -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 )
{
}
......
......@@ -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; }
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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() );
}
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment