Fix travis LINT
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "xenia/ui/file_picker.h"
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <string>
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -36,39 +36,34 @@ GtkFilePicker::GtkFilePicker() = default;
|
||||
|
||||
GtkFilePicker::~GtkFilePicker() = default;
|
||||
|
||||
|
||||
bool GtkFilePicker::Show(void* parent_window_handle) {
|
||||
// TODO(benvanik): FileSaveDialog.
|
||||
assert_true(mode() == Mode::kOpen);
|
||||
// TODO(benvanik): folder dialogs.
|
||||
assert_true(type() == Type::kFile);
|
||||
GtkWidget *dialog;
|
||||
GtkWidget* dialog;
|
||||
gint res;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Open File",
|
||||
(GtkWindow*)parent_window_handle,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
"_Open",
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
dialog = gtk_file_chooser_dialog_new(
|
||||
"Open File", (GtkWindow*)parent_window_handle,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open",
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
|
||||
res = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
char *filename;
|
||||
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
char* filename;
|
||||
if (res == GTK_RESPONSE_ACCEPT) {
|
||||
GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
|
||||
filename = gtk_file_chooser_get_filename (chooser);
|
||||
GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog);
|
||||
filename = gtk_file_chooser_get_filename(chooser);
|
||||
std::vector<std::wstring> selected_files;
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
std::wstring ws_filename = converter.from_bytes(filename);
|
||||
selected_files.push_back(ws_filename);
|
||||
set_selected_files(selected_files);
|
||||
gtk_widget_destroy (dialog);
|
||||
gtk_widget_destroy(dialog);
|
||||
return true;
|
||||
}
|
||||
gtk_widget_destroy (dialog);
|
||||
return false;;
|
||||
gtk_widget_destroy(dialog);
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "xenia/ui/gl/gl_immediate_drawer.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
|
||||
DEFINE_bool(thread_safe_gl, false,
|
||||
"Only allow one GL context to be active at a time.");
|
||||
|
||||
@@ -40,7 +39,6 @@ namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
std::recursive_mutex GLContext::global_gl_mutex_;
|
||||
|
||||
void GLContext::FatalGLError(std::string error) {
|
||||
@@ -51,10 +49,8 @@ void GLContext::FatalGLError(std::string error) {
|
||||
"of supported GPUs.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLContext::GLContext(GraphicsProvider* provider, Window* target_window)
|
||||
: GraphicsContext(provider, target_window) { }
|
||||
: GraphicsContext(provider, target_window) {}
|
||||
|
||||
GLContext::~GLContext() {}
|
||||
|
||||
@@ -218,8 +214,6 @@ ImmediateDrawer* GLContext::immediate_drawer() {
|
||||
return immediate_drawer_.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLContext::WasLost() {
|
||||
if (!robust_access_supported_) {
|
||||
// Can't determine if we lost the context.
|
||||
|
||||
@@ -29,7 +29,6 @@ DECLARE_bool(gl_debug);
|
||||
DECLARE_bool(gl_debug_output);
|
||||
DECLARE_bool(gl_debug_output_synchronous);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
@@ -69,6 +68,7 @@ class GLContext : public GraphicsContext {
|
||||
void AssertExtensionsPresent();
|
||||
void DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity,
|
||||
GLsizei length, const GLchar* message);
|
||||
|
||||
private:
|
||||
friend class GLProvider;
|
||||
|
||||
@@ -79,15 +79,11 @@ class GLContext : public GraphicsContext {
|
||||
GLContext* parent_context);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static void GLAPIENTRY DebugMessageThunk(GLenum source, GLenum type,
|
||||
GLuint id, GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
GLvoid* user_param);
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
||||
@@ -24,23 +24,20 @@
|
||||
|
||||
#include "third_party/GL/wglew.h"
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
||||
thread_local WGLEWContext* tls_wglew_context_ = nullptr;
|
||||
extern "C" GLEWContext* glewGetContext() { return tls_glew_context_; }
|
||||
extern "C" WGLEWContext* wglewGetContext() { return tls_wglew_context_; }
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
Window* target_window,
|
||||
GLContext* share_context) {
|
||||
auto context =
|
||||
std::unique_ptr<GLContext>(new WGLContext(provider, target_window));
|
||||
std::unique_ptr<GLContext>(new WGLContext(provider, target_window));
|
||||
if (!context->Initialize(share_context)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -48,11 +45,10 @@ std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::CreateOffscreen(
|
||||
GraphicsProvider* provider, GLContext* parent_context) {
|
||||
GraphicsProvider* provider, GLContext* parent_context) {
|
||||
return WGLContext::CreateOffscreen(provider,
|
||||
static_cast<WGLContext*>(parent_context));
|
||||
static_cast<WGLContext*>(parent_context));
|
||||
}
|
||||
|
||||
WGLContext::WGLContext(GraphicsProvider* provider, Window* target_window)
|
||||
@@ -296,7 +292,6 @@ void WGLContext::ClearCurrent() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WGLContext::BeginSwap() {
|
||||
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::WGLContext::BeginSwap");
|
||||
float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f};
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
|
||||
typedef struct HDC__* HDC;
|
||||
@@ -33,7 +33,6 @@ class WGLContext : public GLContext {
|
||||
public:
|
||||
~WGLContext() override;
|
||||
|
||||
|
||||
bool is_current() override;
|
||||
bool MakeCurrent() override;
|
||||
void ClearCurrent() override;
|
||||
@@ -41,25 +40,21 @@ class WGLContext : public GLContext {
|
||||
void BeginSwap() override;
|
||||
void EndSwap() override;
|
||||
|
||||
|
||||
protected:
|
||||
friend class GLContext;
|
||||
WGLContext(GraphicsProvider* provider, Window* target_window);
|
||||
static std::unique_ptr<WGLContext> CreateOffscreen(GraphicsProvider* provider,
|
||||
WGLContext* parent_context);
|
||||
static std::unique_ptr<WGLContext> CreateOffscreen(
|
||||
GraphicsProvider* provider, WGLContext* parent_context);
|
||||
|
||||
bool Initialize(GLContext* share_context) override;
|
||||
void* handle() override {return glrc_;};
|
||||
void* handle() override { return glrc_; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
HDC dc_ = nullptr;
|
||||
HGLRC glrc_ = nullptr;
|
||||
|
||||
std::unique_ptr<GLEWContext> glew_context_;
|
||||
std::unique_ptr<WGLEWContext> wglew_context_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
@@ -21,27 +23,21 @@
|
||||
#include "xenia/base/profiling.h"
|
||||
#include "xenia/ui/gl/gl_immediate_drawer.h"
|
||||
#include "xenia/ui/window.h"
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
|
||||
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
||||
thread_local GLXEWContext* tls_glxew_context_ = nullptr;
|
||||
extern "C" GLEWContext* glewGetContext() { return tls_glew_context_; }
|
||||
extern "C" GLXEWContext* glxewGetContext() { return tls_glxew_context_; }
|
||||
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
Window* target_window,
|
||||
GLContext* share_context) {
|
||||
auto context =
|
||||
std::unique_ptr<GLContext>(new GLXContext(provider, target_window));
|
||||
std::unique_ptr<GLContext>(new GLXContext(provider, target_window));
|
||||
if (!context->Initialize(share_context)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -50,9 +46,9 @@ std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
}
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::CreateOffscreen(
|
||||
GraphicsProvider* provider, GLContext* parent_context) {
|
||||
GraphicsProvider* provider, GLContext* parent_context) {
|
||||
return GLXContext::CreateOffscreen(provider,
|
||||
static_cast<GLXContext*>(parent_context));
|
||||
static_cast<GLXContext*>(parent_context));
|
||||
}
|
||||
|
||||
GLXContext::GLXContext(GraphicsProvider* provider, Window* target_window)
|
||||
@@ -74,8 +70,6 @@ GLXContext::~GLXContext() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLXContext::Initialize(GLContext* share_context) {
|
||||
GtkWidget* window = GTK_WIDGET(target_window_->native_handle());
|
||||
GtkWidget* draw_area = gtk_drawing_area_new();
|
||||
@@ -90,8 +84,8 @@ bool GLXContext::Initialize(GLContext* share_context) {
|
||||
Display* display = gdk_x11_display_get_xdisplay(gdk_display);
|
||||
disp_ = display;
|
||||
::Window root = gdk_x11_get_default_root_xwindow();
|
||||
static int vis_attrib_list[] =
|
||||
{GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
||||
static int vis_attrib_list[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24,
|
||||
GLX_DOUBLEBUFFER, None};
|
||||
XVisualInfo* vi = glXChooseVisual(display, 0, vis_attrib_list);
|
||||
if (vi == NULL) {
|
||||
FatalGLError("No matching visuals for X display");
|
||||
@@ -151,8 +145,8 @@ bool GLXContext::Initialize(GLContext* share_context) {
|
||||
GLXContext* share_context_glx = static_cast<GLXContext*>(share_context);
|
||||
glx_context_ = glXCreateContextAttribsARB(
|
||||
display, nullptr,
|
||||
share_context ? share_context_glx->glx_context_ : nullptr, True,
|
||||
attrib_list);
|
||||
share_context ? share_context_glx->glx_context_ : nullptr, True,
|
||||
attrib_list);
|
||||
glXMakeCurrent(display, 0, nullptr);
|
||||
glXDestroyContext(display, temp_context);
|
||||
if (!glx_context_) {
|
||||
@@ -222,7 +216,8 @@ std::unique_ptr<GLXContext> GLXContext::CreateOffscreen(
|
||||
robust_access_supported ? GLX_LOSE_CONTEXT_ON_RESET_ARB : 0,
|
||||
0};
|
||||
new_glrc = glXCreateContextAttribsARB(parent_context->disp_, nullptr,
|
||||
parent_context->glx_context_, True, attrib_list);
|
||||
parent_context->glx_context_, True,
|
||||
attrib_list);
|
||||
if (!new_glrc) {
|
||||
FatalGLError("Could not create shared context.");
|
||||
return nullptr;
|
||||
@@ -271,13 +266,10 @@ std::unique_ptr<GLXContext> GLXContext::CreateOffscreen(
|
||||
return new_context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLXContext::is_current() {
|
||||
return tls_glew_context_ == glew_context_.get();
|
||||
}
|
||||
|
||||
|
||||
bool GLXContext::MakeCurrent() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (FLAGS_thread_safe_gl) {
|
||||
@@ -308,7 +300,6 @@ void GLXContext::ClearCurrent() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLXContext::BeginSwap() {
|
||||
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLXContext::BeginSwap");
|
||||
float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f};
|
||||
|
||||
@@ -14,16 +14,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
|
||||
DECLARE_bool(thread_safe_gl);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
@@ -35,7 +34,6 @@ class GLXContext : public GLContext {
|
||||
public:
|
||||
~GLXContext() override;
|
||||
|
||||
|
||||
bool is_current() override;
|
||||
|
||||
bool MakeCurrent() override;
|
||||
@@ -44,13 +42,12 @@ class GLXContext : public GLContext {
|
||||
void BeginSwap() override;
|
||||
void EndSwap() override;
|
||||
|
||||
|
||||
protected:
|
||||
static std::unique_ptr<GLXContext> CreateOffscreen(GraphicsProvider* provider,
|
||||
GLXContext* parent_context);
|
||||
static std::unique_ptr<GLXContext> CreateOffscreen(
|
||||
GraphicsProvider* provider, GLXContext* parent_context);
|
||||
|
||||
bool Initialize(GLContext* share_context) override;
|
||||
void* handle() override {return glx_context_;}
|
||||
void* handle() override { return glx_context_; }
|
||||
|
||||
private:
|
||||
friend class GLContext;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
|
||||
class PostedFn {
|
||||
public:
|
||||
explicit PostedFn(std::function<void()> fn) : fn_(std::move(fn)) {}
|
||||
@@ -28,7 +27,7 @@ std::unique_ptr<Loop> Loop::Create() { return std::make_unique<GTKLoop>(); }
|
||||
|
||||
GTKLoop::GTKLoop() : thread_id_() {
|
||||
gtk_init(nullptr, nullptr);
|
||||
xe::threading::Fence init_fence;
|
||||
xe::threading::Fence init_fence;
|
||||
thread_ = std::thread([&init_fence, this]() {
|
||||
xe::threading::set_name("GTK Loop");
|
||||
|
||||
@@ -47,39 +46,31 @@ GTKLoop::~GTKLoop() {
|
||||
thread_.join();
|
||||
}
|
||||
|
||||
void GTKLoop::ThreadMain() {
|
||||
|
||||
gtk_main();
|
||||
|
||||
}
|
||||
void GTKLoop::ThreadMain() { gtk_main(); }
|
||||
|
||||
bool GTKLoop::is_on_loop_thread() {
|
||||
return thread_id_ == std::this_thread::get_id();
|
||||
}
|
||||
|
||||
|
||||
gboolean _posted_fn_thunk(gpointer posted_fn) {
|
||||
PostedFn* Fn = reinterpret_cast<PostedFn*>(posted_fn);
|
||||
Fn->Call();
|
||||
return G_SOURCE_REMOVE;
|
||||
PostedFn* Fn = reinterpret_cast<PostedFn*>(posted_fn);
|
||||
Fn->Call();
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void GTKLoop::Post(std::function<void()> fn) {
|
||||
assert_true(thread_id_ != std::thread::id());
|
||||
gdk_threads_add_idle(_posted_fn_thunk,
|
||||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
}
|
||||
|
||||
|
||||
void GTKLoop::PostDelayed(std::function<void()> fn, uint64_t delay_millis) {
|
||||
gdk_threads_add_timeout(delay_millis, _posted_fn_thunk,
|
||||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
gdk_threads_add_timeout(
|
||||
delay_millis, _posted_fn_thunk,
|
||||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
}
|
||||
|
||||
void GTKLoop::Quit() {
|
||||
assert_true(thread_id_ != std::thread::id());
|
||||
|
||||
}
|
||||
void GTKLoop::Quit() { assert_true(thread_id_ != std::thread::id()); }
|
||||
|
||||
void GTKLoop::AwaitQuit() { quit_fence_.Wait(); }
|
||||
|
||||
|
||||
@@ -35,15 +35,13 @@ class GTKLoop : public Loop {
|
||||
|
||||
void Quit() override;
|
||||
void AwaitQuit() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
void ThreadMain();
|
||||
|
||||
std::thread::id thread_id_;
|
||||
std::thread thread_;
|
||||
xe::threading::Fence quit_fence_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/ui/ui_event.h"
|
||||
|
||||
|
||||
@@ -73,16 +73,15 @@ bool VulkanContext::Initialize() {
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
xcb_window_t window =
|
||||
gdk_x11_window_get_xid(gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(target_window_->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
create_info.connection = static_cast<xcb_connection_t*>(
|
||||
target_window_->native_platform_handle());
|
||||
create_info.window = static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(*provider->instance(), &create_info,
|
||||
nullptr, &surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
|
||||
@@ -397,18 +397,17 @@ bool VulkanInstance::QueryDevices(Window* any_target_window) {
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
xcb_window_t window =
|
||||
gdk_x11_window_get_xid(gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(any_target_window->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(handle, &create_info,
|
||||
nullptr, &any_surface);
|
||||
create_info.connection = static_cast<xcb_connection_t*>(
|
||||
any_target_window->native_platform_handle());
|
||||
create_info.window = static_cast<xcb_window_t>(window);
|
||||
auto err =
|
||||
vkCreateXcbSurfaceKHR(handle, &create_info, nullptr, &any_surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
#else
|
||||
#error Unsupported GDK Backend on Linux.
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
|
||||
class FnWrapper {
|
||||
public:
|
||||
explicit FnWrapper(std::function<void()> fn) : fn_(std::move(fn)) {}
|
||||
@@ -161,12 +160,12 @@ void GTKWindow::set_focus(bool value) {
|
||||
if (value) {
|
||||
gtk_window_activate_focus(GTK_WINDOW(window_));
|
||||
} else {
|
||||
// TODO(dougvj) Check to see if we need to do somethign here to unset
|
||||
// TODO(dougvj) Check to see if we need to do something here to unset
|
||||
// the focus.
|
||||
}
|
||||
} else {
|
||||
has_focus_ = value;
|
||||
}
|
||||
} else {
|
||||
has_focus_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
void GTKWindow::Resize(int32_t width, int32_t height) {
|
||||
@@ -219,8 +218,6 @@ void GTKWindow::OnMainMenuChange() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GTKWindow::HandleWindowOwnerChange(GdkEventOwnerChange* event) {
|
||||
if (event->type == GDK_OWNER_CHANGE) {
|
||||
if (event->reason == GDK_OWNER_CHANGE_DESTROY) {
|
||||
@@ -231,8 +228,8 @@ bool GTKWindow::HandleWindowOwnerChange(GdkEventOwnerChange* event) {
|
||||
OnClose();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GTKWindow::HandleWindowResize(GdkEventConfigure* event) {
|
||||
@@ -244,8 +241,6 @@ bool GTKWindow::HandleWindowResize(GdkEventConfigure* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GTKWindow::HandleWindowVisibility(GdkEventVisibility* event) {
|
||||
// TODO(dougvj) The gdk docs say that this is deprecated because modern window
|
||||
// managers composite everything and nothing is truly hidden.
|
||||
@@ -258,8 +253,8 @@ bool GTKWindow::HandleWindowVisibility(GdkEventVisibility* event) {
|
||||
OnHidden(&e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GTKWindow::HandleWindowFocus(GdkEventFocus* event) {
|
||||
@@ -274,8 +269,8 @@ bool GTKWindow::HandleWindowFocus(GdkEventFocus* event) {
|
||||
OnGotFocus(&e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GTKWindow::HandleMouse(GdkEventAny* event) {
|
||||
@@ -326,26 +321,26 @@ bool GTKWindow::HandleMouse(GdkEventAny* event) {
|
||||
dy = e->delta_y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto e = MouseEvent(this, button, x, y, dx, dy);
|
||||
switch (event->type) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
OnMouseDown(&e);
|
||||
break;
|
||||
case GDK_BUTTON_RELEASE:
|
||||
OnMouseUp(&e);
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
OnMouseMove(&e);
|
||||
break;
|
||||
case GDK_SCROLL:
|
||||
OnMouseWheel(&e);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return e.is_handled();
|
||||
auto e = MouseEvent(this, button, x, y, dx, dy);
|
||||
switch (event->type) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
OnMouseDown(&e);
|
||||
break;
|
||||
case GDK_BUTTON_RELEASE:
|
||||
OnMouseUp(&e);
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
OnMouseMove(&e);
|
||||
break;
|
||||
case GDK_SCROLL:
|
||||
OnMouseWheel(&e);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return e.is_handled();
|
||||
}
|
||||
|
||||
bool GTKWindow::HandleKeyboard(GdkEventKey* event) {
|
||||
@@ -364,8 +359,8 @@ bool GTKWindow::HandleKeyboard(GdkEventKey* event) {
|
||||
case GDK_KEY_RELEASE:
|
||||
OnKeyUp(&e);
|
||||
break;
|
||||
// TODO(dougvj) GDK doesn't have a KEY CHAR event, so we will have to
|
||||
// figure out its equivalent here to call OnKeyChar(&e);
|
||||
// TODO(dougvj) GDK doesn't have a KEY CHAR event, so we will have to
|
||||
// figure out its equivalent here to call OnKeyChar(&e);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include "xenia/ui/menu_item.h"
|
||||
#include "xenia/ui/window.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -27,9 +27,10 @@ class GTKWindow : public Window {
|
||||
GTKWindow(Loop* loop, const std::wstring& title);
|
||||
~GTKWindow() override;
|
||||
|
||||
NativePlatformHandle native_platform_handle() const override {return nullptr;}
|
||||
NativeWindowHandle native_handle() const override { return window_;}
|
||||
|
||||
NativePlatformHandle native_platform_handle() const override {
|
||||
return nullptr;
|
||||
}
|
||||
NativeWindowHandle native_handle() const override { return window_; }
|
||||
|
||||
bool set_title(const std::wstring& title) override;
|
||||
|
||||
@@ -60,7 +61,6 @@ class GTKWindow : public Window {
|
||||
|
||||
void OnResize(UIEvent* e) override;
|
||||
|
||||
|
||||
private:
|
||||
void Create();
|
||||
GtkWidget* window_;
|
||||
@@ -75,16 +75,15 @@ class GTKWindow : public Window {
|
||||
|
||||
bool closing_ = false;
|
||||
bool fullscreen_ = false;
|
||||
|
||||
};
|
||||
|
||||
class GTKMenuItem : public MenuItem {
|
||||
public:
|
||||
GTKMenuItem(Type type, const std::wstring& text, const std::wstring& hotkey,
|
||||
std::function<void()> callback);
|
||||
std::function<void()> callback);
|
||||
~GTKMenuItem() override;
|
||||
|
||||
GtkWidget* handle() {return menu_;}
|
||||
GtkWidget* handle() { return menu_; }
|
||||
using MenuItem::OnSelected;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user