Merge branch 'master' of github.com:buggins/dlangui

This commit is contained in:
Vadim Lopatin 2017-08-14 10:10:28 +03:00
commit 075708fae3
7 changed files with 116 additions and 20 deletions

View File

@ -5,9 +5,9 @@ platform:
environment: environment:
matrix: matrix:
- DC: dmd - DC: dmd
DVersion: 2.074.0 DVersion: 2.075.0
- DC: ldc - DC: ldc
DVersion: 1.1.0 DVersion: 1.3.0
matrix: matrix:
allow_failures: allow_failures:
@ -48,13 +48,8 @@ install:
echo "finished."; echo "finished.";
pushd c:\\; pushd c:\\;
7z x ldc.zip > $null; 7z x ldc.zip > $null;
mv ldc2-$($version)-win$($env:Dmodel)-msvc ldc2;
popd; popd;
} }
Invoke-WebRequest "https://code.dlang.org/files/dub-1.1.1-windows-x86.zip" -OutFile "c:\dub.zip";
pushd c:\\;
7z x dub.zip -odub > $null;
popd;
} }
- ps: SetUpDCompiler - ps: SetUpDCompiler
@ -74,8 +69,9 @@ before_build:
$env:PATH += ";C:\dub"; $env:PATH += ";C:\dub";
} }
elseif($env:DC -eq "ldc"){ elseif($env:DC -eq "ldc"){
$env:PATH += ";C:\ldc2\bin"; $version = $env:DVersion;
$env:PATH += ";C:\dub"; $model = $env:Dmodel;
$env:PATH += ";C:\ldc2-$($version)-win$($model)-msvc\bin";
$env:DC = "ldc2"; $env:DC = "ldc2";
} }
- ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall"; - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";

View File

