BsLinuxPlatform.h 2.0 KB

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