diff options
Diffstat (limited to 'platform/windows/os_windows.cpp')
| -rw-r--r-- | platform/windows/os_windows.cpp | 53 | 
1 files changed, 41 insertions, 12 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3e0c4a7c0c..f52c8881d4 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -455,6 +455,13 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)  		} break;  		case WM_LBUTTONDOWN:  		case WM_LBUTTONUP: +			if (input->is_emulating_mouse_from_touch()) { +				// Universal translation enabled; ignore OS translations for left button +				LPARAM extra = GetMessageExtraInfo(); +				if (IsPenEvent(extra)) { +					break; +				} +			}  		case WM_MBUTTONDOWN:  		case WM_MBUTTONUP:  		case WM_RBUTTONDOWN: @@ -467,14 +474,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)  			/*case WM_XBUTTONDOWN:  		case WM_XBUTTONUP: */ { -				if (input->is_emulating_mouse_from_touch()) { -					// Universal translation enabled; ignore OS translation -					LPARAM extra = GetMessageExtraInfo(); -					if (IsPenEvent(extra)) { -						break; -					} -				} -  				Ref<InputEventMouseButton> mb;  				mb.instance(); @@ -742,13 +741,18 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)  				if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) {  					for (UINT i = 0; i < cInputs; i++) {  						TOUCHINPUT ti = pInputs[i]; +						POINT touch_pos = { +							TOUCH_COORD_TO_PIXEL(ti.x), +							TOUCH_COORD_TO_PIXEL(ti.y), +						}; +						ScreenToClient(hWnd, &touch_pos);  						//do something with each touch input entry  						if (ti.dwFlags & TOUCHEVENTF_MOVE) { -							_drag_event(ti.x / 100.0f, ti.y / 100.0f, ti.dwID); +							_drag_event(touch_pos.x, touch_pos.y, ti.dwID);  						} else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) { -							_touch_event(ti.dwFlags & TOUCHEVENTF_DOWN, ti.x / 100.0f, ti.y / 100.0f, ti.dwID); +							_touch_event(ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);  						};  					}  					bHandled = TRUE; @@ -1181,6 +1185,15 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int  	if (p_desired.layered_splash) {  		set_window_per_pixel_transparency_enabled(true);  	} + +	// IME +	im_himc = ImmGetContext(hWnd); +	ImmReleaseContext(hWnd, im_himc); + +	im_position = Vector2(); + +	set_ime_active(false); +  	return OK;  } @@ -2659,13 +2672,29 @@ String OS_Windows::get_unique_id() const {  	return String(HwProfInfo.szHwProfileGuid);  } +void OS_Windows::set_ime_active(const bool p_active) { + +	if (p_active) { +		ImmAssociateContext(hWnd, im_himc); + +		set_ime_position(im_position); +	} else { +		ImmAssociateContext(hWnd, (HIMC)0); +	} +} +  void OS_Windows::set_ime_position(const Point2 &p_pos) { +	im_position = p_pos; +  	HIMC himc = ImmGetContext(hWnd); +	if (himc == (HIMC)0) +		return; +  	COMPOSITIONFORM cps;  	cps.dwStyle = CFS_FORCE_POSITION; -	cps.ptCurrentPos.x = p_pos.x; -	cps.ptCurrentPos.y = p_pos.y; +	cps.ptCurrentPos.x = im_position.x; +	cps.ptCurrentPos.y = im_position.y;  	ImmSetCompositionWindow(himc, &cps);  	ImmReleaseContext(hWnd, himc);  }  |