|
@@ -29,6 +29,9 @@
|
|
|
|
|
|
|
|
#include <tchar.h>
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
TypeHandle WinGraphicsWindow::_type_handle;
|
|
TypeHandle WinGraphicsWindow::_type_handle;
|
|
|
|
|
|
|
|
WinGraphicsWindow::WindowHandles WinGraphicsWindow::_window_handles;
|
|
WinGraphicsWindow::WindowHandles WinGraphicsWindow::_window_handles;
|
|
@@ -105,6 +108,7 @@ WinGraphicsWindow(GraphicsPipe *pipe,
|
|
|
_rcontrol_down = false;
|
|
_rcontrol_down = false;
|
|
|
_lalt_down = false;
|
|
_lalt_down = false;
|
|
|
_ralt_down = false;
|
|
_ralt_down = false;
|
|
|
|
|
+ _hparent = NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -140,7 +144,6 @@ move_pointer(int device, int x, int y) {
|
|
|
!_input_devices[0].get_pointer().get_in_window()) {
|
|
!_input_devices[0].get_pointer().get_in_window()) {
|
|
|
// If the window doesn't have input focus, or the mouse isn't
|
|
// If the window doesn't have input focus, or the mouse isn't
|
|
|
// currently within the window, forget it.
|
|
// currently within the window, forget it.
|
|
|
-
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -303,11 +306,15 @@ set_properties_now(WindowProperties &properties) {
|
|
|
properties.clear_z_order();
|
|
properties.clear_z_order();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (properties.has_foreground() && properties.get_foreground()) {
|
|
|
|
|
- if (!SetForegroundWindow(_hWnd)) {
|
|
|
|
|
- windisplay_cat.warning()
|
|
|
|
|
- << "SetForegroundWindow() failed!\n";
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if (properties.has_foreground() && properties.get_foreground())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!SetActiveWindow(_hWnd))
|
|
|
|
|
+ {
|
|
|
|
|
+ windisplay_cat.warning() << "SetForegroundWindow() failed!\n";
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
_properties.set_foreground(true);
|
|
_properties.set_foreground(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -394,10 +401,14 @@ open_window() {
|
|
|
new_foreground_window = old_foreground_window;
|
|
new_foreground_window = old_foreground_window;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!SetForegroundWindow(new_foreground_window)) {
|
|
|
|
|
|
|
+ if (!SetActiveWindow(new_foreground_window))
|
|
|
|
|
+ {
|
|
|
windisplay_cat.warning()
|
|
windisplay_cat.warning()
|
|
|
<< "SetForegroundWindow() failed!\n";
|
|
<< "SetForegroundWindow() failed!\n";
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Determine the initial open status of the IME.
|
|
// Determine the initial open status of the IME.
|
|
|
_ime_open = false;
|
|
_ime_open = false;
|
|
@@ -732,7 +743,8 @@ support_overlay_window(bool) {
|
|
|
// Description: Creates a fullscreen-style window.
|
|
// Description: Creates a fullscreen-style window.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
bool WinGraphicsWindow::
|
|
bool WinGraphicsWindow::
|
|
|
-open_fullscreen_window() {
|
|
|
|
|
|
|
+open_fullscreen_window()
|
|
|
|
|
+{
|
|
|
// from MSDN:
|
|
// from MSDN:
|
|
|
// An OpenGL window has its own pixel format. Because of this, only
|
|
// An OpenGL window has its own pixel format. Because of this, only
|
|
|
// device contexts retrieved for the client area of an OpenGL
|
|
// device contexts retrieved for the client area of an OpenGL
|
|
@@ -779,9 +791,17 @@ open_fullscreen_window() {
|
|
|
// up the desktop during the mode change
|
|
// up the desktop during the mode change
|
|
|
const WindowClass &wclass = register_window_class(_properties);
|
|
const WindowClass &wclass = register_window_class(_properties);
|
|
|
HINSTANCE hinstance = GetModuleHandle(NULL);
|
|
HINSTANCE hinstance = GetModuleHandle(NULL);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
_hWnd = CreateWindow(wclass._name.c_str(), title.c_str(), window_style,
|
|
_hWnd = CreateWindow(wclass._name.c_str(), title.c_str(), window_style,
|
|
|
0, 0, dwWidth, dwHeight,
|
|
0, 0, dwWidth, dwHeight,
|
|
|
hDesktopWindow, NULL, hinstance, 0);
|
|
hDesktopWindow, NULL, hinstance, 0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (!_hWnd) {
|
|
if (!_hWnd) {
|
|
|
windisplay_cat.error()
|
|
windisplay_cat.error()
|
|
|
<< "CreateWindow() failed!" << endl;
|
|
<< "CreateWindow() failed!" << endl;
|
|
@@ -873,12 +893,52 @@ open_regular_window() {
|
|
|
|
|
|
|
|
const WindowClass &wclass = register_window_class(_properties);
|
|
const WindowClass &wclass = register_window_class(_properties);
|
|
|
HINSTANCE hinstance = GetModuleHandle(NULL);
|
|
HINSTANCE hinstance = GetModuleHandle(NULL);
|
|
|
- _hWnd = CreateWindow(wclass._name.c_str(), title.c_str(), window_style,
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ _hparent = NULL;
|
|
|
|
|
+ if(_properties.has_parent_window())
|
|
|
|
|
+ _hparent = (HWND) _properties.get_parent_window();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(!_hparent)
|
|
|
|
|
+ {
|
|
|
|
|
+ _hWnd = CreateWindow(wclass._name.c_str(), title.c_str(), window_style,
|
|
|
x_origin, y_origin,
|
|
x_origin, y_origin,
|
|
|
win_rect.right - win_rect.left,
|
|
win_rect.right - win_rect.left,
|
|
|
win_rect.bottom - win_rect.top,
|
|
win_rect.bottom - win_rect.top,
|
|
|
NULL, NULL, hinstance, 0);
|
|
NULL, NULL, hinstance, 0);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ x_origin = 0;
|
|
|
|
|
+ y_origin = 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (_properties.has_origin()) {
|
|
|
|
|
+ x_origin = _properties.get_x_origin();
|
|
|
|
|
+ y_origin = _properties.get_y_origin();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _hWnd = CreateWindow(wclass._name.c_str(), title.c_str(),
|
|
|
|
|
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS ,
|
|
|
|
|
+ //x_origin, y_origin,
|
|
|
|
|
+ x_origin,y_origin,
|
|
|
|
|
+ x_size, y_size,
|
|
|
|
|
+ _hparent, NULL, hinstance, 0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(_hWnd)
|
|
|
|
|
+ {
|
|
|
|
|
+ // join or keyboard state with the parents
|
|
|
|
|
+ AttachThreadInput(GetWindowThreadProcessId(_hparent,NULL), GetCurrentThreadId(),TRUE);
|
|
|
|
|
+ // set us as the focus window for keyboard input
|
|
|
|
|
+ SetFocus(_hWnd);
|
|
|
|
|
+ _properties.set_foreground(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (!_hWnd) {
|
|
if (!_hWnd) {
|
|
|
windisplay_cat.error()
|
|
windisplay_cat.error()
|
|
|
<< "CreateWindow() failed!" << endl;
|
|
<< "CreateWindow() failed!" << endl;
|
|
@@ -1068,20 +1128,24 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
|
|
|
|
|
case WM_ACTIVATE:
|
|
case WM_ACTIVATE:
|
|
|
properties.set_minimized((wparam & 0xffff0000) != 0);
|
|
properties.set_minimized((wparam & 0xffff0000) != 0);
|
|
|
- if ((wparam & 0xffff) != WA_INACTIVE) {
|
|
|
|
|
|
|
+ if ((wparam & 0xffff) != WA_INACTIVE)
|
|
|
|
|
+ {
|
|
|
properties.set_foreground(true);
|
|
properties.set_foreground(true);
|
|
|
- if (is_fullscreen()) {
|
|
|
|
|
|
|
+ if (is_fullscreen())
|
|
|
|
|
+ {
|
|
|
// When a fullscreen window goes active, it automatically gets
|
|
// When a fullscreen window goes active, it automatically gets
|
|
|
// un-minimized.
|
|
// un-minimized.
|
|
|
ChangeDisplaySettings(&_fullscreen_display_mode, CDS_FULLSCREEN);
|
|
ChangeDisplaySettings(&_fullscreen_display_mode, CDS_FULLSCREEN);
|
|
|
GdiFlush();
|
|
GdiFlush();
|
|
|
- SetWindowPos(_hWnd, HWND_TOP, 0,0,0,0,
|
|
|
|
|
- SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOOWNERZORDER);
|
|
|
|
|
|
|
+ SetWindowPos(_hWnd, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOOWNERZORDER);
|
|
|
fullscreen_restored(properties);
|
|
fullscreen_restored(properties);
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
properties.set_foreground(false);
|
|
properties.set_foreground(false);
|
|
|
- if (is_fullscreen()) {
|
|
|
|
|
|
|
+ if (is_fullscreen())
|
|
|
|
|
+ {
|
|
|
// When a fullscreen window goes inactive, it automatically
|
|
// When a fullscreen window goes inactive, it automatically
|
|
|
// gets minimized.
|
|
// gets minimized.
|
|
|
properties.set_minimized(true);
|
|
properties.set_minimized(true);
|
|
@@ -1232,6 +1296,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ break;
|
|
|
|
|
|
|
|
|
|
|
|
|
case WM_IME_SETCONTEXT:
|
|
case WM_IME_SETCONTEXT:
|
|
@@ -1729,20 +1794,25 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case WM_KILLFOCUS:
|
|
case WM_KILLFOCUS:
|
|
|
- if (windisplay_cat.is_debug()) {
|
|
|
|
|
|
|
+ if (windisplay_cat.is_debug())
|
|
|
|
|
+ {
|
|
|
windisplay_cat.debug()
|
|
windisplay_cat.debug()
|
|
|
<< "killfocus\n";
|
|
<< "killfocus\n";
|
|
|
}
|
|
}
|
|
|
- if (!_lost_keypresses) {
|
|
|
|
|
|
|
+ if (!_lost_keypresses)
|
|
|
|
|
+ {
|
|
|
// Record the current state of the keyboard when the focus is
|
|
// Record the current state of the keyboard when the focus is
|
|
|
// lost, so we can check it for changes when we regain focus.
|
|
// lost, so we can check it for changes when we regain focus.
|
|
|
GetKeyboardState(_keyboard_state);
|
|
GetKeyboardState(_keyboard_state);
|
|
|
if (windisplay_cat.is_debug()) {
|
|
if (windisplay_cat.is_debug()) {
|
|
|
// Report the set of keys that are held down at the time of
|
|
// Report the set of keys that are held down at the time of
|
|
|
// the killfocus event.
|
|
// the killfocus event.
|
|
|
- for (int i = 0; i < num_virtual_keys; i++) {
|
|
|
|
|
- if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU) {
|
|
|
|
|
- if ((_keyboard_state[i] & 0x80) != 0) {
|
|
|
|
|
|
|
+ for (int i = 0; i < num_virtual_keys; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((_keyboard_state[i] & 0x80) != 0)
|
|
|
|
|
+ {
|
|
|
windisplay_cat.debug()
|
|
windisplay_cat.debug()
|
|
|
<< "on killfocus, key is down: " << i
|
|
<< "on killfocus, key is down: " << i
|
|
|
<< " (" << lookup_key(i) << ")\n";
|
|
<< " (" << lookup_key(i) << ")\n";
|
|
@@ -1751,14 +1821,18 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!hold_keys_across_windows) {
|
|
|
|
|
|
|
+ if (!hold_keys_across_windows)
|
|
|
|
|
+ {
|
|
|
// If we don't want to remember the keystate while the
|
|
// If we don't want to remember the keystate while the
|
|
|
// window focus is lost, then generate a keyup event
|
|
// window focus is lost, then generate a keyup event
|
|
|
// right now for each key currently held.
|
|
// right now for each key currently held.
|
|
|
double message_time = get_message_time();
|
|
double message_time = get_message_time();
|
|
|
- for (int i = 0; i < num_virtual_keys; i++) {
|
|
|
|
|
- if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU) {
|
|
|
|
|
- if ((_keyboard_state[i] & 0x80) != 0) {
|
|
|
|
|
|
|
+ for (int i = 0; i < num_virtual_keys; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i != VK_SHIFT && i != VK_CONTROL && i != VK_MENU)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ((_keyboard_state[i] & 0x80) != 0)
|
|
|
|
|
+ {
|
|
|
handle_keyrelease(lookup_key(i), message_time);
|
|
handle_keyrelease(lookup_key(i), message_time);
|
|
|
_keyboard_state[i] &= ~0x80;
|
|
_keyboard_state[i] &= ~0x80;
|
|
|
}
|
|
}
|
|
@@ -1770,6 +1844,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
// on may be lost.
|
|
// on may be lost.
|
|
|
_lost_keypresses = true;
|
|
_lost_keypresses = true;
|
|
|
}
|
|
}
|
|
|
|
|
+ properties.set_foreground(false);
|
|
|
|
|
+ system_changed_properties(properties);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETFOCUS:
|
|
case WM_SETFOCUS:
|
|
@@ -1797,6 +1873,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|
|
windisplay_cat.debug()
|
|
windisplay_cat.debug()
|
|
|
<< "setfocus\n";
|
|
<< "setfocus\n";
|
|
|
}
|
|
}
|
|
|
|
|
+ properties.set_foreground(true);
|
|
|
|
|
+ system_changed_properties(properties);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2450,3 +2528,5 @@ void get_client_rect_screen(HWND hwnd, RECT *view_rect) {
|
|
|
view_rect->right = lr.x;
|
|
view_rect->right = lr.x;
|
|
|
view_rect->bottom = lr.y;
|
|
view_rect->bottom = lr.y;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|