Skip to content

Commit 0473315

Browse files
committed
chore: tweak class names for consistency
Signed-off-by: Michael Pollind <mpollind@gmail.com>
1 parent e8d78d6 commit 0473315

17 files changed

+191
-212
lines changed

include/nbl/ui/CClipboardManagerXCB.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#ifndef _NBL_UI_C_CLIPBOARD_MANAGER_XCB_INCLUDED_
2+
#define _NBL_UI_C_CLIPBOARD_MANAGER_XCB_INCLUDED_
3+
4+
#include <string>
5+
#include <vector>
6+
#include <xcb/xproto.h>
7+
#ifdef _NBL_PLATFORM_LINUX_
8+
9+
#include "nbl/core/decl/Types.h"
10+
#include "nbl/ui/IClipboardManager.h"
11+
#include "nbl/ui/XCBConnection.h"
12+
13+
namespace nbl::ui
14+
{
15+
16+
// details on XCB clipboard protocol: https://tronche.com/gui/x/icccm/sec-2.html#s-2
17+
class NBL_API2 CClipboardManagerXCB final : public IClipboardManager
18+
{
19+
using base_t = IClipboardManager;
20+
public:
21+
inline CClipboardManagerXCB(core::smart_refctd_ptr<XCBConnection>&& connect):
22+
m_xcbConnection(std::move(connect)) {}
23+
24+
virtual std::string getClipboardText() override;
25+
virtual bool setClipboardText(const std::string_view& data) override;
26+
27+
void process(const IWindowXCB* window, xcb_generic_event_t* event);
28+
private:
29+
core::smart_refctd_ptr<XCBConnection> m_xcbConnection;
30+
31+
struct {
32+
std::string m_data;
33+
std::vector<xcb_atom_t> m_formats;
34+
} m_stagedClipboard;
35+
36+
std::mutex m_clipboardMutex;
37+
std::condition_variable m_clipboardResponseCV;
38+
std::string m_clipboardResponse;
39+
40+
XCBConnection::XCBAtomToken<core::StringLiteral("CLIPBOARD")> m_CLIPBOARD;
41+
XCBConnection::XCBAtomToken<core::StringLiteral("TARGETS")> m_TARGETS;
42+
XCBConnection::XCBAtomToken<core::StringLiteral("INCR")> m_INCR;
43+
44+
XCBConnection::XCBAtomToken<core::StringLiteral("UTF8_STRING")> m_formatUTF8_0;
45+
XCBConnection::XCBAtomToken<core::StringLiteral("text/plain;charset=utf-8")> m_formatUTF8_1;
46+
XCBConnection::XCBAtomToken<core::StringLiteral("text/plain;charset=UTF-8")> m_formatUTF8_2;
47+
XCBConnection::XCBAtomToken<core::StringLiteral("GTK_TEXT_BUFFER_CONTENTS")> m_formatGTK;
48+
XCBConnection::XCBAtomToken<core::StringLiteral("STRING")> m_formatString;
49+
XCBConnection::XCBAtomToken<core::StringLiteral("TEXT")> m_formatText;
50+
XCBConnection::XCBAtomToken<core::StringLiteral("text/plain")> m_formatTextPlain;
51+
};
52+
53+
}
54+
55+
#endif
56+
57+
#endif

include/nbl/ui/CClipboardManagerXcb.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

include/nbl/ui/CCursorControlXcb.h renamed to include/nbl/ui/CCursorControlXCB.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44

55
#include "nbl/ui/ICursorControl.h"
6-
#include "nbl/ui/XcbConnection.h"
6+
#include "nbl/ui/XCBConnection.h"
77

88
#ifdef _NBL_PLATFORM_LINUX_
99

