diff --git a/modules/client/client.lua b/modules/client/client.lua index 816b61c1..67040b68 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -19,7 +19,7 @@ function Client.init() local displaySize = g_window.getDisplaySize() local pos = { x = (displaySize.width - size.width)/2, y = (displaySize.height - size.height)/2 } - pos = Settings.getPoint('window-pos', size) + pos = Settings.getPoint('window-pos', pos) g_window.move(pos) -- window maximized? diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 14b164d9..1141bc87 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -1,14 +1,14 @@ Options = {} --- public functions function Options.load() - -- set default settings - Settings.setDefault('vsync', true) - Settings.setDefault('showfps', true) + local booleanOptions = { vsync = true, + showfps = true, + fullscreen = false } - -- load the options - Options.enableVsync(Settings.getBoolean('vsync')) - Options.enableFps(Settings.getBoolean('showfps')) + for k,v in pairs(booleanOptions) do + Settings.setDefault(k, v) + Options.changeOption(k, Settings.getBoolean(k)) + end end function Options.show() @@ -20,15 +20,14 @@ function Options.openWebpage() end -- private functions -function Options.enableVsync(on) - g_window.setVerticalSync(on) - Settings.set('vsync', on) - Options.vsync = on -end - -function Options.enableFps(on) - local frameCounter = rootWidget:recursiveGetChildById('frameCounter') - frameCounter:setVisible(on) - Settings.set('showfps', on) - Options.fps = on +function Options.changeOption(key, status) + if key == 'vsync' then + g_window.setVerticalSync(status) + elseif key == 'showfps' then + addEvent(function() rootWidget:recursiveGetChildById('frameCounter'):setVisible(status) end) + elseif key == 'fullscreen' then + addEvent(function() g_window.setFullscreen(status) end) + end + Settings.set(key, status) + Options[key] = status end diff --git a/modules/client_options/options.otui b/modules/client_options/options.otui index 8e57ad36..c41e8a11 100644 --- a/modules/client_options/options.otui +++ b/modules/client_options/options.otui @@ -1,32 +1,38 @@ -MainWindow - id: optionsWindow - title: Options - size: 286 100 +OptionCheckBox < CheckBox + margin-left: 18 + margin-right: 18 + @onCheckChange: Options.changeOption(self:getId(), self:isChecked()) + @onSetup: self:setChecked(Options[self:getId()]) - CheckBox - id: vsyncCheckBox - text: Enable vertical synchronization - tooltip: Limits FPS to 60 + $first: + margin-top: 28 anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top - margin-top: 28 - margin-left: 18 - margin-right: 18 - @onCheckChange: Options.enableVsync(self:isChecked()) - @onSetup: self:setChecked(Options.vsync) - CheckBox - id: fpsCheckBox - text: Show frame rate + $middle: + margin-top: 10 anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom - margin-top: 10 - margin-left: 18 - margin-right: 18 - @onCheckChange: Options.enableFps(self:isChecked()) - @onSetup: self:setChecked(Options.fps) + +MainWindow + id: optionsWindow + title: Options + size: 286 120 + + OptionCheckBox + id: vsync + text: Enable vertical synchronization + tooltip: Limits FPS to 60 + + OptionCheckBox + id: showfps + text: Show frame rate + + OptionCheckBox + id: fullscreen + text: Fullscreen Button text: Ok diff --git a/src/framework/platform/platformwindow.cpp b/src/framework/platform/platformwindow.cpp index 87a24356..88eff0af 100644 --- a/src/framework/platform/platformwindow.cpp +++ b/src/framework/platform/platformwindow.cpp @@ -34,7 +34,7 @@ PlatformWindow& g_window = window; void PlatformWindow::updateUnmaximizedCoords() { - if(!isMaximized()) { + if(!isMaximized() && !isFullscreen()) { m_unmaximizedPos = m_pos; m_unmaximizedSize = m_size; } diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index eaf66e5e..14dce8d7 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -495,8 +495,6 @@ void X11Window::hide() void X11Window::maximize() { - updateUnmaximizedCoords(); - Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False); Atom wmStateMaximizedVert = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_VERT", False); Atom wmStateMaximizedHorz = XInternAtom(m_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);