AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
PlatformAbstractionX11.h
    1#pragma once
    2
    3#include <AUI/Platform/linux/IPlatformAbstraction.h>
    4#include "AUI/Platform/ACursor.h"
    5
    6#include <X11/Xlib.h>
    7#include <X11/Xutil.h>
    8#include <X11/keysymdef.h>
    9#include <GL/gl.h>
   10#include <GL/glx.h>
   11#include <X11/Xatom.h>
   12#include <X11/extensions/sync.h>
   13
   14
   15class PlatformAbstractionX11: public IPlatformAbstraction {
   16public:
   17    static void ensureXLibInitialized();
   18    static aui::assert_not_used_when_null<Display*> ourDisplay;
   19    static Screen* ourScreen;
   20    void init() override;
   21
   22    static Window nativeHandle(AWindow& window) {
   23        return static_cast<Window>(window.getNativeHandle());
   24    }
   25
   26    static void setNativeHandle(AWindow& window, Window x11Window) {
   27        IPlatformAbstraction::nativeHandle(window) = x11Window;
   28    }
   29
   30    static struct Atoms {
   31        Atom wmProtocols;
   32        Atom wmDeleteWindow;
   33        Atom wmHints;
   34        Atom wmState;
   35        Atom netWmState;
   36        Atom netWmStateMaximizedVert;
   37        Atom netWmStateMaximizedHorz;
   38        Atom clipboard;
   39        Atom utf8String;
   40        Atom textPlain;
   41        Atom textPlainUtf8;
   42        Atom auiClipboard;
   43        Atom incr;
   44        Atom targets;
   45        Atom netWmSyncRequest;
   46        Atom netWmSyncRequestCounter;
   47    } ourAtoms;
   48
   49    ~PlatformAbstractionX11() override = default;
   50
   51    // CURSOR
   52    void applyNativeCursor(const ACursor &cursor, AWindow *pWindow) override;
   53    _<ACursor::Custom> createCustomCursor(AImageView image) override;
   54
   55    // CLIPBOARD
   56    void copyToClipboard(const AString& text) override;
   57    AString pasteFromClipboard() override;
   58
   59    // INPUT
   60    AInput::Key inputFromNative(int k) override;
   61    int inputToNative(AInput::Key key) override;
   62    bool inputIsKeyDown(AInput::Key k) override;
   63
   64    // PLATFORM/DESKTOP
   65    glm::ivec2 desktopGetMousePosition() override;
   66    void desktopSetMousePosition(glm::ivec2 pos) override;
   67    float platformGetDpiRatio() override;
   68
   69
   70    // WINDOW
   71    void windowSetStyle(AWindow& window, WindowStyle ws) override;
   72    float windowFetchDpiFromSystem(AWindow& window) override;
   73    void windowRestore(AWindow& window) override;
   74    void windowMinimize(AWindow& window) override;
   75    bool windowIsMinimized(AWindow& window) const override;
   76    bool windowIsMaximized(AWindow& window) const override;
   77    void windowMaximize(AWindow& window) override;
   78    glm::ivec2 windowGetPosition(AWindow& window) const override;
   79    void windowFlagRedraw(AWindow& window) override;
   80    void windowShow(AWindow& window) override;
   81    void windowSetSize(AWindow& window, glm::ivec2 size) override;
   82    void windowSetGeometry(AWindow& window, int x, int y, int width, int height) override;
   83    void windowSetIcon(AWindow& window, const AImage& image) override;
   84    void windowHide(AWindow& window) override;
   85    void windowManagerNotifyProcessMessages() override;
   86    void windowManagerLoop() override;
   87    void windowBlockUserInput(AWindow& window, bool blockUserInput) override;
   88    void windowAllowDragNDrop(AWindow& window) override;
   89    void windowShowTouchscreenKeyboardImpl(AWindow& window) override;
   90    void windowHideTouchscreenKeyboardImpl(AWindow& window) override;
   91    void windowMoveToCenter(AWindow& window) override;
   92    void windowQuit(AWindow& window) override;
   93    void windowAnnounceMinMaxSize(AWindow& window) override;
   94    void windowManagerInitNativeWindow(const IRenderingContext::Init& init) override;
   95    AMessageBox::ResultButton messageBoxShow(
   96        AWindow* parent, const AString& title, const AString& message, AMessageBox::Icon icon,
   97        AMessageBox::Button b) override;
   98
   99private:
  100    void xProcessEvent(XEvent& ev);
  101    void xClipboardClear();
  102    void xHandleClipboard(const XEvent& ev);
  103
  104    Pipe mNotifyPipe;
  105    std::atomic_bool mFastPathNotify = false;
  106};
Represents cursor type.
Definition ACursor.h:26
Non-owning read-only image representation of some format.
Definition AImageView.h:58
Owning image representation.
Definition AImage.h:25
Represents a Unicode character string.
Definition AString.h:38
Represents a window in the underlying windowing system.
Definition AWindow.h:45
Native pipe RAII wrapper.
Definition Pipe.h:37
Definition PlatformAbstractionX11.h:15
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
Definition values.h:56
ResultButton
Button that the user has clicked.
Definition AMessageBox.h:104
Button
Specifies button(s) to be displayed.
Definition AMessageBox.h:79
Icon
Specifies icon to be displayed.
Definition AMessageBox.h:51
Definition IRenderingContext.h:38