Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_window.c
| Show First 20 Lines • Show All 1,835 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Find Window Utility | /** \name Find Window Utility | ||||
| * \{ */ | * \{ */ | ||||
| static void wm_window_desktop_pos_get(const wmWindow *win, | wmWindow *WM_window_find_under_cursor(const wmWindow *win_ignore, | ||||
| const int screen_pos[2], | wmWindow *win, | ||||
| int r_desk_pos[2]) | |||||
| { | |||||
| /* To desktop space. */ | |||||
| r_desk_pos[0] = screen_pos[0] + (int)(U.pixelsize * win->posx); | |||||
| r_desk_pos[1] = screen_pos[1] + (int)(U.pixelsize * win->posy); | |||||
| } | |||||
| static void wm_window_screen_pos_get(const wmWindow *win, | |||||
| const int desktop_pos[2], | |||||
| int r_scr_pos[2]) | |||||
| { | |||||
| /* To window space. */ | |||||
| r_scr_pos[0] = desktop_pos[0] - (int)(U.pixelsize * win->posx); | |||||
| r_scr_pos[1] = desktop_pos[1] - (int)(U.pixelsize * win->posy); | |||||
| } | |||||
| wmWindow *WM_window_find_under_cursor(const wmWindowManager *wm, | |||||
| const wmWindow *win_ignore, | |||||
| const wmWindow *win, | |||||
| const int mval[2], | const int mval[2], | ||||
| int r_mval[2]) | int r_mval[2]) | ||||
| { | { | ||||
| int desk_pos[2]; | copy_v2_v2_int(r_mval, mval); | ||||
| wm_window_desktop_pos_get(win, mval, desk_pos); | wm_cursor_position_to_ghost(win, &r_mval[0], &r_mval[1]); | ||||
| /* TODO: This should follow the order of the activated windows. | GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor( | ||||
| * The current solution is imperfect but usable in most cases. */ | g_system, r_mval[0], r_mval[1], win_ignore ? win_ignore->ghostwin : NULL); | ||||
| LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) { | |||||
| if (win_iter == win_ignore) { | |||||
| continue; | |||||
| } | |||||
| if (win_iter->windowstate == GHOST_kWindowStateMinimized) { | if (!ghostwin) { | ||||
| continue; | return NULL; | ||||
| } | } | ||||
| int scr_pos[2]; | wmWindow *r_win = GHOST_GetWindowUserData(ghostwin); | ||||
| wm_window_screen_pos_get(win_iter, desk_pos, scr_pos); | wm_cursor_position_from_ghost(r_win, &r_mval[0], &r_mval[1]); | ||||
| if (scr_pos[0] >= 0 && scr_pos[1] >= 0 && scr_pos[0] <= WM_window_pixels_x(win_iter) && | |||||
| scr_pos[1] <= WM_window_pixels_y(win_iter)) { | |||||
| copy_v2_v2_int(r_mval, scr_pos); | return r_win; | ||||
| return win_iter; | |||||
| } | |||||
| } | |||||
| return NULL; | |||||
| } | } | ||||
| void WM_window_pixel_sample_read(const wmWindowManager *wm, | void WM_window_pixel_sample_read(const wmWindowManager *wm, | ||||
| const wmWindow *win, | const wmWindow *win, | ||||
| const int pos[2], | const int pos[2], | ||||
| float r_col[3]) | float r_col[3]) | ||||
| { | { | ||||
| bool setup_context = wm->windrawable != win; | bool setup_context = wm->windrawable != win; | ||||
| ▲ Show 20 Lines • Show All 483 Lines • Show Last 20 Lines | |||||