Cleanup: return window in 'WM_window_find_under_cursor'

This better matches other functions like `BKE_screen_find_area_xy`.
This commit is contained in:
Germano Cavalcante 2021-08-26 13:26:31 -03:00 committed by Germano Cavalcante
parent 06a60fe9f7
commit d7b0567f7c
3 changed files with 16 additions and 22 deletions

View File

@ -342,15 +342,13 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
if (area == NULL) {
int mval[2] = {mx, my};
if (WM_window_find_under_cursor(wm, NULL, win, mval, &win, mval)) {
win = WM_window_find_under_cursor(wm, NULL, win, mval, mval);
if (win) {
mx = mval[0];
my = mval[1];
screen = WM_window_get_active_screen(win);
area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
}
else {
win = NULL;
}
}
if (area) {

View File

@ -111,12 +111,11 @@ void WM_reinit_gizmomap_all(struct Main *bmain);
void WM_script_tag_reload(void);
bool WM_window_find_under_cursor(const wmWindowManager *wm,
const wmWindow *win_ignore,
const wmWindow *win,
const int mval[2],
wmWindow **r_win,
int r_mval[2]);
wmWindow *WM_window_find_under_cursor(const wmWindowManager *wm,
const wmWindow *win_ignore,
const wmWindow *win,
const int mval[2],
int r_mval[2]);
void WM_window_pixel_sample_read(const wmWindowManager *wm,
const wmWindow *win,
const int pos[2],
@ -263,9 +262,8 @@ struct wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *han
wmKeyMap *keymap,
int priority);
typedef struct wmKeyMap *(wmEventHandler_KeymapDynamicFn)(wmWindowManager *wm,
struct wmEventHandler_Keymap *handler)
ATTR_WARN_UNUSED_RESULT;
typedef struct wmKeyMap *(wmEventHandler_KeymapDynamicFn)(
wmWindowManager *wm, struct wmEventHandler_Keymap *handler)ATTR_WARN_UNUSED_RESULT;
struct wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(
struct wmWindowManager *wm, struct wmEventHandler_Keymap *handler);

View File

@ -1922,12 +1922,11 @@ static void wm_window_screen_pos_get(const wmWindow *win,
r_scr_pos[1] = desktop_pos[1] - (int)(U.pixelsize * win->posy);
}
bool WM_window_find_under_cursor(const wmWindowManager *wm,
const wmWindow *win_ignore,
const wmWindow *win,
const int mval[2],
wmWindow **r_win,
int r_mval[2])
wmWindow *WM_window_find_under_cursor(const wmWindowManager *wm,
const wmWindow *win_ignore,
const wmWindow *win,
const int mval[2],
int r_mval[2])
{
int desk_pos[2];
wm_window_desktop_pos_get(win, mval, desk_pos);
@ -1949,13 +1948,12 @@ bool WM_window_find_under_cursor(const wmWindowManager *wm,
if (scr_pos[0] >= 0 && win_iter->posy >= 0 && scr_pos[0] <= WM_window_pixels_x(win_iter) &&
scr_pos[1] <= WM_window_pixels_y(win_iter)) {
*r_win = win_iter;
copy_v2_v2_int(r_mval, scr_pos);
return true;
return win_iter;
}
}
return false;
return NULL;
}
void WM_window_pixel_sample_read(const wmWindowManager *wm,