@ -37,6 +37,15 @@ class AndroidWindow : Window {
return null; return null;
} }
override protected void handleWindowActivityChange(bool isWindowActive) {
super.handleWindowActivityChange(isWindowActive);
}
override @property bool isActive() {
//todo:
return true;
}
protected dstring _caption; protected dstring _caption;
/// returns window caption /// returns window caption
override @property dstring windowCaption() { override @property dstring windowCaption() {

View File

@ -118,6 +118,12 @@ interface OnWindowStateHandler {
bool onWindowStateChange(Window window, WindowState winState, Rect rect); bool onWindowStateChange(Window window, WindowState winState, Rect rect);
} }
/// Window activate/deactivate signal listener
interface OnWindowActivityHandler {
/// signal listener - called when window activity is changed
bool onWindowActivityChange(Window window, bool isWindowActive);
}
/// protected event list /// protected event list
/// references to posted messages can be stored here at least to keep live reference and avoid GC /// references to posted messages can be stored here at least to keep live reference and avoid GC
/// as well, on some platforms it's easy to send id to message queue, but not pointer /// as well, on some platforms it's easy to send id to message queue, but not pointer
@ -907,6 +913,7 @@ class Window : CustomEventTarget {
} }
protected Widget _focusedWidget; protected Widget _focusedWidget;
protected auto _focusStateToApply = State.Focused;
/// returns current focused widget /// returns current focused widget
@property Widget focusedWidget() { @property Widget focusedWidget() {
if (!isChild(_focusedWidget)) if (!isChild(_focusedWidget))
@ -922,6 +929,7 @@ class Window : CustomEventTarget {
auto targetState = State.Focused; auto targetState = State.Focused;
if(reason == FocusReason.TabFocus) if(reason == FocusReason.TabFocus)
targetState = State.Focused | State.KeyboardFocused; targetState = State.Focused | State.KeyboardFocused;
_focusStateToApply = targetState;
if (oldFocus is newFocus) if (oldFocus is newFocus)
return oldFocus; return oldFocus;
if (oldFocus !is null) { if (oldFocus !is null) {
@ -943,6 +951,40 @@ class Window : CustomEventTarget {
} }
return _focusedWidget; return _focusedWidget;
} }
protected Widget removeFocus() {
if (!isChild(_focusedWidget))
_focusedWidget = null;
if (_focusedWidget) {
_focusedWidget.resetState(_focusStateToApply);
update();
}
return _focusedWidget;
}
protected Widget applyFocus() {
if (!isChild(_focusedWidget))
_focusedWidget = null;
if (_focusedWidget) {
_focusedWidget.setState(_focusStateToApply);
update();
}
return _focusedWidget;
}
abstract @property bool isActive();
/// window state change signal
Signal!OnWindowActivityHandler windowActivityChanged;
protected void handleWindowActivityChange(bool isWindowActive) {
if (isWindowActive)
applyFocus();
else
removeFocus();
if (windowActivityChanged.assigned)
windowActivityChanged(this, isWindowActive);
}
/// dispatch key event to widgets which have wantsKeyTracking == true /// dispatch key event to widgets which have wantsKeyTracking == true
protected bool dispatchKeyEvent(Widget root, KeyEvent event) { protected bool dispatchKeyEvent(Widget root, KeyEvent event) {

View File

@ -56,6 +56,16 @@ class ConsoleWindow : Window {
override @property Window parentWindow() { override @property Window parentWindow() {
return _parent; return _parent;
} }
override protected void handleWindowActivityChange(bool isWindowActive) {
super.handleWindowActivityChange(isWindowActive);
}
override @property bool isActive() {
// todo
return true;
}
protected bool _visible; protected bool _visible;
/// returns true if window is shown /// returns true if window is shown

View File

@ -455,15 +455,22 @@ class SDLWindow : Window {
else else
handleWindowStateChange(newState, RECT_VALUE_IS_NOT_SET); handleWindowStateChange(newState, RECT_VALUE_IS_NOT_SET);
return res; return res;
} }
override @property Window parentWindow() { override @property Window parentWindow() {
return _parent; return _parent;
} }
override protected void handleWindowActivityChange(bool isWindowActive) {
super.handleWindowActivityChange(isWindowActive);
}
override @property bool isActive() {
uint flags = SDL_GetWindowFlags(_win);
return (flags & SDL_WINDOW_INPUT_FOCUS) == SDL_WINDOW_INPUT_FOCUS;
}
protected dstring _caption; protected dstring _caption;
override @property dstring windowCaption() { override @property dstring windowCaption() {
@ -1344,9 +1351,11 @@ class SDLPlatform : Platform {
debug(DebugSDL) Log.d("SDL_WINDOWEVENT_FOCUS_GAINED - ", w.windowCaption); debug(DebugSDL) Log.d("SDL_WINDOWEVENT_FOCUS_GAINED - ", w.windowCaption);
if (!_windowsMinimized) if (!_windowsMinimized)
w.restoreModalChilds(); w.restoreModalChilds();
w.handleWindowActivityChange(true);
break; break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
debug(DebugSDL) Log.d("SDL_WINDOWEVENT_FOCUS_LOST - ", w.windowCaption); debug(DebugSDL) Log.d("SDL_WINDOWEVENT_FOCUS_LOST - ", w.windowCaption);
w.handleWindowActivityChange(false);
break; break;
default: default:
break; break;

View File

@ -501,6 +501,14 @@ class Win32Window : Window {
return _w32parent; return _w32parent;
} }
override protected void handleWindowActivityChange(bool isWindowActive) {
super.handleWindowActivityChange(isWindowActive);
}
override @property bool isActive() {
return _hwnd == GetForegroundWindow();
}
override @property dstring windowCaption() { override @property dstring windowCaption() {
return _caption; return _caption;
} }
@ -1395,6 +1403,16 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
} }
return 0; return 0;
case WM_ACTIVATE:
{
if (window) {
if (wParam == WA_INACTIVE)
window.handleWindowActivityChange(false);
else if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE)
window.handleWindowActivityChange(true);
}
}
return 0;
case CUSTOM_MESSAGE_ID: case CUSTOM_MESSAGE_ID:
if (window !is null) { if (window !is null) {
window.handlePostedEvent(cast(uint)lParam); window.handlePostedEvent(cast(uint)lParam);

View File

@ -444,6 +444,10 @@ class X11Window : DWindow {
} }
} }
override protected void handleWindowStateChange(WindowState newState, Rect newWindowRect = RECT_VALUE_IS_NOT_SET) {
super.handleWindowStateChange(newState, newWindowRect);
}
protected final void changeWindowState(int action, Atom firstProperty, Atom secondProperty = None) nothrow protected final void changeWindowState(int action, Atom firstProperty, Atom secondProperty = None) nothrow
{ {
XEvent ev; XEvent ev;
@ -561,6 +565,16 @@ class X11Window : DWindow {
return _parent; return _parent;
} }
private bool _isActive;
override protected void handleWindowActivityChange(bool isWindowActive) {
_isActive = isWindowActive;
super.handleWindowActivityChange(isWindowActive);
}
override @property bool isActive() {
return _isActive;
}
override @property dstring windowCaption() { override @property dstring windowCaption() {
return _caption; return _caption;
} }
@ -618,10 +632,6 @@ class X11Window : DWindow {
_platform.closeWindow(this); _platform.closeWindow(this);
} }
override protected void handleWindowStateChange(WindowState newState, Rect newWindowRect = RECT_VALUE_IS_NOT_SET) {
super.handleWindowStateChange(newState, newWindowRect);
}
ColorDrawBuf _drawbuf; ColorDrawBuf _drawbuf;
protected void drawUsingBitmap() { protected void drawUsingBitmap() {
if (_dx > 0 && _dy > 0) { if (_dx > 0 && _dy > 0) {
@ -1519,16 +1529,18 @@ class X11Platform : Platform {
case FocusIn: case FocusIn:
Log.d("X11: FocusIn event"); Log.d("X11: FocusIn event");
X11Window w = findWindow(event.xfocus.window); X11Window w = findWindow(event.xfocus.window);
if (!w) { if (w)
w.handleWindowActivityChange(true);
else
Log.e("Window not found"); Log.e("Window not found");
}
break; break;
case FocusOut: case FocusOut:
Log.d("X11: FocusOut event"); Log.d("X11: FocusOut event");
X11Window w = findWindow(event.xfocus.window); X11Window w = findWindow(event.xfocus.window);
if (!w) { if (w)
w.handleWindowActivityChange(false);
else
Log.e("Window not found"); Log.e("Window not found");
}
break; break;
case KeymapNotify: case KeymapNotify:
Log.d("X11: KeymapNotify event"); Log.d("X11: KeymapNotify event");
@ -1667,7 +1679,7 @@ class X11Platform : Platform {
for (uint i = 0; i + 1 < _windowList.length; i++) { for (uint i = 0; i + 1 < _windowList.length; i++) {
if (_windowList[i] is w) { if (_windowList[i] is w) {
for (uint j = i + 1; j < _windowList.length; j++) { for (uint j = i + 1; j < _windowList.length; j++) {
if (_windowList[j].flags & WindowFlag.Modal && _windowList[j]._windowState != WindowState.hidden) if (_windowList[j].flags & WindowFlag.Modal && _windowList[j].windowState != WindowState.hidden)
return true; return true;
} }
return false; return false;