forked from blender/blender
main sync #3
@ -943,6 +943,11 @@ extern void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn);
|
||||
*/
|
||||
extern void GHOST_UseWindowFocus(bool use_focus);
|
||||
|
||||
/**
|
||||
* Focus and raise windows on mouse hover.
|
||||
*/
|
||||
extern void GHOST_SetAutoFocus(bool auto_focus);
|
||||
|
||||
/**
|
||||
* If window was opened using native pixel size, it returns scaling factor.
|
||||
*/
|
||||
|
@ -332,6 +332,11 @@ class GHOST_ISystem {
|
||||
*/
|
||||
virtual void useWindowFocus(const bool use_focus) = 0;
|
||||
|
||||
/**
|
||||
* Focus and raise windows on mouse hover.
|
||||
*/
|
||||
virtual void setAutoFocus(const bool auto_focus) = 0;
|
||||
|
||||
/**
|
||||
* Get the Window under the cursor.
|
||||
* \param x: The x-coordinate of the cursor.
|
||||
|
@ -918,6 +918,12 @@ void GHOST_UseWindowFocus(bool use_focus)
|
||||
return system->useWindowFocus(use_focus);
|
||||
}
|
||||
|
||||
void GHOST_SetAutoFocus(bool auto_focus)
|
||||
{
|
||||
GHOST_ISystem *system = GHOST_ISystem::getSystem();
|
||||
system->setAutoFocus(auto_focus);
|
||||
}
|
||||
|
||||
float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
|
||||
{
|
||||
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
|
||||
|
@ -23,6 +23,7 @@
|
||||
GHOST_System::GHOST_System()
|
||||
: m_nativePixel(false),
|
||||
m_windowFocus(true),
|
||||
m_autoFocus(true),
|
||||
m_displayManager(nullptr),
|
||||
m_timerManager(nullptr),
|
||||
m_windowManager(nullptr),
|
||||
@ -412,6 +413,11 @@ void GHOST_System::useWindowFocus(const bool use_focus)
|
||||
m_windowFocus = use_focus;
|
||||
}
|
||||
|
||||
void GHOST_System::setAutoFocus(const bool auto_focus)
|
||||
{
|
||||
m_autoFocus = auto_focus;
|
||||
}
|
||||
|
||||
bool GHOST_System::supportsCursorWarp()
|
||||
{
|
||||
return true;
|
||||
|
@ -160,6 +160,12 @@ class GHOST_System : public GHOST_ISystem {
|
||||
|
||||
bool m_windowFocus;
|
||||
|
||||
/**
|
||||
* Focus and raise windows on mouse hover.
|
||||
*/
|
||||
void setAutoFocus(const bool auto_focus);
|
||||
bool m_autoFocus;
|
||||
|
||||
/**
|
||||
* Get the Window under the cursor.
|
||||
* \param x: The x-coordinate of the cursor.
|
||||
|
@ -1828,10 +1828,13 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam,
|
||||
if (!window->m_mousePresent) {
|
||||
WINTAB_PRINTF("HWND %p mouse enter\n", window->getHWND());
|
||||
TRACKMOUSEEVENT tme = {sizeof(tme)};
|
||||
/* Request WM_MOUSELEAVE message when the cursor leaves the client area, and
|
||||
* WM_MOUSEHOVER message after 50ms when in the client area. */
|
||||
tme.dwFlags = TME_LEAVE | TME_HOVER;
|
||||
tme.dwHoverTime = 50;
|
||||
/* Request WM_MOUSELEAVE message when the cursor leaves the client area. */
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
if (system->m_autoFocus) {
|
||||
/* Request WM_MOUSEHOVER message after 100ms when in the client area. */
|
||||
tme.dwFlags |= TME_HOVER;
|
||||
tme.dwHoverTime = 100;
|
||||
}
|
||||
tme.hwndTrack = hwnd;
|
||||
TrackMouseEvent(&tme);
|
||||
window->m_mousePresent = true;
|
||||
|
@ -20,6 +20,7 @@ set(INC
|
||||
../../python
|
||||
../../render
|
||||
../../windowmanager
|
||||
../../../../intern/ghost
|
||||
../../../../intern/guardedalloc
|
||||
../../bmesh
|
||||
# RNA_prototypes.h
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "BKE_tracking.h"
|
||||
#include "BKE_unit.h"
|
||||
|
||||
#include "GHOST_C-api.h"
|
||||
|
||||
#include "IMB_colormanagement.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
@ -3459,6 +3461,9 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
|
||||
WM_cursor_modal_set(win, WM_CURSOR_TEXT_EDIT);
|
||||
|
||||
/* Temporarily turn off window auto-focus on platforms that support it. */
|
||||
GHOST_SetAutoFocus(false);
|
||||
|
||||
#ifdef WITH_INPUT_IME
|
||||
if (!is_num_but) {
|
||||
ui_textedit_ime_begin(win, but);
|
||||
@ -3514,6 +3519,9 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
|
||||
WM_cursor_modal_restore(win);
|
||||
|
||||
/* Turn back on the auto-focusing of windows. */
|
||||
GHOST_SetAutoFocus(true);
|
||||
|
||||
/* Free text undo history text blocks. */
|
||||
ui_textedit_undo_stack_destroy(data->undo_stack_text);
|
||||
data->undo_stack_text = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user