refactor rename
parent
96e3e9a817
commit
882c694510
|
@ -10,8 +10,8 @@ xcb_device::xcb_device(::Display *display, int screen,
|
|||
own<input_stream> &&an)
|
||||
: display{display}, screen{screen}, xcb_connection{xcb_connection},
|
||||
xcb_screen{xcb_screen}, async_notifier{std::move(an)},
|
||||
async_conveyor{async_notifier->readReady()
|
||||
.then([this]() { handleEvents(); })
|
||||
async_conveyor{async_notifier->read_ready()
|
||||
.then([this]() { handle_events(); })
|
||||
.sink()} {}
|
||||
|
||||
xcb_device::~xcb_device() {
|
||||
|
@ -21,11 +21,11 @@ xcb_device::~xcb_device() {
|
|||
}
|
||||
}
|
||||
|
||||
void xcb_device::windowDestroyed(xcb_window_t window_id) {
|
||||
void xcb_device::window_destroyed(xcb_window_t window_id) {
|
||||
windows.erase(window_id);
|
||||
}
|
||||
|
||||
void xcb_device::handleEvents() {
|
||||
void xcb_device::handle_events() {
|
||||
while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection)) {
|
||||
pending_events.push_back(event);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(motion->event);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->mouseMoveEvent(motion->event_x, motion->event_y);
|
||||
find->second->mouseMoveevent(motion->event_x, motion->event_y);
|
||||
}
|
||||
} break;
|
||||
case XCB_EXPOSE: {
|
||||
|
@ -47,7 +47,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(expose->window);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->resizeEvent(static_cast<size_t>(expose->x),
|
||||
find->second->resizeevent(static_cast<size_t>(expose->x),
|
||||
static_cast<size_t>(expose->y),
|
||||
static_cast<size_t>(expose->width),
|
||||
static_cast<size_t>(expose->height));
|
||||
|
@ -59,7 +59,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(button->event);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->mouseEvent(button->event_x, button->event_y,
|
||||
find->second->mouseevent(button->event_x, button->event_y,
|
||||
button->detail, false);
|
||||
}
|
||||
} break;
|
||||
|
@ -69,7 +69,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(button->event);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->mouseEvent(button->event_x, button->event_y,
|
||||
find->second->mouseevent(button->event_x, button->event_y,
|
||||
button->detail, true);
|
||||
}
|
||||
} break;
|
||||
|
@ -103,7 +103,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(key->event);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->keyboardEvent(key->event_x, key->event_y,
|
||||
find->second->keyboardevent(key->event_x, key->event_y,
|
||||
key->detail, repeat, repeat);
|
||||
}
|
||||
} break;
|
||||
|
@ -113,7 +113,7 @@ void xcb_device::handleEvents() {
|
|||
auto find = windows.find(key->event);
|
||||
if (find != windows.end()) {
|
||||
assert(find->second);
|
||||
find->second->keyboardEvent(key->event_x, key->event_y,
|
||||
find->second->keyboardevent(key->event_x, key->event_y,
|
||||
key->detail, true, false);
|
||||
}
|
||||
} break;
|
||||
|
@ -158,14 +158,14 @@ own<xcb_window> xcb_device::create_xcb_window(const video_mode &video_mode,
|
|||
title_view.data());
|
||||
|
||||
xcb_flush(xcb_connection);
|
||||
auto window = heap<xcb_window>(*this, xcb_window, xcb_colormap, video_mode,
|
||||
auto window = heap<class xcb_window>(*this, xcb_window, xcb_colormap, video_mode,
|
||||
title_view);
|
||||
windows[xcb_window] = window.get();
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
own<Window> xcb_device::createWindow(const video_mode &video_mode,
|
||||
own<window> xcb_device::create_window(const video_mode &video_mode,
|
||||
std::string_view title_view) {
|
||||
assert(xcb_screen);
|
||||
return create_xcb_window(video_mode, title_view, xcb_screen->root_visual);
|
||||
|
@ -194,7 +194,7 @@ own<xcb_device> create_xcb_device(io_provider &provider) {
|
|||
|
||||
int fd = xcb_get_file_descriptor(xcb_connection);
|
||||
|
||||
own<input_stream> fd_wrapped = provider.wrapInputFd(fd);
|
||||
own<input_stream> fd_wrapped = provider.wrap_input_fd(fd);
|
||||
if (!fd_wrapped) {
|
||||
::XCloseDisplay(display);
|
||||
return nullptr;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
xcb_screen_t *xcb_screen;
|
||||
|
||||
own<input_stream> async_notifier;
|
||||
sink_conveyor async_conveyor;
|
||||
conveyor_sink async_conveyor;
|
||||
|
||||
std::map<xcb_window_t, xcb_window *> windows;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace saw {
|
||||
namespace {
|
||||
GlxLibraryExtensions glxLibraryExtensions(const char *extension_string) {
|
||||
glx_library_extensions glxLibraryExtensions(const char *extension_string) {
|
||||
std::string_view extensions_view{extension_string};
|
||||
std::set<std::string_view> extensions;
|
||||
while (1) {
|
||||
|
@ -48,7 +48,7 @@ int translateRenderTypeSetting(GlSettings::RenderType cmp) {
|
|||
int translateDrawableTypeSetting(GlSettings::DrawableType cmp) {
|
||||
int i = 0;
|
||||
if (static_cast<int32_t>(cmp) &
|
||||
static_cast<int32_t>(GlSettings::DrawableType::WindowBit)) {
|
||||
static_cast<int32_t>(GlSettings::DrawableType::windowBit)) {
|
||||
i |= static_cast<int32_t>(GLX_WINDOW_BIT);
|
||||
}
|
||||
if (static_cast<int32_t>(cmp) &
|
||||
|
@ -63,13 +63,13 @@ int translateDrawableTypeSetting(GlSettings::DrawableType cmp) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
XcbGlContext::XcbGlContext(const GlxLibraryExtensions &ext_lib,
|
||||
xcb_gl_context::xcb_gl_context(const glx_library_extensions &ext_lib,
|
||||
own<xcb_device> &&dev, int visual_id,
|
||||
GLXContext context, GLXFBConfig fb_config)
|
||||
: ext_lib{ext_lib}, device{std::move(dev)}, visual_id{visual_id},
|
||||
context{context}, fb_config{fb_config} {}
|
||||
|
||||
XcbGlContext::~XcbGlContext() {
|
||||
xcb_gl_context::~xcb_gl_context() {
|
||||
assert(device);
|
||||
assert(device->display);
|
||||
if (context) {
|
||||
|
@ -79,7 +79,7 @@ XcbGlContext::~XcbGlContext() {
|
|||
device->flush();
|
||||
}
|
||||
|
||||
own<GlWindow> XcbGlContext::createWindow(const video_mode &video_mode,
|
||||
own<gl_window> xcb_gl_context::create_window(const video_mode &video_mode,
|
||||
std::string_view title_view) {
|
||||
assert(device);
|
||||
if (!device) {
|
||||
|
@ -91,20 +91,20 @@ own<GlWindow> XcbGlContext::createWindow(const video_mode &video_mode,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
::GLXWindow glx_window = glXCreateWindow(device->display, fb_config,
|
||||
::GLXWindow glx_window = glXCreatewindow(device->display, fb_config,
|
||||
window->xcb_window, nullptr);
|
||||
|
||||
return heap<XcbGlWindow>(std::move(window), *this, glx_window);
|
||||
return heap<xcb_gl_window>(std::move(window), *this, glx_window);
|
||||
}
|
||||
|
||||
void XcbGlContext::flush() {
|
||||
void xcb_gl_context::flush() {
|
||||
assert(device);
|
||||
if (device) {
|
||||
device->flush();
|
||||
}
|
||||
}
|
||||
|
||||
own<GlContext> createGlContext(io_provider &provider,
|
||||
own<gl_context> creategl_context(io_provider &provider,
|
||||
const GlSettings &settings) {
|
||||
own<xcb_device> device = create_xcb_device(provider);
|
||||
if (!device) {
|
||||
|
@ -154,7 +154,7 @@ own<GlContext> createGlContext(io_provider &provider,
|
|||
|
||||
int num_fb_configs = 0;
|
||||
|
||||
GlxLibraryExtensions lib_ext = glxLibraryExtensions(
|
||||
glx_library_extensions lib_ext = glxLibraryExtensions(
|
||||
glXQueryExtensionsString(device->display, device->screen));
|
||||
|
||||
GLXFBConfig *fb_configs = glXChooseFBConfig(
|
||||
|
@ -192,7 +192,7 @@ own<GlContext> createGlContext(io_provider &provider,
|
|||
int visual_id = 0;
|
||||
glXGetFBConfigAttrib(device->display, fb_config, GLX_VISUAL_ID,
|
||||
&visual_id);
|
||||
return heap<XcbGlContext>(lib_ext, std::move(device), visual_id,
|
||||
return heap<xcb_gl_context>(lib_ext, std::move(device), visual_id,
|
||||
context, fb_config);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "forstio/window/gl/gl_context.h"
|
||||
|
||||
namespace saw {
|
||||
struct GlxLibraryExtensions {
|
||||
struct glx_library_extensions {
|
||||
public:
|
||||
std::string_view raw_extension_string;
|
||||
|
||||
|
@ -17,20 +17,20 @@ public:
|
|||
};
|
||||
|
||||
class xcb_device;
|
||||
class XcbGlContext final : public GlContext {
|
||||
class xcb_gl_context final : public gl_context {
|
||||
public:
|
||||
GlxLibraryExtensions ext_lib;
|
||||
glx_library_extensions ext_lib;
|
||||
own<xcb_device> device;
|
||||
int visual_id;
|
||||
GLXContext context;
|
||||
GLXFBConfig fb_config;
|
||||
|
||||
public:
|
||||
XcbGlContext(const GlxLibraryExtensions &, own<xcb_device> &&, int,
|
||||
xcb_gl_context(const glx_library_extensions &, own<xcb_device> &&, int,
|
||||
GLXContext, GLXFBConfig);
|
||||
~XcbGlContext();
|
||||
~xcb_gl_context();
|
||||
|
||||
own<GlWindow> createWindow(const video_mode &, std::string_view) override;
|
||||
own<gl_window> create_window(const video_mode &, std::string_view) override;
|
||||
|
||||
void flush() override;
|
||||
};
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
#include <cassert>
|
||||
|
||||
namespace saw {
|
||||
XcbGlWindow::XcbGlWindow(own<xcb_window> &&win, XcbGlContext &ctx,
|
||||
xcb_gl_window::xcb_gl_window(own<xcb_window> &&win, xcb_gl_context &ctx,
|
||||
::GLXWindow glx_win)
|
||||
: window{std::move(win)}, context{ctx}, glx_window{glx_win} {}
|
||||
|
||||
XcbGlWindow::~XcbGlWindow() {
|
||||
xcb_gl_window::~xcb_gl_window() {
|
||||
assert(context.device);
|
||||
if (context.device) {
|
||||
::glXDestroyWindow(context.device->display, glx_window);
|
||||
}
|
||||
}
|
||||
|
||||
void XcbGlWindow::bind() {
|
||||
void xcb_gl_window::bind() {
|
||||
assert(window && context.device && context.device->display);
|
||||
if (window) {
|
||||
if (context.device && context.device->display) {
|
||||
|
@ -29,21 +29,21 @@ void XcbGlWindow::bind() {
|
|||
}
|
||||
}
|
||||
|
||||
void XcbGlWindow::show() {
|
||||
void xcb_gl_window::show() {
|
||||
assert(window);
|
||||
if (window) {
|
||||
window->show();
|
||||
}
|
||||
}
|
||||
|
||||
void XcbGlWindow::hide() {
|
||||
void xcb_gl_window::hide() {
|
||||
assert(window);
|
||||
if (window) {
|
||||
window->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void XcbGlWindow::swap() {
|
||||
void xcb_gl_window::swap() {
|
||||
assert(context.device);
|
||||
assert(context.device->display);
|
||||
if (context.device && context.device->display) {
|
||||
|
@ -51,28 +51,28 @@ void XcbGlWindow::swap() {
|
|||
}
|
||||
}
|
||||
|
||||
const video_mode &XcbGlWindow::videoMode() const {
|
||||
const video_mode &xcb_gl_window::videoMode() const {
|
||||
assert(window);
|
||||
return window->videoMode();
|
||||
}
|
||||
|
||||
const std::string_view XcbGlWindow::title() const {
|
||||
const std::string_view xcb_gl_window::title() const {
|
||||
assert(window);
|
||||
if (window) {
|
||||
return window->title();
|
||||
}
|
||||
return "Bad Window";
|
||||
return "Bad window";
|
||||
}
|
||||
|
||||
void XcbGlWindow::resize(size_t height, size_t width) {
|
||||
void xcb_gl_window::resize(size_t height, size_t width) {
|
||||
assert(window);
|
||||
if (window) {
|
||||
window->resize(height, width);
|
||||
}
|
||||
}
|
||||
|
||||
Conveyor<Window::VariantEvent> XcbGlWindow::onEvent() {
|
||||
conveyor<window::variant_event> xcb_gl_window::onevent() {
|
||||
assert(window);
|
||||
return window->onEvent();
|
||||
return window->onevent();
|
||||
}
|
||||
} // namespace saw
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
|
||||
namespace saw {
|
||||
class xcb_window;
|
||||
class XcbGlContext;
|
||||
class XcbGlWindow final : public GlWindow {
|
||||
class xcb_gl_context;
|
||||
class xcb_gl_window final : public gl_window {
|
||||
public:
|
||||
own<xcb_window> window;
|
||||
XcbGlContext &context;
|
||||
xcb_gl_context &context;
|
||||
|
||||
::GLXWindow glx_window;
|
||||
|
||||
public:
|
||||
XcbGlWindow(own<xcb_window> &&, XcbGlContext &, ::GLXWindow);
|
||||
~XcbGlWindow();
|
||||
xcb_gl_window(own<xcb_window> &&, xcb_gl_context &, ::GLXWindow);
|
||||
~xcb_gl_window();
|
||||
|
||||
void bind() override;
|
||||
void swap() override;
|
||||
|
@ -29,6 +29,6 @@ public:
|
|||
|
||||
void resize(size_t height, size_t width) override;
|
||||
|
||||
Conveyor<Window::VariantEvent> onEvent() override;
|
||||
conveyor<window::variant_event> onevent() override;
|
||||
};
|
||||
} // namespace saw
|
||||
|
|
|
@ -12,7 +12,7 @@ xcb_window::xcb_window(xcb_device &dev, xcb_window_t xcb_win,
|
|||
video_mode_{vid_mode}, window_title_{title_view_} {}
|
||||
|
||||
xcb_window::~xcb_window() {
|
||||
device_.windowDestroyed(xcb_window_);
|
||||
device_.window_destroyed(xcb_window_);
|
||||
xcb_destroy_window(device_.xcb_connection, xcb_window_);
|
||||
device_.flush();
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ void xcb_window::resize(size_t width, size_t height) {
|
|||
video_mode_.height = height;
|
||||
}
|
||||
|
||||
Conveyor<Window::VariantEvent> xcb_window::onEvent() {
|
||||
auto caf = newConveyorAndFeeder<Window::VariantEvent>();
|
||||
conveyor<window::variant_event> xcb_window::onevent() {
|
||||
auto caf = new_conveyor_and_feeder<window::variant_event>();
|
||||
event_feeder = std::move(caf.feeder);
|
||||
return std::move(caf.conveyor);
|
||||
}
|
||||
|
||||
void xcb_window::resizeEvent(size_t x, size_t y, size_t width, size_t height) {
|
||||
void xcb_window::resizeevent(size_t x, size_t y, size_t width, size_t height) {
|
||||
(void)x;
|
||||
(void)y;
|
||||
/// @todo maybe include x and y?
|
||||
|
@ -57,11 +57,11 @@ void xcb_window::resizeEvent(size_t x, size_t y, size_t width, size_t height) {
|
|||
|
||||
if (event_feeder) {
|
||||
event_feeder->feed(
|
||||
Window::VariantEvent{Window::Event::Resize{width, height}});
|
||||
window::variant_event{window::event::resize{width, height}});
|
||||
}
|
||||
}
|
||||
|
||||
void xcb_window::mouseEvent(int16_t x, int16_t y, uint16_t state, bool pressed) {
|
||||
void xcb_window::mouseevent(int16_t x, int16_t y, uint16_t state, bool pressed) {
|
||||
if (x < 0 || y < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -72,11 +72,11 @@ void xcb_window::mouseEvent(int16_t x, int16_t y, uint16_t state, bool pressed)
|
|||
}
|
||||
if (event_feeder) {
|
||||
event_feeder->feed(
|
||||
Window::VariantEvent{Window::Event::Mouse{state, pressed, ux, uy}});
|
||||
window::variant_event{window::event::mouse{state, pressed, ux, uy}});
|
||||
}
|
||||
}
|
||||
|
||||
void xcb_window::mouseMoveEvent(int16_t x, int16_t y) {
|
||||
void xcb_window::mouseMoveevent(int16_t x, int16_t y) {
|
||||
if (x < 0 || y < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ void xcb_window::mouseMoveEvent(int16_t x, int16_t y) {
|
|||
}
|
||||
if (event_feeder) {
|
||||
event_feeder->feed(
|
||||
Window::VariantEvent{Window::Event::MouseMove{ux, uy}});
|
||||
window::variant_event{window::event::mouse_move{ux, uy}});
|
||||
}
|
||||
}
|
||||
|
||||
void xcb_window::keyboardEvent(int16_t x, int16_t y, uint32_t keycode,
|
||||
void xcb_window::keyboardevent(int16_t x, int16_t y, uint32_t keycode,
|
||||
bool pressed, bool repeat) {
|
||||
if (x < 0 || y < 0) {
|
||||
return;
|
||||
|
@ -102,8 +102,8 @@ void xcb_window::keyboardEvent(int16_t x, int16_t y, uint32_t keycode,
|
|||
return;
|
||||
}
|
||||
if (event_feeder) {
|
||||
event_feeder->feed(Window::VariantEvent{
|
||||
Window::Event::Keyboard{keycode, keycode, pressed, repeat}});
|
||||
event_feeder->feed(window::variant_event{
|
||||
window::event::keyboard{keycode, keycode, pressed, repeat}});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,12 @@ public:
|
|||
|
||||
void resize(size_t width, size_t height) override;
|
||||
|
||||
conveyor<window::variant_event> onEvent() override;
|
||||
conveyor<window::variant_event> onevent() override;
|
||||
|
||||
void resizeEvent(size_t x, size_t y, size_t width, size_t height);
|
||||
void mouseEvent(int16_t x, int16_t y, uint16_t state, bool pressed);
|
||||
void mouseMoveEvent(int16_t x, int16_t y);
|
||||
void keyboardEvent(int16_t x, int16_t y, uint32_t keycode, bool pressed,
|
||||
void resizeevent(size_t x, size_t y, size_t width, size_t height);
|
||||
void mouseevent(int16_t x, int16_t y, uint16_t state, bool pressed);
|
||||
void mouseMoveevent(int16_t x, int16_t y);
|
||||
void keyboardevent(int16_t x, int16_t y, uint32_t keycode, bool pressed,
|
||||
bool repeat);
|
||||
};
|
||||
} // namespace saw
|
||||
|
|
|
@ -27,11 +27,11 @@ public:
|
|||
/// glcontext-xcb.cpp and other occurences
|
||||
/// Alternatively implement bitwise operations & and |
|
||||
enum class DrawableType : int32_t {
|
||||
WindowBit = 0x01,
|
||||
windowBit = 0x01,
|
||||
PixMapBit = 0x02,
|
||||
PBufferBit = 0x04
|
||||
};
|
||||
DrawableType drawable_type = DrawableType::WindowBit;
|
||||
DrawableType drawable_type = DrawableType::windowBit;
|
||||
|
||||
bool double_buffer = true;
|
||||
|
||||
|
@ -47,15 +47,15 @@ public:
|
|||
bool core_profile = true;
|
||||
};
|
||||
|
||||
class GlContext {
|
||||
class gl_context {
|
||||
public:
|
||||
virtual ~GlContext() = default;
|
||||
virtual ~gl_context() = default;
|
||||
|
||||
virtual own<GlWindow> createWindow(const video_mode &, std::string_view) = 0;
|
||||
virtual own<gl_window> create_window(const video_mode &, std::string_view) = 0;
|
||||
|
||||
virtual void flush() = 0;
|
||||
};
|
||||
|
||||
class io_provider;
|
||||
own<GlContext> createGlContext(io_provider &, const GlSettings &);
|
||||
own<gl_context> creategl_context(io_provider &, const GlSettings &);
|
||||
} // namespace saw
|
||||
|
|
|
@ -26,6 +26,6 @@ public:
|
|||
|
||||
virtual void resize(size_t height, size_t width) = 0;
|
||||
|
||||
virtual conveyor<window::variant_event> onEvent() = 0;
|
||||
virtual conveyor<window::variant_event> onevent() = 0;
|
||||
};
|
||||
} // namespace saw
|
||||
|
|
|
@ -52,6 +52,6 @@ public:
|
|||
|
||||
virtual void resize(size_t width, size_t height) = 0;
|
||||
|
||||
virtual conveyor<variant_event> onEvent() = 0;
|
||||
virtual conveyor<variant_event> onevent() = 0;
|
||||
};
|
||||
} // namespace saw
|
||||
|
|
Loading…
Reference in New Issue