stuff-from-scratch/src/windows/ui_interfaces/x11/XcbInterface.h
2022-11-11 11:48:42 +00:00

64 lines
1.3 KiB
C++

#pragma once
#include "AbstractUiInterface.h"
#include <memory>
class GlxInterface;
using GlxInterfacePtr = std::unique_ptr<GlxInterface>;
class XcbEventInterface;
using XcbEventInterfacePtr = std::unique_ptr<XcbEventInterface>;
class XcbWindowInterface;
using XcbWindowInterfacePtr = std::unique_ptr<XcbWindowInterface>;
struct xcb_connection_t;
struct xcb_expose_event_t;
struct _XDisplay;
namespace mt
{
class Window;
}
class XcbInterface : public AbstractUIInterface
{
public:
XcbInterface(DesktopManager* desktopManager, bool useHardware = true);
~XcbInterface();
void initialize() override;
void loop() override;
void shutDown() override;
void showWindow(mt::Window* window) override;
void addWindow(mt::Window* window) override;
private:
void onPaint();
void onEventsDispatched();
void onLoopCompleted();
void onExposeEvent(xcb_expose_event_t* event);
void initializeOpenGl();
void createGraphicsContext();
void createOpenGlDrawable(mt::Window* window);
void connect();
void updateScreen();
void mapWindow(mt::Window* window);
uint32_t getEventMask();
private:
xcb_connection_t* mConnection;
_XDisplay* mX11Display;
GlxInterfacePtr mGlxInterface;
XcbEventInterfacePtr mXcbEventInterface {nullptr};
XcbWindowInterfacePtr mXcbWindowInterface {nullptr};
};