From b66a3243a8562cb5cddf5d5d1ffd21064e731752 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Wed, 24 Apr 2013 03:24:16 +0300 Subject: [PATCH] [Windows] Cleaner activation by relaying mouse presses to parent Canvas, similarly to the Linux implementation. --- src/java/org/lwjgl/opengl/WindowsDisplay.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index 959d5eef..1f78f3fe 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -170,6 +170,7 @@ final class WindowsDisplay implements DisplayImplementation { private Object current_cursor; private Canvas parent; private static boolean hasParent; + private long parent_hwnd; private WindowsKeyboard keyboard; private WindowsMouse mouse; @@ -227,7 +228,7 @@ final class WindowsDisplay implements DisplayImplementation { maximized = false; this.parent = parent; hasParent = parent != null; - long parent_hwnd = parent != null ? getHwnd(parent) : 0; + parent_hwnd = parent != null ? getHwnd(parent) : 0; this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd); this.resizable=false; if (hwnd == 0) { @@ -381,7 +382,6 @@ final class WindowsDisplay implements DisplayImplementation { else SwingUtilities.invokeLater(new Runnable() { public void run() { - MenuSelectionManager.defaultManager().clearSelectedPath(); parent.requestFocus(); } }); @@ -922,6 +922,16 @@ final class WindowsDisplay implements DisplayImplementation { WindowsEventDebug.printMessage(msg, wParam, lParam); }*/ + if ( parent != null && !isFocused ) { + switch ( msg ) { + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_XBUTTONDOWN: + sendMessage(parent_hwnd, msg, wParam, lParam); + } + } + switch (msg) { // disable screen saver and monitor power down messages which wreak havoc case WM_ACTIVATE: @@ -970,10 +980,9 @@ final class WindowsDisplay implements DisplayImplementation { appActivate(true); return 0L; case WM_MOUSEACTIVATE: - if ( !isFocused ) - grabFocus(); - - return 3L; // MA_NOACTIVATE + if ( parent != null ) + return 3L; // MA_NOACTIVATE + break; case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));