merge with/from trunk at r35190
[blender.git] / intern / ghost / intern / GHOST_SystemX11.cpp
index 961a637e6169178e6be6fe176dc0f9f197fd968b..09a4d9d4de262cd8a947c7e8fad44bcf26ef94af 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file ghost/intern/GHOST_SystemX11.cpp
+ *  \ingroup GHOST
+ */
+
+
 #include "GHOST_SystemX11.h"
 #include "GHOST_WindowX11.h"
 #include "GHOST_WindowManager.h"
 #include <X11/keysym.h>
 #include <X11/XKBlib.h> /* allow detectable autorepeate */
 
+#ifdef WITH_XF86KEYSYM
+#include <X11/XF86keysym.h>
+#endif
+
 #ifdef __sgi
 
 #if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
@@ -68,7 +77,7 @@
 #include <cstdlib> // for exit
 
 #ifndef PREFIX
-#  define PREFIX "/usr/local"
+#error "PREFIX not defined"
 #endif
 
 typedef struct NDOFPlatformInfo {
@@ -388,6 +397,10 @@ processEvents(
        
        bool anyProcessed = false;
        
+       if (playingEvents(&anyProcessed)) {
+               return anyProcessed;
+       }
+       
        do {
                GHOST_TimerManager* timerMgr = getTimerManager();
                
@@ -835,7 +848,10 @@ GHOST_SystemX11::
 getModifierKeys(
        GHOST_ModifierKeys& keys
 ) const {
-
+       if (this->playingEvents(NULL)) {
+               return getEventManager()->getModifierKeys(keys);
+       }
+       
        // analyse the masks retuned from XQueryPointer.
 
        memset((void *)m_keyboard_vector,0,sizeof(m_keyboard_vector));
@@ -851,6 +867,8 @@ getModifierKeys(
        const KeyCode control_r = XKeysymToKeycode(m_display,XK_Control_R);
        const KeyCode alt_l = XKeysymToKeycode(m_display,XK_Alt_L);
        const KeyCode alt_r = XKeysymToKeycode(m_display,XK_Alt_R);
+       const KeyCode super_l = XKeysymToKeycode(m_display,XK_Super_L);
+       const KeyCode super_r = XKeysymToKeycode(m_display,XK_Super_R);
 
        // Shift
        if ((m_keyboard_vector[shift_l >> 3] >> (shift_l & 7)) & 1) {
@@ -888,6 +906,15 @@ getModifierKeys(
        } else {
                keys.set(GHOST_kModifierKeyRightAlt,false);
        }
+
+       // Super (Windows) - only one GHOST-kModifierKeyOS, so mapping
+       // to either
+       if ( ((m_keyboard_vector[super_l >> 3] >> (super_l & 7)) & 1) || 
+            ((m_keyboard_vector[super_r >> 3] >> (super_r & 7)) & 1) ) {
+               keys.set(GHOST_kModifierKeyOS,true);
+       } else {
+               keys.set(GHOST_kModifierKeyOS,false);
+       }
        return GHOST_kSuccess;
 }
 
@@ -946,7 +973,11 @@ getCursorPosition(
        Window root_return, child_return;
        int rx,ry,wx,wy;
        unsigned int mask_return;
-
+       
+       if (playingEvents(NULL)) {
+               return getEventManager()->getCursorPosition(x, y);
+       }
+       
        if (XQueryPointer(
                m_display,
                RootWindow(m_display,DefaultScreen(m_display)),
@@ -1095,6 +1126,8 @@ convertXKey(
                        GXMAP(type,XK_Control_R,        GHOST_kKeyRightControl);
                        GXMAP(type,XK_Alt_L,            GHOST_kKeyLeftAlt);
                        GXMAP(type,XK_Alt_R,            GHOST_kKeyRightAlt);
+                       GXMAP(type,XK_Super_L,          GHOST_kKeyOS);
+                       GXMAP(type,XK_Super_R,          GHOST_kKeyOS);
 
                        GXMAP(type,XK_Insert,           GHOST_kKeyInsert);
                        GXMAP(type,XK_Delete,           GHOST_kKeyDelete);
@@ -1144,6 +1177,16 @@ convertXKey(
                        GXMAP(type,XK_KP_Multiply,      GHOST_kKeyNumpadAsterisk);
                        GXMAP(type,XK_KP_Divide,        GHOST_kKeyNumpadSlash);
 
+                       /* Media keys in some keyboards and laptops with XFree86/Xorg */
+#ifdef WITH_XF86KEYSYM
+                       GXMAP(type,XF86XK_AudioPlay,    GHOST_kKeyMediaPlay);
+                       GXMAP(type,XF86XK_AudioStop,    GHOST_kKeyMediaStop);
+                       GXMAP(type,XF86XK_AudioPrev,    GHOST_kKeyMediaFirst);
+                       GXMAP(type,XF86XK_AudioRewind,  GHOST_kKeyMediaFirst);
+                       GXMAP(type,XF86XK_AudioNext,    GHOST_kKeyMediaLast);
+                       GXMAP(type,XF86XK_AudioForward, GHOST_kKeyMediaLast);
+#endif
+
                                /* some extra sun cruft (NICE KEYBOARD!) */
 #ifdef __sun__
                        GXMAP(type,0xffde,                      GHOST_kKeyNumpad1);
@@ -1463,23 +1506,4 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        }
 }
 
-const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
-{
-       return (GHOST_TUns8*) PREFIX "/share";
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getUserDir() const
-{
-       char* env = getenv("HOME");
-       if(env) {
-               return (GHOST_TUns8*) env;
-       } else {
-               return NULL;
-       }
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getBinaryDir() const
-{
-       return NULL;
-}