-
Notifications
You must be signed in to change notification settings - Fork 64
feature: implement xcb for windowing #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pollend
wants to merge
9
commits into
Devsh-Graphics-Programming:master
Choose a base branch
from
pollend:feature/add-support-xcb
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e8d78d6
feature: implement xcb for windowing
pollend 0473315
chore: tweak class names for consistency
pollend 21d91f7
cleanup
pollend 78172bf
address some of the comments
pollend a5a9b04
remove getXcbWindow and getXcbConnection
pollend 0daeef1
shuffled around implementation
pollend 57074d8
simplify interface
pollend 1ac7295
updated window manager
pollend 5035358
cleanup
pollend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _NBL_UI_C_CLIPBOARD_MANAGER_XCB_INCLUDED_ | ||
#define _NBL_UI_C_CLIPBOARD_MANAGER_XCB_INCLUDED_ | ||
|
||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include "nbl/core/decl/Types.h" | ||
#include "nbl/ui/IClipboardManagerXCB.h" | ||
namespace nbl::ui | ||
{ | ||
|
||
class IWindowXCB; | ||
class XCBConnection; | ||
|
||
// details on XCB clipboard protocol: https://tronche.com/gui/x/icccm/sec-2.html#s-2 | ||
// class NBL_API2 CClipboardManagerXCB final : public IClipboardManagerXCB | ||
// { | ||
// public: | ||
// inline CClipboardManagerXCB(core::smart_refctd_ptr<XCBConnection>&& connect): | ||
// IClipboardManagerXCB(), | ||
// m_connection(std::move(connect)) {} | ||
|
||
// virtual std::string getClipboardText() override; | ||
// virtual bool setClipboardText(const std::string_view& data) override; | ||
|
||
// void process(const IWindowXCB* window, xcb_generic_event_t* event) override; | ||
// private: | ||
// core::smart_refctd_ptr<XCBConnection> m_connection; | ||
// std::mutex m_clipboardMutex; | ||
// std::condition_variable m_clipboardResponseCV; | ||
// std::string m_clipboardResponse; // data sent to the clipboard by another application | ||
|
||
// std::string m_savedClipboard; // data saved to the clipboard for another application to read | ||
|
||
// }; | ||
|
||
} | ||
|
||
#endif | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef __NBL_SYSTEM_C_CURSOR_CONTROL_XCB_H_INCLUDED__ | ||
#define __NBL_SYSTEM_C_CURSOR_CONTROL_XCB_H_INCLUDED__ | ||
|
||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include "nbl/ui/ICursorControl.h" | ||
|
||
namespace nbl::ui | ||
{ | ||
|
||
class XCBConnection; | ||
class NBL_API2 CCursorControlXCB final : public ICursorControl | ||
{ | ||
public: | ||
inline CCursorControlXCB() {} | ||
|
||
void setVisible(bool visible) override; | ||
bool isVisible() const override; | ||
|
||
void setPosition(SPosition pos) override; | ||
void setRelativePosition(IWindow* window, SRelativePosition pos) override; | ||
|
||
SPosition getPosition() override; | ||
SRelativePosition getRelativePosition(IWindow* window) override; | ||
private: | ||
// core::smart_refctd_ptr<XCBConnection> m_connection; | ||
}; | ||
} | ||
|
||
#endif | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef _NBL_UI_C__WINDOWMANAGER_XCB_INCLUDED_ | ||
#define _NBL_UI_C__WINDOWMANAGER_XCB_INCLUDED_ | ||
|
||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include "nbl/core/decl/Types.h" | ||
|
||
#include "nbl/ui/IWindow.h" | ||
#include "nbl/ui/IWindowManagerXCB.h" | ||
|
||
namespace nbl::ui | ||
{ | ||
|
||
class CWindowManagerXCB final : public IWindowManagerXCB | ||
{ | ||
public: | ||
|
||
bool setWindowSize_impl(IWindow* window, uint32_t width, uint32_t height) override; | ||
bool setWindowPosition_impl(IWindow* window, int32_t x, int32_t y) override; | ||
bool setWindowRotation_impl(IWindow* window, bool landscape) override; | ||
bool setWindowVisible_impl(IWindow* window, bool visible) override; | ||
bool setWindowMaximized_impl(IWindow* window, bool maximized) override; | ||
|
||
inline SDisplayInfo getPrimaryDisplayInfo() const override final { | ||
return SDisplayInfo(); | ||
} | ||
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO |
||
|
||
CWindowManagerXCB(); | ||
~CWindowManagerXCB() override = default; | ||
|
||
core::smart_refctd_ptr<IWindow> createWindow(IWindow::SCreationParams&& creationParams) override; | ||
|
||
void destroyWindow(IWindow* wnd) override final {} | ||
|
||
const Xcb& getXcbFunctionTable() const override { return m_xcb; } | ||
const XcbIcccm& getXcbIcccmFunctionTable() const override { return m_xcbIcccm; } | ||
|
||
private: | ||
Xcb m_xcb = Xcb("xcb"); // function tables | ||
XcbIcccm m_xcbIcccm = XcbIcccm("xcb-icccm"); | ||
}; | ||
|
||
|
||
} | ||
#endif | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef _NBL_UI_C_WINDOW_XCB_H_INCLUDED_ | ||
#define _NBL_UI_C_WINDOW_XCB_H_INCLUDED_ | ||
|
||
#include "nbl/core/decl/smart_refctd_ptr.h" | ||
#include "nbl/ui/IClipboardManagerXCB.h" | ||
#include "nbl/ui/IWindowXCB.h" | ||
#include "nbl/ui/XCBHandle.h" | ||
|
||
#include <cstdlib> | ||
|
||
namespace nbl::ui | ||
{ | ||
|
||
class CWindowManagerXCB; | ||
class XCBConnection; | ||
class CCursorControlXCB; | ||
class IClipboardManagerXCB; | ||
|
||
class NBL_API2 CWindowXCB final : public IWindowXCB | ||
{ | ||
|
||
public: | ||
CWindowXCB(native_handle_t&& handle, core::smart_refctd_ptr<CWindowManagerXCB>&& winManager, SCreationParams&& params); | ||
~CWindowXCB(); | ||
|
||
const native_handle_t* getNativeHandle() const override { | ||
return &m_handle; | ||
} | ||
|
||
virtual IClipboardManager* getClipboardManager() override; | ||
virtual ICursorControl* getCursorControl() override; | ||
virtual IWindowManager* getManager() const override; | ||
|
||
virtual void setCaption(const std::string_view& caption) override; | ||
|
||
private: | ||
CWindowXCB(core::smart_refctd_ptr<system::ISystem>&& sys, uint32_t _w, uint32_t _h, E_CREATE_FLAGS _flags); | ||
|
||
native_handle_t m_handle; | ||
core::smart_refctd_ptr<CWindowManagerXCB> m_windowManager; | ||
core::smart_refctd_ptr<CCursorControlXCB> m_cursorControl; | ||
core::smart_refctd_ptr<IClipboardManagerXCB> m_clipboardManager; | ||
|
||
class CDispatchThread final : public system::IThreadHandler<CDispatchThread> | ||
{ | ||
public: | ||
using base_t = system::IThreadHandler<CDispatchThread>; | ||
|
||
inline CDispatchThread(CWindowXCB& window) : | ||
base_t(base_t::start_on_construction_t {}), | ||
m_window(window) { | ||
|
||
} | ||
inline ~CDispatchThread() { | ||
} | ||
|
||
inline void init() {} | ||
inline void exit() {} | ||
void work(lock_t& lock); | ||
|
||
inline bool wakeupPredicate() const { return true; } | ||
inline bool continuePredicate() const { return true; } | ||
private: | ||
CWindowXCB& m_window; | ||
friend class CWindowXCB; | ||
} m_dispatcher; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _NBL_UI_I_CLIPBOARD_MANAGER_XCB_INCLUDED_ | ||
#define _NBL_UI_I_CLIPBOARD_MANAGER_XCB_INCLUDED_ | ||
|
||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include "nbl/ui/IClipboardManager.h" | ||
|
||
namespace nbl::ui | ||
{ | ||
class XCBConnection; | ||
|
||
// details on XCB clipboard protocol: https://tronche.com/gui/x/icccm/sec-2.html#s-2 | ||
class NBL_API2 IClipboardManagerXCB : public IClipboardManager | ||
{ | ||
public: | ||
IClipboardManagerXCB() : IClipboardManager() {} | ||
virtual ~IClipboardManagerXCB() = default; | ||
|
||
virtual std::string getClipboardText() = 0; | ||
virtual bool setClipboardText(const std::string_view& data) = 0; | ||
virtual void process(const IWindowXCB* window, xcb_generic_event_t* event) = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif | ||
|
||
#endif | ||
Comment on lines
+1
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you probably don't need an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef _NBL_UI_I_WINDOWMANAGER_XCB_INCLUDED_ | ||
#define _NBL_UI_I_WINDOWMANAGER_XCB_INCLUDED_ | ||
|
||
#include "nbl/ui/IWindowManager.h" | ||
|
||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include <xcb/xcb.h> | ||
#include <xcb/xcb_icccm.h> | ||
#include <xcb/xproto.h> | ||
|
||
namespace nbl::ui { | ||
|
||
class IWindowManagerXCB : public IWindowManager | ||
{ | ||
public: | ||
NBL_SYSTEM_DECLARE_DYNAMIC_FUNCTION_CALLER_CLASS(Xcb, system::DefaultFuncPtrLoader, | ||
xcb_destroy_window, | ||
xcb_generate_id, | ||
xcb_create_window, | ||
xcb_connect, | ||
xcb_disconnect, | ||
xcb_map_window, | ||
xcb_get_setup, | ||
xcb_setup_roots_iterator, | ||
xcb_flush, | ||
xcb_intern_atom, | ||
xcb_intern_atom_reply, | ||
xcb_unmap_window, | ||
xcb_get_property, | ||
xcb_get_property_reply, | ||
xcb_get_property_value_length, | ||
xcb_change_property, | ||
xcb_configure_window_checked, | ||
xcb_get_property_value, | ||
xcb_wait_for_event, | ||
xcb_send_event, | ||
xcb_request_check, | ||
xcb_delete_property, | ||
xcb_change_window_attributes, | ||
xcb_warp_pointer, | ||
xcb_query_pointer, | ||
xcb_query_pointer_reply, | ||
xcb_get_selection_owner_reply, | ||
xcb_get_selection_owner | ||
); | ||
|
||
NBL_SYSTEM_DECLARE_DYNAMIC_FUNCTION_CALLER_CLASS(XcbIcccm, system::DefaultFuncPtrLoader, | ||
xcb_icccm_set_wm_hints, | ||
xcb_icccm_size_hints_set_size, | ||
xcb_icccm_size_hints_set_min_size, | ||
xcb_icccm_size_hints_set_max_size, | ||
xcb_icccm_set_wm_normal_hints | ||
); | ||
|
||
|
||
NBL_API2 static core::smart_refctd_ptr<IWindowManagerXCB> create(); | ||
virtual const Xcb& getXcbFunctionTable() const = 0; | ||
virtual const XcbIcccm& getXcbIcccmFunctionTable() const = 0; | ||
}; | ||
|
||
} // namespace nbl::ui | ||
|
||
#endif | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef __NBL_I_WINDOW_XCB_H_INCLUDED__ | ||
#define __NBL_I_WINDOW_XCB_H_INCLUDED__ | ||
|
||
#include "nbl/ui/XCBHandle.h" | ||
#ifdef _NBL_PLATFORM_LINUX_ | ||
|
||
#include "nbl/core/util/bitflag.h" | ||
|
||
#include "nbl/ui/IWindow.h" | ||
|
||
#include <xcb/xproto.h> | ||
|
||
namespace nbl::ui | ||
{ | ||
|
||
class NBL_API2 IWindowXCB : public IWindow | ||
{ | ||
protected: | ||
virtual ~IWindowXCB() = default; | ||
inline IWindowXCB(SCreationParams&& params) : IWindow(std::move(params)) {} | ||
|
||
public: | ||
using IWindow::IWindow; | ||
|
||
struct native_handle_t { | ||
xcb_window_t m_window; | ||
core::smart_refctd_ptr<xcb::XCBHandle> m_connection; | ||
}; | ||
|
||
virtual const native_handle_t* getNativeHandle() const = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong namespace, also one too many
_
on the beginning and end