1010
namespace nbl::ui
1111
{
12-
class NBL_API2 CCursorControlXcb final : public ICursorControl
12+
class NBL_API2 CCursorControlXCB final : public ICursorControl
1313
{
14-
core::smart_refctd_ptr<XcbConnection> m_xcbConnection;
14+
core::smart_refctd_ptr<XCBConnection> m_xcbConnection;
1515

1616
public:
17-
inline CCursorControlXcb(
18-
core::smart_refctd_ptr<XcbConnection>&& xcbConnection) :
17+
inline CCursorControlXCB(
18+
core::smart_refctd_ptr<XCBConnection>&& xcbConnection) :
1919
m_xcbConnection(std::move(xcbConnection)) {}
2020

2121
void setVisible(bool visible) override;

include/nbl/ui/CWindowManagerXcb.h renamed to include/nbl/ui/CWindowManagerXCB.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ NBL_SYSTEM_DECLARE_DYNAMIC_FUNCTION_CALLER_CLASS(XcbIcccm, system::DefaultFuncPt
5959
xcb_icccm_set_wm_normal_hints
6060
);
6161

62-
class CWindowManagerXcb : public IWindowManager
62+
class CWindowManagerXCB : public IWindowManager
6363
{
6464
public:
6565

@@ -73,8 +73,8 @@ class CWindowManagerXcb : public IWindowManager
7373
return SDisplayInfo();
7474
}
7575

76-
CWindowManagerXcb();
77-
~CWindowManagerXcb() override = default;
76+
CWindowManagerXCB();
77+
~CWindowManagerXCB() override = default;
7878

7979
virtual core::smart_refctd_ptr<IWindow> createWindow(IWindow::SCreationParams&& creationParams) override;
8080

include/nbl/ui/CWindowXcb.h renamed to include/nbl/ui/CWindowXCB.h

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#include <cstdlib>
55

66
#include "nbl/core/decl/smart_refctd_ptr.h"
7-
#include "nbl/ui/CClipboardManagerXcb.h"
8-
#include "nbl/ui/IWindowXcb.h"
9-
#include "nbl/ui/XcbConnection.h"
7+
#include "nbl/ui/CClipboardManagerXCB.h"
8+
#include "nbl/ui/IWindowXCB.h"
9+
#include "nbl/ui/XCBConnection.h"
1010

1111
namespace nbl::ui
1212
{
1313

14-
class CCursorControlXcb;
15-
class CWindowManagerXcb;
16-
class CClipboardManagerXcb;
14+
class CCursorControlXCB;
15+
class CWindowManagerXCB;
16+
class CClipboardManagerXCB;
1717

18-
class NBL_API2 CWindowXcb final : public IWindowXcb
18+
class NBL_API2 CWindowXCB final : public IWindowXCB
1919
{
2020

2121
public:
22-
CWindowXcb(core::smart_refctd_ptr<CWindowManagerXcb>&& winManager, SCreationParams&& params);
23-
~CWindowXcb();
22+
CWindowXCB(core::smart_refctd_ptr<CWindowManagerXCB>&& winManager, SCreationParams&& params);
23+
~CWindowXCB();
2424

2525
// Display* getDisplay() const override { return m_dpy; }
2626
xcb_window_t getXcbWindow() const override { return m_xcbWindow; }
@@ -41,18 +41,18 @@ class NBL_API2 CWindowXcb final : public IWindowXcb
4141
virtual void setCaption(const std::string_view& caption) override;
4242

4343
private:
44-
CWindowXcb(core::smart_refctd_ptr<system::ISystem>&& sys, uint32_t _w, uint32_t _h, E_CREATE_FLAGS _flags);
44+
CWindowXCB(core::smart_refctd_ptr<system::ISystem>&& sys, uint32_t _w, uint32_t _h, E_CREATE_FLAGS _flags);
4545

46-
core::smart_refctd_ptr<CWindowManagerXcb> m_windowManager;
47-
core::smart_refctd_ptr<XcbConnection> m_xcbConnection;
48-
core::smart_refctd_ptr<CCursorControlXcb> m_cursorControl;
49-
core::smart_refctd_ptr<CClipboardManagerXcb> m_clipboardManager;
46+
core::smart_refctd_ptr<CWindowManagerXCB> m_windowManager;
47+
core::smart_refctd_ptr<XCBConnection> m_xcbConnection;
48+
core::smart_refctd_ptr<CCursorControlXCB> m_cursorControl;
49+
core::smart_refctd_ptr<CClipboardManagerXCB> m_clipboardManager;
5050

5151
class CDispatchThread final : public system::IThreadHandler<CDispatchThread>
5252
{
5353
public:
5454

55-
inline CDispatchThread(CWindowXcb& window);
55+
inline CDispatchThread(CWindowXCB& window);
5656
inline ~CDispatchThread() {
5757
}
5858

@@ -63,20 +63,19 @@ class NBL_API2 CWindowXcb final : public IWindowXcb
6363
inline bool wakeupPredicate() const { return true; }
6464
inline bool continuePredicate() const { return true; }
6565
private:
66-
CWindowXcb& m_window;
67-
// xcb_connection_t* m_connection = nullptr;
68-
friend class CWindowXcb;
66+
CWindowXCB& m_window;
67+
friend class CWindowXCB;
6968
} m_dispatcher;
7069

7170
xcb_window_t m_xcbWindow = 0;
7271

73-
XcbConnection::XCBAtomToken<core::StringLiteral("WM_DELETE_WINDOW")> m_WM_DELETE_WINDOW;
74-
XcbConnection::XCBAtomToken<core::StringLiteral("WM_PROTOCOLS")> m_WM_PROTOCOLS;
75-
XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_PING")> m_NET_WM_PING;
72+
XCBConnection::XCBAtomToken<core::StringLiteral("WM_DELETE_WINDOW")> m_WM_DELETE_WINDOW;
73+
XCBConnection::XCBAtomToken<core::StringLiteral("WM_PROTOCOLS")> m_WM_PROTOCOLS;
74+
XCBConnection::XCBAtomToken<core::StringLiteral("_NET_WM_PING")> m_NET_WM_PING;
7675

77-
XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_VERT")> m_NET_WM_STATE_MAXIMIZED_VERT;
78-
XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_HORZ")> m_NET_WM_STATE_MAXIMIZED_HORZ;
79-
XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_FULLSCREEN")> m_NET_WM_STATE_FULLSCREEN;
76+
XCBConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_VERT")> m_NET_WM_STATE_MAXIMIZED_VERT;
77+
XCBConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_HORZ")> m_NET_WM_STATE_MAXIMIZED_HORZ;
78+
XCBConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_FULLSCREEN")> m_NET_WM_STATE_FULLSCREEN;
8079

8180
};
8281

include/nbl/ui/IWindowXcb.h renamed to include/nbl/ui/IWindowXCB.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
#include "nbl/core/util/bitflag.h"
55
#include "nbl/ui/IWindow.h"
6-
#include "nbl/ui/XcbConnection.h"
6+
#include "nbl/ui/XCBConnection.h"
77
#include <xcb/xproto.h>
88

99
#ifdef _NBL_PLATFORM_LINUX_
1010

1111
namespace nbl::ui
1212
{
1313

14-
class NBL_API2 IWindowXcb : public IWindow
14+
class NBL_API2 IWindowXCB : public IWindow
1515
{
1616
protected:
17-
virtual ~IWindowXcb() = default;
18-
inline IWindowXcb(SCreationParams&& params) : IWindow(std::move(params)) {}
17+
virtual ~IWindowXCB() = default;
18+
inline IWindowXCB(SCreationParams&& params) : IWindow(std::move(params)) {}
1919

2020
public:
2121
using IWindow::IWindow;
@@ -31,44 +31,44 @@ class NBL_API2 IWindowXcb : public IWindow
3131
virtual bool setWindowVisible_impl(bool visible) = 0;
3232
virtual bool setWindowMaximized_impl(bool maximized) = 0;
3333

34-
static XcbConnection::MotifWmHints fetchMotifMWHints(IWindow::E_CREATE_FLAGS flags) {
35-
core::bitflag<XcbConnection::MotifFlags> motifFlags(XcbConnection::MWM_HINTS_NONE);
36-
core::bitflag<XcbConnection::MotifFunctions> motifFunctions(XcbConnection::MWM_FUNC_NONE);
37-
core::bitflag<XcbConnection::MotifDecorations> motifDecorations(XcbConnection::MWM_DECOR_NONE);
38-
motifFlags |= XcbConnection::MWM_HINTS_DECORATIONS;
34+
static XCBConnection::MotifWmHints fetchMotifMWHints(IWindow::E_CREATE_FLAGS flags) {
35+
core::bitflag<XCBConnection::MotifFlags> motifFlags(XCBConnection::MWM_HINTS_NONE);
36+
core::bitflag<XCBConnection::MotifFunctions> motifFunctions(XCBConnection::MWM_FUNC_NONE);
37+
core::bitflag<XCBConnection::MotifDecorations> motifDecorations(XCBConnection::MWM_DECOR_NONE);
38+
motifFlags |= XCBConnection::MWM_HINTS_DECORATIONS;
3939

4040
if (flags & IWindow::ECF_BORDERLESS) {
41-
motifDecorations |= XcbConnection::MWM_DECOR_ALL;
41+
motifDecorations |= XCBConnection::MWM_DECOR_ALL;
4242
} else {
43-
motifDecorations |= XcbConnection::MWM_DECOR_BORDER;
44-
motifDecorations |= XcbConnection::MWM_DECOR_RESIZEH;
45-
motifDecorations |= XcbConnection::MWM_DECOR_TITLE;
43+
motifDecorations |= XCBConnection::MWM_DECOR_BORDER;
44+
motifDecorations |= XCBConnection::MWM_DECOR_RESIZEH;
45+
motifDecorations |= XCBConnection::MWM_DECOR_TITLE;
4646

4747
// minimize button
4848
if(flags & IWindow::ECF_MINIMIZED) {
49-
motifDecorations |= XcbConnection::MWM_DECOR_MINIMIZE;
50-
motifFunctions |= XcbConnection::MWM_FUNC_MINIMIZE;
49+
motifDecorations |= XCBConnection::MWM_DECOR_MINIMIZE;
50+
motifFunctions |= XCBConnection::MWM_FUNC_MINIMIZE;
5151
}
5252

5353
// maximize button
5454
if(flags & IWindow::ECF_MAXIMIZED) {
55-
motifDecorations |= XcbConnection::MWM_DECOR_MAXIMIZE;
56-
motifFunctions |= XcbConnection::MWM_FUNC_MAXIMIZE;
55+
motifDecorations |= XCBConnection::MWM_DECOR_MAXIMIZE;
56+
motifFunctions |= XCBConnection::MWM_FUNC_MAXIMIZE;
5757
}
5858

5959
// close button
60-
motifFunctions |= XcbConnection::MWM_FUNC_CLOSE;
60+
motifFunctions |= XCBConnection::MWM_FUNC_CLOSE;
6161
}
6262

63-
if(motifFunctions.value != XcbConnection::MWM_FUNC_NONE) {
64-
motifFlags |= XcbConnection::MWM_HINTS_FUNCTIONS;
65-
motifFunctions |= XcbConnection::MWM_FUNC_RESIZE;
66-
motifFunctions |= XcbConnection::MWM_FUNC_MOVE;
63+
if(motifFunctions.value != XCBConnection::MWM_FUNC_NONE) {
64+
motifFlags |= XCBConnection::MWM_HINTS_FUNCTIONS;
65+
motifFunctions |= XCBConnection::MWM_FUNC_RESIZE;
66+
motifFunctions |= XCBConnection::MWM_FUNC_MOVE;
6767
} else {
68-
motifFunctions = XcbConnection::MWM_FUNC_ALL;
68+
motifFunctions = XCBConnection::MWM_FUNC_ALL;
6969
}
7070

71-
XcbConnection::MotifWmHints hints;
71+
XCBConnection::MotifWmHints hints;
7272
hints.flags = motifFlags.value;
7373
hints.functions = motifFunctions.value;
7474
hints.decorations = motifDecorations.value;

include/nbl/ui/XcbConnection.h renamed to include/nbl/ui/XCBConnection.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "nbl/core/decl/Types.h"
77
#include "nbl/core/string/StringLiteral.h"
88
#include "nbl/core/decl/smart_refctd_ptr.h"
9-
#include "nbl/ui/CWindowManagerXcb.h"
9+
#include "nbl/ui/CWindowManagerXCB.h"
1010

1111
#include <xcb/xcb.h>
1212
#include <xcb/xcb_icccm.h>
@@ -17,16 +17,16 @@
1717
namespace nbl::ui
1818
{
1919

20-
class XcbConnection : public core::IReferenceCounted {
20+
class XCBConnection : public core::IReferenceCounted {
2121
public:
2222
template<core::StringLiteral Name>
2323
struct XCBAtomToken {
2424
xcb_atom_t token = 0;
2525
bool fetched = false;
2626
};
2727

28-
XcbConnection(core::smart_refctd_ptr<CWindowManagerXcb>&& windowManager);
29-
virtual ~XcbConnection() override;
28+
XCBConnection(core::smart_refctd_ptr<CWindowManagerXCB>&& windowManager);
29+
virtual ~XCBConnection() override;
3030

3131
template<core::StringLiteral Name>
3232
inline xcb_atom_t resolveXCBAtom(XCBAtomToken<Name>& token, bool only_if_exists = true, bool forced = false) const {
@@ -97,11 +97,11 @@ class XcbConnection : public core::IReferenceCounted {
9797
const xcb_screen_t* primaryScreen();
9898

9999
private:
100-
core::smart_refctd_ptr<CWindowManagerXcb> m_windowManager;
100+
core::smart_refctd_ptr<CWindowManagerXCB> m_windowManager;
101101
xcb_connection_t* m_connection = nullptr;
102102

103-
mutable XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE")> m_NET_WM_STATE;
104-
mutable XcbConnection::XCBAtomToken<core::StringLiteral("_MOTIF_WM_HINTS")> m_MOTIF_WM_HINTS;
103+
mutable XCBConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE")> m_NET_WM_STATE;
104+
mutable XCBConnection::XCBAtomToken<core::StringLiteral("_MOTIF_WM_HINTS")> m_MOTIF_WM_HINTS;
105105
};
106106

107107
} // namespace nbl::ui

include/nbl/ui/declarations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#elif defined(_NBL_BUILD_WITH_WAYLAND) && defined(_NBL_TEST_WAYLAND)
1414
# include "nbl/ui/CWindowManagerWayland.h"
1515
#elif defined(_NBL_PLATFORM_LINUX_)
16-
# include "nbl/ui/CWindowManagerXcb.h"
16+
# include "nbl/ui/CWindowManagerXCB.h"
1717
#endif // TODO more platforms (android)
1818

1919
// clipboards

0 commit comments

Comments
 (0)