| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "Platform/BsPlatform.h" |
| 6 | #include "Private/Linux/BsLinuxInput.h" |
| 7 | #include <X11/X.h> |
| 8 | #include <X11/Xlib.h> |
| 9 | |
| 10 | namespace bs |
| 11 | { |
| 12 | class LinuxWindow; |
| 13 | |
| 14 | /** @addtogroup Platform-Internal |
| 15 | * @{ |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * Contains various Linux specific platform functionality; |
| 20 | */ |
| 21 | class BS_CORE_EXPORT LinuxPlatform : public Platform |
| 22 | { |
| 23 | public: |
| 24 | /** Returns the active X11 display. */ |
| 25 | static ::Display* getXDisplay(); |
| 26 | |
| 27 | /** Returns the main X11 window. Caller must ensure the main window has been created. */ |
| 28 | static ::Window getMainXWindow(); |
| 29 | |
| 30 | /** Retruns the absolute path to the user's home directory. */ |
| 31 | static Path getHomeDir(); |
| 32 | |
| 33 | /** Locks access to the X11 system, not allowing any other thread to access it. Must be used for every X11 access. */ |
| 34 | static void lockX(); |
| 35 | |
| 36 | /** Unlocks access to the X11 system. Must follow every call to lockX(). */ |
| 37 | static void unlockX(); |
| 38 | |
| 39 | /** Notifies the system that a new window was created. */ |
| 40 | static void _registerWindow(::Window xWindow, LinuxWindow* window); |
| 41 | |
| 42 | /** Notifies the system that a window is about to be destroyed. */ |
| 43 | static void _unregisterWindow(::Window xWindow); |
| 44 | |
| 45 | /** Generates a X11 Pixmap from the provided pixel data. */ |
| 46 | static Pixmap createPixmap(const PixelData& data, UINT32 depth); |
| 47 | |
| 48 | /** Mutex for accessing buttonEvents / mouseEvent. */ |
| 49 | static Mutex eventLock; |
| 50 | |
| 51 | /** |
| 52 | * Stores events captured on the core thread, waiting to be processed by the main thread. |
| 53 | * Always lock on eventLock when accessing this. |
| 54 | */ |
| 55 | static Queue<LinuxButtonEvent> buttonEvents; |
| 56 | |
| 57 | /** |
| 58 | * Stores accumulated mouse motion events, waiting to be processed by the main thread. |
| 59 | * Always lock on eventLock when accessing this. |
| 60 | */ |
| 61 | static LinuxMouseMotionEvent mouseMotionEvent; |
| 62 | }; |
| 63 | |
| 64 | /** @} */ |
| 65 | } |
| 66 | |