From 8dad985328e2183b224300aa992951131956fdb3 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 23 Jan 2024 13:12:11 +0100 Subject: core,codec-json,codec-minecraft,codec-netcdf,codec,io-tls,io,io_codec,window,window-opengl: Renamed file endings and changed includes --- modules/window/c++/backends.h | 10 ---- modules/window/c++/backends.hpp | 10 ++++ modules/window/c++/device.h | 18 ------- modules/window/c++/device.hpp | 18 +++++++ modules/window/c++/linux_xcb.h | 5 -- modules/window/c++/linux_xcb.hpp | 5 ++ modules/window/c++/video_mode.h | 11 ---- modules/window/c++/video_mode.hpp | 11 ++++ modules/window/c++/window.h | 79 ---------------------------- modules/window/c++/window.hpp | 79 ++++++++++++++++++++++++++++ modules/window/c++/xcb.h | 105 -------------------------------------- modules/window/c++/xcb.hpp | 105 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 228 insertions(+), 228 deletions(-) delete mode 100644 modules/window/c++/backends.h create mode 100644 modules/window/c++/backends.hpp delete mode 100644 modules/window/c++/device.h create mode 100644 modules/window/c++/device.hpp delete mode 100644 modules/window/c++/linux_xcb.h create mode 100644 modules/window/c++/linux_xcb.hpp delete mode 100644 modules/window/c++/video_mode.h create mode 100644 modules/window/c++/video_mode.hpp delete mode 100644 modules/window/c++/window.h create mode 100644 modules/window/c++/window.hpp delete mode 100644 modules/window/c++/xcb.h create mode 100644 modules/window/c++/xcb.hpp (limited to 'modules/window/c++') diff --git a/modules/window/c++/backends.h b/modules/window/c++/backends.h deleted file mode 100644 index e129037..0000000 --- a/modules/window/c++/backends.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace saw { -namespace gfx { -namespace backend { -struct linux_xcb {}; -struct wasm {}; -} -} -} diff --git a/modules/window/c++/backends.hpp b/modules/window/c++/backends.hpp new file mode 100644 index 0000000..e129037 --- /dev/null +++ b/modules/window/c++/backends.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace saw { +namespace gfx { +namespace backend { +struct linux_xcb {}; +struct wasm {}; +} +} +} diff --git a/modules/window/c++/device.h b/modules/window/c++/device.h deleted file mode 100644 index 6a28cd5..0000000 --- a/modules/window/c++/device.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "window.h" - -#include -#include -#include -#include - -#include -#include - -namespace saw { -namespace gfx { -template -class device; -} -} diff --git a/modules/window/c++/device.hpp b/modules/window/c++/device.hpp new file mode 100644 index 0000000..f2524db --- /dev/null +++ b/modules/window/c++/device.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "window.hpp + +#include +#include +#include +#include + +#include +#include + +namespace saw { +namespace gfx { +template +class device; +} +} diff --git a/modules/window/c++/linux_xcb.h b/modules/window/c++/linux_xcb.h deleted file mode 100644 index 65ff94d..0000000 --- a/modules/window/c++/linux_xcb.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#ifdef SAW_UNIX_XCB -#include "xcb.h" -#endif diff --git a/modules/window/c++/linux_xcb.hpp b/modules/window/c++/linux_xcb.hpp new file mode 100644 index 0000000..534404c --- /dev/null +++ b/modules/window/c++/linux_xcb.hpp @@ -0,0 +1,5 @@ +#pragma once + +#ifdef SAW_UNIX_XCB +#include "xcb.hpp +#endif diff --git a/modules/window/c++/video_mode.h b/modules/window/c++/video_mode.h deleted file mode 100644 index a8f1695..0000000 --- a/modules/window/c++/video_mode.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -namespace saw { -class video_mode { -public: - size_t width = 64; - size_t height = 64; -}; -} // namespace saw diff --git a/modules/window/c++/video_mode.hpp b/modules/window/c++/video_mode.hpp new file mode 100644 index 0000000..a8f1695 --- /dev/null +++ b/modules/window/c++/video_mode.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace saw { +class video_mode { +public: + size_t width = 64; + size_t height = 64; +}; +} // namespace saw diff --git a/modules/window/c++/window.h b/modules/window/c++/window.h deleted file mode 100644 index 0e8d051..0000000 --- a/modules/window/c++/window.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include "video_mode.h" - -#include -#include -#include - -#include -#include - -namespace saw { -namespace gfx { -namespace schema { -using namespace saw::schema; -using WindowResize = Struct< - Member, - Member ->; -using WindowEvents = Union< - Member ->; -} - -template -class window; -} -} - -#include "linux_xcb.h" - -/** -namespace saw { -class window { -public: - class event { - public: - struct resize { - size_t width; - size_t height; - }; - - struct keyboard { - uint32_t key; - uint32_t scan; - bool pressed; - bool repeat; - }; - - struct mouse { - uint16_t button_mask; - bool pressed; - uint32_t x; - uint32_t y; - }; - - struct mouse_move { - uint32_t x; - uint32_t y; - }; - }; - - using variant_event = std::variant; - - virtual ~window() = default; - - virtual void show() = 0; - virtual void hide() = 0; - - virtual const video_mode &get_video_mode() const = 0; - virtual const std::string_view title() const = 0; - - virtual void resize(size_t width, size_t height) = 0; - - virtual conveyor on_event() = 0; -}; -} // namespace saw -*/ diff --git a/modules/window/c++/window.hpp b/modules/window/c++/window.hpp new file mode 100644 index 0000000..4637ea7 --- /dev/null +++ b/modules/window/c++/window.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include "video_mode.hpp + +#include +#include +#include + +#include +#include + +namespace saw { +namespace gfx { +namespace schema { +using namespace saw::schema; +using WindowResize = Struct< + Member, + Member +>; +using WindowEvents = Union< + Member +>; +} + +template +class window; +} +} + +#include "linux_xcb.hpp + +/** +namespace saw { +class window { +public: + class event { + public: + struct resize { + size_t width; + size_t height; + }; + + struct keyboard { + uint32_t key; + uint32_t scan; + bool pressed; + bool repeat; + }; + + struct mouse { + uint16_t button_mask; + bool pressed; + uint32_t x; + uint32_t y; + }; + + struct mouse_move { + uint32_t x; + uint32_t y; + }; + }; + + using variant_event = std::variant; + + virtual ~window() = default; + + virtual void show() = 0; + virtual void hide() = 0; + + virtual const video_mode &get_video_mode() const = 0; + virtual const std::string_view title() const = 0; + + virtual void resize(size_t width, size_t height) = 0; + + virtual conveyor on_event() = 0; +}; +} // namespace saw +*/ diff --git a/modules/window/c++/xcb.h b/modules/window/c++/xcb.h deleted file mode 100644 index a2a9b0b..0000000 --- a/modules/window/c++/xcb.h +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#ifndef SAW_UNIX_XCB -#error "XCB is not supported" -#endif - -#include "backends.h" -#include "device.h" -#include "window.h" - -#include - -#include -#include - -namespace saw { -namespace gfx { -template -class window; - -template -class device; - -template<> -class device final { -private: - ::Display *display_; - int screen_; - - xcb_connection_t *xcb_connection_; - xcb_screen_t *xcb_screen_; - - own async_notifier_; - conveyor_sink async_conveyor_; - - std::map *> windows_; - - std::vector pending_events_; - - friend class window; -public: - own> create_xcb_window(const video_mode& vid_mod, std::string_view title_view, int visual_id); - void xcb_window_was_destroyed(xcb_window_t window_id); -public: - device(::Display *display, int screen, xcb_connection_t *xcb_connection, - xcb_screen_t *xcb_screen, own && an); - - ~device(); - - void handle_events(); - - own> create_window(const video_mode& vid_mod, std::string_view title_view); - - void flush(); - - // XCB specific info for other classes - ::Display* get_xcb_display() { - return display_; - } - - int get_xcb_screen() const { - return screen_; - } -}; - -error_or>> create_xcb_device(io_provider& provider); - -template<> -class window final { -private: - device *device_; - - xcb_window_t xcb_window_; - xcb_colormap_t xcb_colormap_; - - video_mode video_mode_; - std::string window_title_; - - own>> event_feeder = nullptr; -public: - window(device& dev_, xcb_window_t xcb_win, xcb_colormap_t xcb_colormap_, const video_mode& vid_mode_, const std::string_view& title_view_); - - ~window(); - - void show(); - void hide(); - - const video_mode& get_video_mode() const; - - const std::string_view get_title() const; - - void resize(uint64_t width, uint64_t height); - - conveyor> on_event(); - - void resize_event(uint64_t x, uint64_t y, uint64_t width, uint64_t height); - void mouse_event(int16_t x, int16_t y, uint16_t state, bool pressed); - void mouse_move_event(int16_t x, int16_t y); - void keyboard_event(int16_t x, int16_t y, uint32_t keycode, bool pressed, bool repeat); - - // XCB specific things - xcb_window_t get_xcb_window_handle() const; -}; -} -} diff --git a/modules/window/c++/xcb.hpp b/modules/window/c++/xcb.hpp new file mode 100644 index 0000000..4c7b9fa --- /dev/null +++ b/modules/window/c++/xcb.hpp @@ -0,0 +1,105 @@ +#pragma once + +#ifndef SAW_UNIX_XCB +#error "XCB is not supported" +#endif + +#include "backends.hpp +#include "device.hpp +#include "window.hpp + +#include + +#include +#include + +namespace saw { +namespace gfx { +template +class window; + +template +class device; + +template<> +class device final { +private: + ::Display *display_; + int screen_; + + xcb_connection_t *xcb_connection_; + xcb_screen_t *xcb_screen_; + + own async_notifier_; + conveyor_sink async_conveyor_; + + std::map *> windows_; + + std::vector pending_events_; + + friend class window; +public: + own> create_xcb_window(const video_mode& vid_mod, std::string_view title_view, int visual_id); + void xcb_window_was_destroyed(xcb_window_t window_id); +public: + device(::Display *display, int screen, xcb_connection_t *xcb_connection, + xcb_screen_t *xcb_screen, own && an); + + ~device(); + + void handle_events(); + + own> create_window(const video_mode& vid_mod, std::string_view title_view); + + void flush(); + + // XCB specific info for other classes + ::Display* get_xcb_display() { + return display_; + } + + int get_xcb_screen() const { + return screen_; + } +}; + +error_or>> create_xcb_device(io_provider& provider); + +template<> +class window final { +private: + device *device_; + + xcb_window_t xcb_window_; + xcb_colormap_t xcb_colormap_; + + video_mode video_mode_; + std::string window_title_; + + own>> event_feeder = nullptr; +public: + window(device& dev_, xcb_window_t xcb_win, xcb_colormap_t xcb_colormap_, const video_mode& vid_mode_, const std::string_view& title_view_); + + ~window(); + + void show(); + void hide(); + + const video_mode& get_video_mode() const; + + const std::string_view get_title() const; + + void resize(uint64_t width, uint64_t height); + + conveyor> on_event(); + + void resize_event(uint64_t x, uint64_t y, uint64_t width, uint64_t height); + void mouse_event(int16_t x, int16_t y, uint16_t state, bool pressed); + void mouse_move_event(int16_t x, int16_t y); + void keyboard_event(int16_t x, int16_t y, uint32_t keycode, bool pressed, bool repeat); + + // XCB specific things + xcb_window_t get_xcb_window_handle() const; +}; +} +} -- cgit v1.2.3