Add cairo interface.

This commit is contained in:
jmsgrogan 2021-04-17 13:57:14 +01:00
parent a03eb9599f
commit 9bcc0ae88e
63 changed files with 1247 additions and 450 deletions

View file

@ -1,86 +1,70 @@
#pragma once
#include "Window.h"
#include <memory>
#include <map>
#include "Window.h"
#include "VisualLayer.h"
class DesktopManager;
using DesktopManagerPtr = std::shared_ptr<DesktopManager>;
class GlxInterface;
using GlxInterfacePtr = std::shared_ptr<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_screen_t;
struct xcb_connection_t;
struct xcb_key_press_event_t;
struct xcb_button_press_event_t;
struct xcb_expose_event_t;
struct _XDisplay;
class XcbInterface
{
private:
bool mUseOpenGl;
std::map<unsigned, mt::Window*> mWindows;
std::map<mt::Window*, unsigned> mHandles;
unsigned mDefaultWindow;
xcb_connection_t* mConnection;
xcb_screen_t* mScreen;
unsigned mGraphicsContext;
_XDisplay* mX11Display;
GlxInterfacePtr mGlxInterface;
public:
XcbInterface();
~XcbInterface();
void SetUseOpenGl(bool use);
void onPaint(DesktopManager* desktopManager);
void Initialize();
void InitializeOpenGl();
void CreateOpenGlDrawable(mt::Window* window);
void Initialize(DesktopManager* desktopManager);
void Loop(DesktopManager* desktopManager);
void LoopOpenGl(DesktopManager* desktopManager);
void ShutDown();
void AddWindow(mt::Window* window);
void ShowWindow(mt::Window* window);
void PaintWindow(mt::Window* window);
void AddWindow(mt::Window* window, DesktopManager* desktopManager);
void ClearWindow(mt::Window* window);
void CreateOpenGlDrawable(mt::Window* window);
private:
void onPaint(DesktopManager* desktopManager);
void InitializeOpenGl();
void Connect();
void UpdateScreen();
void UpdateScreen(DesktopManager* desktopManager);
void OnExposeEvent(xcb_expose_event_t* event, DesktopManager* desktopManager);
uint32_t GetEventMask();
void OnKeyPress(xcb_key_press_event_t* event, DesktopManager*);
void OnKeyRelease(xcb_key_press_event_t* event, DesktopManager*);
void OnButtonPress(xcb_button_press_event_t* event, DesktopManager*);
void OnButtonRelease(xcb_button_press_event_t* event, DesktopManager*);
void MapWindow(mt::Window* window);
void CreateGraphicsContext();
void CreateGraphicsContext(DesktopManager* desktopManager);
void onEventsDispatched(DesktopManager* desktopManager);
void OnLoopCompleted(DesktopManager* desktopManagers);
private:
bool mUseOpenGl {false};
xcb_connection_t* mConnection;
_XDisplay* mX11Display;
GlxInterfacePtr mGlxInterface;
XcbEventInterfacePtr mXcbEventInterface {nullptr};
XcbWindowInterfacePtr mXcbWindowInterface {nullptr};
};