main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
8 changed files with 44 additions and 4 deletions
Showing only changes of commit 56d2298271 - Show all commits

View File

@ -943,6 +943,11 @@ extern void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn);
*/ */
extern void GHOST_UseWindowFocus(bool use_focus); 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. * If window was opened using native pixel size, it returns scaling factor.
*/ */

View File

@ -332,6 +332,11 @@ class GHOST_ISystem {
*/ */
virtual void useWindowFocus(const bool use_focus) = 0; 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. * Get the Window under the cursor.
* \param x: The x-coordinate of the cursor. * \param x: The x-coordinate of the cursor.

View File

@ -918,6 +918,12 @@ void GHOST_UseWindowFocus(bool use_focus)
return system->useWindowFocus(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) float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
{ {
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle; GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;

View File

@ -23,6 +23,7 @@
GHOST_System::GHOST_System() GHOST_System::GHOST_System()
: m_nativePixel(false), : m_nativePixel(false),
m_windowFocus(true), m_windowFocus(true),
m_autoFocus(true),
m_displayManager(nullptr), m_displayManager(nullptr),
m_timerManager(nullptr), m_timerManager(nullptr),
m_windowManager(nullptr), m_windowManager(nullptr),
@ -412,6 +413,11 @@ void GHOST_System::useWindowFocus(const bool use_focus)
m_windowFocus = use_focus; m_windowFocus = use_focus;
} }
void GHOST_System::setAutoFocus(const bool auto_focus)
{
m_autoFocus = auto_focus;
}
bool GHOST_System::supportsCursorWarp() bool GHOST_System::supportsCursorWarp()
{ {
return true; return true;

View File

@ -160,6 +160,12 @@ class GHOST_System : public GHOST_ISystem {
bool m_windowFocus; 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. * Get the Window under the cursor.
* \param x: The x-coordinate of the cursor. * \param x: The x-coordinate of the cursor.

View File

@ -1828,10 +1828,13 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam,
if (!window->m_mousePresent) { if (!window->m_mousePresent) {
WINTAB_PRINTF("HWND %p mouse enter\n", window->getHWND()); WINTAB_PRINTF("HWND %p mouse enter\n", window->getHWND());
TRACKMOUSEEVENT tme = {sizeof(tme)}; TRACKMOUSEEVENT tme = {sizeof(tme)};
/* Request WM_MOUSELEAVE message when the cursor leaves the client area, and /* Request WM_MOUSELEAVE message when the cursor leaves the client area. */
* WM_MOUSEHOVER message after 50ms when in the client area. */ tme.dwFlags = TME_LEAVE;
tme.dwFlags = TME_LEAVE | TME_HOVER; if (system->m_autoFocus) {
tme.dwHoverTime = 50; /* Request WM_MOUSEHOVER message after 100ms when in the client area. */
tme.dwFlags |= TME_HOVER;
tme.dwHoverTime = 100;
}
tme.hwndTrack = hwnd; tme.hwndTrack = hwnd;
TrackMouseEvent(&tme); TrackMouseEvent(&tme);
window->m_mousePresent = true; window->m_mousePresent = true;

View File

@ -20,6 +20,7 @@ set(INC
../../python ../../python
../../render ../../render
../../windowmanager ../../windowmanager
../../../../intern/ghost
../../../../intern/guardedalloc ../../../../intern/guardedalloc
../../bmesh ../../bmesh
# RNA_prototypes.h # RNA_prototypes.h

View File

@ -47,6 +47,8 @@
#include "BKE_tracking.h" #include "BKE_tracking.h"
#include "BKE_unit.h" #include "BKE_unit.h"
#include "GHOST_C-api.h"
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "ED_screen.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); 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 #ifdef WITH_INPUT_IME
if (!is_num_but) { if (!is_num_but) {
ui_textedit_ime_begin(win, 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); WM_cursor_modal_restore(win);
/* Turn back on the auto-focusing of windows. */
GHOST_SetAutoFocus(true);
/* Free text undo history text blocks. */ /* Free text undo history text blocks. */
ui_textedit_undo_stack_destroy(data->undo_stack_text); ui_textedit_undo_stack_destroy(data->undo_stack_text);
data->undo_stack_text = nullptr; data->undo_stack_text = nullptr;