mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
partially-working cursor-visible handling
This commit is contained in:
parent
9b5662b635
commit
eda5a0383a
@ -307,44 +307,43 @@ LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
LONG wdxGraphicsWindow::
|
LONG wdxGraphicsWindow::
|
||||||
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||||
int button = -1;
|
int button = -1;
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
|
case WM_PAINT: {
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
case WM_PAINT: {
|
if(DXREADY)
|
||||||
PAINTSTRUCT ps;
|
show_frame();
|
||||||
BeginPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(DXREADY)
|
case WM_MOUSEMOVE:
|
||||||
show_frame();
|
if(!DXREADY)
|
||||||
EndPaint(hwnd, &ps);
|
break;
|
||||||
return 0;
|
|
||||||
|
// Win32 doesn't return the same numbers as X does when the mouse
|
||||||
|
// goes beyond the upper or left side of the window
|
||||||
|
#define SET_MOUSE_COORD(iVal,VAL) { \
|
||||||
|
iVal = VAL; \
|
||||||
|
if(iVal & 0x8000) \
|
||||||
|
iVal -= 0x10000; \
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
SET_MOUSE_COORD(x,LOWORD(lparam));
|
||||||
if(!DXREADY)
|
SET_MOUSE_COORD(y,HIWORD(lparam));
|
||||||
break;
|
|
||||||
|
|
||||||
// Win32 doesn't return the same numbers as X does when the mouse
|
if(mouse_motion_enabled()
|
||||||
// goes beyond the upper or left side of the window
|
&& wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
|
||||||
#define SET_MOUSE_COORD(iVal,VAL) { \
|
handle_mouse_motion(x, y);
|
||||||
iVal = VAL; \
|
} else if(mouse_passive_motion_enabled() &&
|
||||||
if(iVal & 0x8000) \
|
((wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)) {
|
||||||
iVal -= 0x10000; \
|
handle_mouse_motion(x, y);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
SET_MOUSE_COORD(x,LOWORD(lparam));
|
|
||||||
SET_MOUSE_COORD(y,HIWORD(lparam));
|
|
||||||
|
|
||||||
if(mouse_motion_enabled()
|
|
||||||
&& wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
|
|
||||||
handle_mouse_motion(x, y);
|
|
||||||
} else if(mouse_passive_motion_enabled() &&
|
|
||||||
((wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)) {
|
|
||||||
handle_mouse_motion(x, y);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_IME_NOTIFY:
|
case WM_IME_NOTIFY:
|
||||||
if (wparam == IMN_SETOPENSTATUS) {
|
if (wparam == IMN_SETOPENSTATUS) {
|
||||||
@ -561,7 +560,14 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
_WindowAdjustingType = MovingOrResizing;
|
_WindowAdjustingType = MovingOrResizing;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
/*
|
||||||
|
case WM_SETCURSOR: {
|
||||||
|
if(!_props._bCursorIsVisible)
|
||||||
|
return true; // avoid defaultwindproc showing the cursor
|
||||||
|
break;
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
case WM_DISPLAYCHANGE: {
|
case WM_DISPLAYCHANGE: {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
width = LOWORD(lparam); height = HIWORD(lparam);
|
width = LOWORD(lparam); height = HIWORD(lparam);
|
||||||
@ -625,13 +631,13 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_mouse_entry_enabled)
|
|
||||||
handle_mouse_entry(MOUSE_ENTERED,_pParentWindowGroup->_hMouseCursor);
|
|
||||||
|
|
||||||
POINT point;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
ScreenToClient(hwnd, &point);
|
ScreenToClient(hwnd, &point);
|
||||||
|
|
||||||
|
if(_mouse_entry_enabled)
|
||||||
|
handle_mouse_entry(MOUSE_ENTERED,point.x,point.y);
|
||||||
|
|
||||||
// this is a hack to make sure common modifier keys have proper state
|
// this is a hack to make sure common modifier keys have proper state
|
||||||
// since at focus loss, app may never receive key-up event corresponding to
|
// since at focus loss, app may never receive key-up event corresponding to
|
||||||
// a key-down. it would be better to know the exact set of ModifierButtons the
|
// a key-down. it would be better to know the exact set of ModifierButtons the
|
||||||
@ -652,7 +658,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_mouse_entry_enabled)
|
if(_mouse_entry_enabled)
|
||||||
handle_mouse_entry(MOUSE_EXITED,_pParentWindowGroup->_hMouseCursor);
|
handle_mouse_entry(MOUSE_EXITED,0,0);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<NUM_MODIFIER_KEYS;i++) {
|
for(i=0;i<NUM_MODIFIER_KEYS;i++) {
|
||||||
@ -730,8 +736,11 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//case WM_CREATE:
|
case WM_CREATE: {
|
||||||
// break;
|
if(!_props._bCursorIsVisible)
|
||||||
|
ShowCursor(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_ACTIVATEAPP: {
|
case WM_ACTIVATEAPP: {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -1033,6 +1042,7 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_bLoadedCustomCursor=false;
|
_bLoadedCustomCursor=false;
|
||||||
|
_hMouseCursor=NULL;
|
||||||
|
|
||||||
if(!windows_color_cursor_filename.empty()) {
|
if(!windows_color_cursor_filename.empty()) {
|
||||||
// card support for full color non-black/white GDI cursors varies greatly. if the cursor is not supported,
|
// card support for full color non-black/white GDI cursors varies greatly. if the cursor is not supported,
|
||||||
@ -2448,8 +2458,6 @@ void wdxGraphicsWindow::end_frame(void) {
|
|||||||
GraphicsWindow::end_frame();
|
GraphicsWindow::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: handle_window_move
|
// Function: handle_window_move
|
||||||
// Access:
|
// Access:
|
||||||
@ -2475,10 +2483,15 @@ void wdxGraphicsWindow::handle_mouse_motion(int x, int y) {
|
|||||||
// Access:
|
// Access:
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void wdxGraphicsWindow::handle_mouse_entry(int state,HCURSOR hCursor) {
|
|
||||||
|
// BUGBUG: this needs to be called when mouse enters. right now it's just called when keybd focus changes
|
||||||
|
void wdxGraphicsWindow::handle_mouse_entry(int state, int x, int y) {
|
||||||
|
// ShowCursor(_props._bCursorIsVisible);
|
||||||
|
|
||||||
if(state == MOUSE_EXITED) {
|
if(state == MOUSE_EXITED) {
|
||||||
_input_devices[0].set_pointer_out_of_window();
|
_input_devices[0].set_pointer_out_of_window();
|
||||||
} else {
|
} else {
|
||||||
|
_input_devices[0].set_pointer_in_window(x, y);
|
||||||
// SetCursor(hCursor); believe this is not necessary, handled by windows
|
// SetCursor(hCursor); believe this is not necessary, handled by windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
INLINE bool mouse_passive_motion_enabled(void) { return _mouse_passive_motion_enabled; }
|
INLINE bool mouse_passive_motion_enabled(void) { return _mouse_passive_motion_enabled; }
|
||||||
void handle_window_move( int x, int y );
|
void handle_window_move( int x, int y );
|
||||||
void handle_mouse_motion( int x, int y );
|
void handle_mouse_motion( int x, int y );
|
||||||
void handle_mouse_entry( int state, HCURSOR hMouseCursor );
|
void handle_mouse_entry( int state, int x, int y);
|
||||||
void handle_keypress( ButtonHandle key, int x, int y );
|
void handle_keypress( ButtonHandle key, int x, int y );
|
||||||
void handle_keyrelease( ButtonHandle key);
|
void handle_keyrelease( ButtonHandle key);
|
||||||
void dx_setup();
|
void dx_setup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user