From b42c5f78c74855a1a6228d4d5c51dbbc6129e1f5 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 8 Jan 2016 18:30:34 -0800 Subject: [PATCH] Cleanup --- lime/_backend/flash/FlashWindow.hx | 1 + lime/_backend/html5/HTML5Window.hx | 4 +-- lime/_backend/native/NativeWindow.hx | 5 +++ lime/ui/Window.hx | 8 ++--- project/src/ExternalInterface.cpp | 2 ++ project/src/backend/sdl/SDLWindow.cpp | 51 ++++++++++++++------------- 6 files changed, 40 insertions(+), 31 deletions(-) diff --git a/lime/_backend/flash/FlashWindow.hx b/lime/_backend/flash/FlashWindow.hx index 58650e3e1..f1030c45e 100644 --- a/lime/_backend/flash/FlashWindow.hx +++ b/lime/_backend/flash/FlashWindow.hx @@ -94,6 +94,7 @@ class FlashWindow { } + public function setEnableTextEvents (value:Bool):Bool { return enableTextEvents = value; diff --git a/lime/_backend/html5/HTML5Window.hx b/lime/_backend/html5/HTML5Window.hx index 7c4a0d41e..f5085e8db 100644 --- a/lime/_backend/html5/HTML5Window.hx +++ b/lime/_backend/html5/HTML5Window.hx @@ -599,7 +599,7 @@ class HTML5Window { public function setBorderless (value:Bool):Bool { - return false; + return value; } @@ -696,7 +696,7 @@ class HTML5Window { public function setResizable (value:Bool):Bool { - return false; + return value; } diff --git a/lime/_backend/native/NativeWindow.hx b/lime/_backend/native/NativeWindow.hx index 2606c96e6..f6ba24f8f 100644 --- a/lime/_backend/native/NativeWindow.hx +++ b/lime/_backend/native/NativeWindow.hx @@ -274,6 +274,11 @@ class NativeWindow { #if !macro lime_window_set_resizable (handle, value); + + // TODO: remove need for workaround + + lime_window_set_borderless (handle, !parent.__borderless); + lime_window_set_borderless (handle, parent.__borderless); #end } diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index eb2c94db8..27245dc40 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -21,7 +21,7 @@ class Window { public var application (default, null):Application; - public var borderless(get, set):Bool; + public var borderless (get, set):Bool; public var config:WindowConfig; public var display (get, null):Display; public var enableTextEvents (get, set):Bool; @@ -71,7 +71,6 @@ class Window { @:noCompletion private var __width:Int; @:noCompletion private var __x:Int; @:noCompletion private var __y:Int; - @:noCompletion private var __returnState: { width:Int, height:Int, x:Int, y:Int, resizable:Bool, borderless:Bool }; public function new (config:WindowConfig = null) { @@ -402,10 +401,9 @@ class Window { @:noCompletion private function set_resizable (value:Bool):Bool { - __resizable = backend.setResizable(value); - backend.setBorderless(!__borderless); //resizable property won't update until you change another property like the borderless property - backend.setBorderless(__borderless); + __resizable = backend.setResizable (value); return __resizable; + } diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 2ac53cf14..a4c8c3317 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1371,6 +1371,7 @@ namespace lime { } + void lime_window_set_enable_text_events (value window, bool enabled) { Window* targetWindow = (Window*)val_data (window); @@ -1411,6 +1412,7 @@ namespace lime { } + value lime_window_set_title (value window, HxString title) { Window* targetWindow = (Window*)val_data (window); diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 8c70a56ab..d1693e500 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -335,41 +335,35 @@ namespace lime { } - const char* SDLWindow::SetTitle (const char* title) { - - SDL_SetWindowTitle (sdlWindow, title); - - return title; - - } - - bool SDLWindow::SetResizable (bool resizable) { - #ifdef HX_WINDOWS + #if defined(HX_WINDOWS) SDL_SysWMinfo info; - SDL_VERSION(&info.version); - SDL_GetWindowWMInfo(sdlWindow, &info); - - //toggling the window "resizable" property after window creation is not currently supported in SDL, so we have to do it manually + SDL_VERSION (&info.version); + SDL_GetWindowWMInfo (sdlWindow, &info); HWND hwnd = info.info.win.window; - DWORD style = GetWindowLong(hwnd, GWL_STYLE); - if (resizable) - style |= WS_THICKFRAME; - else - style &= ~WS_THICKFRAME; - SetWindowLong(hwnd, GWL_STYLE, style); + DWORD style = GetWindowLong (hwnd, GWL_STYLE); - #endif - #ifdef HX_MACOS + if (resizable) { + + style |= WS_THICKFRAME; + + } else { + + style &= ~WS_THICKFRAME; + + } + + SetWindowLong (hwnd, GWL_STYLE, style); + + #elif defined(HX_MACOS) //TODO //consider: http://stackoverflow.com/questions/10473700/set-window-resizable/10473949#10473949 - #endif - #ifdef HX_LINUX + #elif defined(HX_LINUX) //TODO //maybe something in here? https://tronche.com/gui/x/xlib/ICC/client-to-window-manager/wm-normal-hints.html @@ -381,6 +375,15 @@ namespace lime { } + const char* SDLWindow::SetTitle (const char* title) { + + SDL_SetWindowTitle (sdlWindow, title); + + return title; + + } + + Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) { return new SDLWindow (application, width, height, flags, title);