diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-06-03 21:45:43 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-06-03 21:45:57 +0300 |
commit | b94ab93dfb82275c5c6241f8de1556c4f4be934c (patch) | |
tree | aa807125aa51799606acfd79f5344a303887a432 /source/blender/editors/interface/interface_eyedropper_color.c | |
parent | a4e0bccb87bbcc6ff6f36a428aa402576de5f9ec (diff) |
Eyedropper: Support get samples from other windows
This fix T77226
Differential Revision: https://developer.blender.org/D7910
Diffstat (limited to 'source/blender/editors/interface/interface_eyedropper_color.c')
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper_color.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index ace367fd513..c917ffb3f3e 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -138,11 +138,26 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) { /* we could use some clever */ Main *bmain = CTX_data_main(C); - bScreen *screen = CTX_wm_screen(C); - ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); + wmWindowManager *wm = CTX_wm_manager(C); const char *display_device = CTX_data_scene(C)->display_settings.display_device; struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); + 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)) { + 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) { if (area->spacetype == SPACE_IMAGE) { ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); @@ -179,12 +194,15 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) } } - /* fallback to simple opengl picker */ - glReadBuffer(GL_FRONT); - glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col); - glReadBuffer(GL_BACK); - - IMB_colormanagement_display_to_scene_linear_v3(r_col, display); + if (win) { + /* Fallback to simple opengl picker. */ + int mval[2] = {mx, my}; + WM_window_pixel_sample_read(wm, win, mval, r_col); + IMB_colormanagement_display_to_scene_linear_v3(r_col, display); + } + else { + zero_v3(r_col); + } } /* sets the sample color RGB, maintaining A */ |