AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
CommonRenderingContext.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include "IRenderingContext.h"
15#include <AUI/Platform/AWindow.h>
16#include "AUI/Traits/values.h"
17#include "ARenderingContextOptions.h"
18
19#if AUI_PLATFORM_LINUX
20#include <X11/Xlib.h>
21#include <X11/Xutil.h>
22#include <X11/keysymdef.h>
23#include <GL/gl.h>
24#include <GL/glx.h>
25#include <X11/Xatom.h>
26#endif
27
29public:
30#if AUI_PLATFORM_LINUX
31 static void ensureXLibInitialized();
33 static Screen* ourScreen;
34
35 static struct Atoms {
36 Atom wmProtocols;
37 Atom wmDeleteWindow;
38 Atom wmHints;
39 Atom wmState;
40 Atom netWmState;
41 Atom netWmStateMaximizedVert;
42 Atom netWmStateMaximizedHorz;
43 Atom clipboard;
44 Atom utf8String;
45 Atom textPlain;
46 Atom textPlainUtf8;
47 Atom auiClipboard;
48 Atom incr;
49 Atom targets;
50 Atom netWmSyncRequest;
51 Atom netWmSyncRequestCounter;
52 } ourAtoms;
53#endif
54#if AUI_PLATFORM_MACOS
55 void requestFrame();
56#endif
57
58 void init(const Init& init) override;
59
60 void beginPaint(AWindowBase& window) override;
61
62 void endPaint(AWindowBase& window) override;
63
64 ~CommonRenderingContext() override = default;
65
66 void destroyNativeWindow(AWindowBase& window) override;
67
68protected:
69#if AUI_PLATFORM_WIN
70
71 AString mWindowClass;
72
76 HDC mWindowDC;
77
81 HDC mPainterDC = nullptr;
82
83 PAINTSTRUCT mPaintstruct;
84#endif
85#if AUI_PLATFORM_LINUX
86 void initX11Window(const Init& init, XSetWindowAttributes& swa, XVisualInfo* vi);
87#endif
88#if AUI_PLATFORM_MACOS
89 AWindow* mWindow;
90 void* mDisplayLink;
91 bool mFrameScheduled = false;
92#endif
93
94 bool mSmoothResize = !(ARenderingContextOptions::get().flags & ARenderContextFlags::NO_SMOOTH);
95};
Represents a Unicode character string.
Definition: AString.h:37
Definition: AWindowBase.h:33
Represents a window in the underlying windowing system.
Definition: AWindow.h:45
Definition: CommonRenderingContext.h:28
Glue between AWindow and IRenderer.
Definition: IRenderingContext.h:36
Definition: values.h:52
Definition: IRenderingContext.h:38