diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.cpp | 21 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_glfw.h | 2 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 7 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.hxx | 2 | ||||
| -rw-r--r-- | src/common/emu_window.h | 34 |
5 files changed, 58 insertions, 8 deletions
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 28aa3450c..7e1e1c9a6 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp | |||
| @@ -46,6 +46,15 @@ void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int hei | |||
| 46 | _dbg_assert_(GUI, width > 0); | 46 | _dbg_assert_(GUI, width > 0); |
| 47 | _dbg_assert_(GUI, height > 0); | 47 | _dbg_assert_(GUI, height > 0); |
| 48 | 48 | ||
| 49 | // TODO: It's actually more interesting to us what the framebuffer size ends up being. | ||
| 50 | int adjusted_width = std::max<unsigned>(width, GetEmuWindow(win)->GetActiveConfig().min_client_area_size.first); | ||
| 51 | int adjusted_height = std::max<unsigned>(height, GetEmuWindow(win)->GetActiveConfig().min_client_area_size.second); | ||
| 52 | |||
| 53 | if (adjusted_width != width || adjusted_height != height) { | ||
| 54 | glfwSetWindowSize(win, adjusted_width, adjusted_height); | ||
| 55 | return; | ||
| 56 | } | ||
| 57 | |||
| 49 | GetEmuWindow(win)->NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(width, height)); | 58 | GetEmuWindow(win)->NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(width, height)); |
| 50 | } | 59 | } |
| 51 | 60 | ||
| @@ -136,3 +145,15 @@ void EmuWindow_GLFW::ReloadSetKeymaps() { | |||
| 136 | KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, HID_User::PAD_CIRCLE_UP); | 145 | KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, HID_User::PAD_CIRCLE_UP); |
| 137 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); | 146 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); |
| 138 | } | 147 | } |
| 148 | |||
| 149 | void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { | ||
| 150 | std::pair<int,int> current_size; | ||
| 151 | glfwGetWindowSize(m_render_window, ¤t_size.first, ¤t_size.second); | ||
| 152 | |||
| 153 | _dbg_assert_(GUI, (int)minimal_size.first > 0 && (int)minimal_size.second > 0); | ||
| 154 | int new_width = std::max(current_size.first, (int)minimal_size.first); | ||
| 155 | int new_height = std::max(current_size.second, (int)minimal_size.second); | ||
| 156 | |||
| 157 | if (current_size != std::make_pair(new_width, new_height)) | ||
| 158 | glfwSetWindowSize(m_render_window, new_width, new_height); | ||
| 159 | } | ||
diff --git a/src/citra/emu_window/emu_window_glfw.h b/src/citra/emu_window/emu_window_glfw.h index 0da688a54..61cef4e65 100644 --- a/src/citra/emu_window/emu_window_glfw.h +++ b/src/citra/emu_window/emu_window_glfw.h | |||
| @@ -37,6 +37,8 @@ public: | |||
| 37 | void ReloadSetKeymaps() override; | 37 | void ReloadSetKeymaps() override; |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override; | ||
| 41 | |||
| 40 | static EmuWindow_GLFW* GetEmuWindow(GLFWwindow* win); | 42 | static EmuWindow_GLFW* GetEmuWindow(GLFWwindow* win); |
| 41 | 43 | ||
| 42 | GLFWwindow* m_render_window; ///< Internal GLFW render window | 44 | GLFWwindow* m_render_window; ///< Internal GLFW render window |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 34a79b306..8c12cb228 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -129,6 +129,9 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this | |||
| 129 | setLayout(layout); | 129 | setLayout(layout); |
| 130 | connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); | 130 | connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); |
| 131 | 131 | ||
| 132 | setMinimumSize(GetActiveConfig().min_client_area_size.first, | ||
| 133 | GetActiveConfig().min_client_area_size.second); | ||
| 134 | |||
| 132 | OnFramebufferSizeChanged(); | 135 | OnFramebufferSizeChanged(); |
| 133 | NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height())); | 136 | NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height())); |
| 134 | 137 | ||
| @@ -275,3 +278,7 @@ void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) | |||
| 275 | { | 278 | { |
| 276 | NotifyClientAreaSizeChanged(std::make_pair(width, height)); | 279 | NotifyClientAreaSizeChanged(std::make_pair(width, height)); |
| 277 | } | 280 | } |
| 281 | |||
| 282 | void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { | ||
| 283 | setMinimumSize(minimal_size.first, minimal_size.second); | ||
| 284 | } | ||
diff --git a/src/citra_qt/bootmanager.hxx b/src/citra_qt/bootmanager.hxx index 3a18f98fd..3eec1668e 100644 --- a/src/citra_qt/bootmanager.hxx +++ b/src/citra_qt/bootmanager.hxx | |||
| @@ -121,6 +121,8 @@ public slots: | |||
| 121 | void moveContext(); // overridden | 121 | void moveContext(); // overridden |
| 122 | 122 | ||
| 123 | private: | 123 | private: |
| 124 | void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override; | ||
| 125 | |||
| 124 | QGLWidget* child; | 126 | QGLWidget* child; |
| 125 | 127 | ||
| 126 | EmuThread emu_thread; | 128 | EmuThread emu_thread; |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index 72c40c6a4..baacc6da2 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -20,6 +20,7 @@ public: | |||
| 20 | bool fullscreen; | 20 | bool fullscreen; |
| 21 | int res_width; | 21 | int res_width; |
| 22 | int res_height; | 22 | int res_height; |
| 23 | std::pair<unsigned,unsigned> min_client_area_size; | ||
| 23 | }; | 24 | }; |
| 24 | 25 | ||
| 25 | /// Swap buffers to display the next frame | 26 | /// Swap buffers to display the next frame |
| @@ -42,8 +43,8 @@ public: | |||
| 42 | /// Signals a key release action to the HID module | 43 | /// Signals a key release action to the HID module |
| 43 | static void KeyReleased(KeyMap::HostDeviceKey key); | 44 | static void KeyReleased(KeyMap::HostDeviceKey key); |
| 44 | 45 | ||
| 45 | WindowConfig GetConfig() const { | 46 | const WindowConfig& GetActiveConfig() const { |
| 46 | return config; | 47 | return active_config; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | void SetConfig(const WindowConfig& val) { | 50 | void SetConfig(const WindowConfig& val) { |
| @@ -72,24 +73,40 @@ public: | |||
| 72 | window_title = val; | 73 | window_title = val; |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 76 | // Only call this from the GUI thread! | ||
| 77 | void ProcessConfigurationChanges() { | ||
| 78 | // TODO: For proper thread safety, we should eventually implement a proper | ||
| 79 | // multiple-writer/single-reader queue... | ||
| 80 | |||
| 81 | if (config.min_client_area_size != active_config.min_client_area_size) { | ||
| 82 | OnMinimalClientAreaChangeRequest(config.min_client_area_size); | ||
| 83 | config.min_client_area_size = active_config.min_client_area_size; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 75 | protected: | 87 | protected: |
| 76 | EmuWindow() : // TODO: What the hell... -.- - don't hardcode dimensions here without applying them in a sensible manner... | 88 | EmuWindow() : |
| 77 | window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc)) | 89 | window_title(Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc)) |
| 78 | m_client_area_width(640), | 90 | { |
| 79 | m_client_area_height(480), | 91 | // TODO |
| 80 | {} | 92 | config.min_client_area_size = std::make_pair(300u, 500u); |
| 93 | active_config = config; | ||
| 94 | } | ||
| 81 | virtual ~EmuWindow() {} | 95 | virtual ~EmuWindow() {} |
| 82 | 96 | ||
| 83 | std::pair<unsigned,unsigned> NotifyFramebufferSizeChanged(const std::pair<unsigned,unsigned>& size) { | 97 | std::pair<unsigned,unsigned> NotifyFramebufferSizeChanged(const std::pair<unsigned,unsigned>& size) { |
| 84 | framebuffer_size = size; | 98 | framebuffer_size = size; |
| 85 | } | 99 | } |
| 86 | 100 | ||
| 87 | void NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned> size) { | 101 | void NotifyClientAreaSizeChanged(const std::pair<unsigned,unsigned>& size) { |
| 88 | client_area_width = size.first; | 102 | client_area_width = size.first; |
| 89 | client_area_height = size.second; | 103 | client_area_height = size.second; |
| 90 | } | 104 | } |
| 91 | 105 | ||
| 92 | private: | 106 | private: |
| 107 | virtual void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { | ||
| 108 | } | ||
| 109 | |||
| 93 | std::string window_title; ///< Current window title, should be used by window impl. | 110 | std::string window_title; ///< Current window title, should be used by window impl. |
| 94 | 111 | ||
| 95 | std::pair<unsigned,unsigned> framebuffer_size; | 112 | std::pair<unsigned,unsigned> framebuffer_size; |
| @@ -97,5 +114,6 @@ private: | |||
| 97 | unsigned client_area_width; ///< Current client width, should be set by window impl. | 114 | unsigned client_area_width; ///< Current client width, should be set by window impl. |
| 98 | unsigned client_area_height; ///< Current client height, should be set by window impl. | 115 | unsigned client_area_height; ///< Current client height, should be set by window impl. |
| 99 | 116 | ||
| 100 | WindowConfig config; ///< Internal configuration | 117 | WindowConfig config; ///< Internal configuration (changes pending for being applied in ProcessConfigurationChanges) |
| 118 | WindowConfig active_config; ///< Internal active configuration | ||
| 101 | }; | 119 | }; |