Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-05-25 12:48:31 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-05-25 12:48:31 +0300
commite76ff4df4123b5517599930629dbcf0507b582e9 (patch)
tree3cf9a67f3a3a05c678f39a04533da81f56e66c02 /source/blender/windowmanager
parent15dd6cb66887eb83fcc3ecf44c3b42a53161e390 (diff)
parent528f0b95c4462b2e429600a566ca0434c90310f6 (diff)
Merge branch 'master' into tmp-widget-optitmp-widget-opti
# Conflicts: # source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/CMakeLists.txt4
-rw-r--r--source/blender/windowmanager/intern/wm.c27
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c5
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c54
-rw-r--r--source/blender/windowmanager/intern/wm_files.c7
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c17
-rw-r--r--source/blender/windowmanager/intern/wm_splash_screen.c3
-rw-r--r--source/blender/windowmanager/intern/wm_window.c26
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/blender/windowmanager/wm_event_types.h1
-rw-r--r--source/blender/windowmanager/wm_window.h5
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr.c7
12 files changed, 107 insertions, 54 deletions
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 22fd55cd49a..7c749c60168 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -168,10 +168,6 @@ if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
endif()
-if(WITH_OPENSUBDIV)
- add_definitions(-DWITH_OPENSUBDIV)
-endif()
-
if(WITH_INPUT_NDOF)
add_definitions(-DWITH_INPUT_NDOF)
endif()
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 54e6735175d..9aaaa0e2c81 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -44,8 +44,10 @@
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
+#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_report.h"
+#include "BKE_screen.h"
#include "BKE_workspace.h"
#include "WM_api.h"
@@ -73,6 +75,28 @@ static void window_manager_free_data(ID *id)
wm_close_and_free(NULL, (wmWindowManager *)id);
}
+static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
+{
+ wmWindowManager *wm = (wmWindowManager *)id;
+
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ BKE_LIB_FOREACHID_PROCESS(data, win->scene, IDWALK_CB_USER_ONE);
+
+ /* This pointer can be NULL during old files reading, better be safe than sorry. */
+ if (win->workspace_hook != NULL) {
+ ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
+ BKE_LIB_FOREACHID_PROCESS_ID(data, workspace, IDWALK_CB_NOP);
+ /* allow callback to set a different workspace */
+ BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace);
+ }
+ if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
+ BKE_screen_foreach_id_screen_area(data, area);
+ }
+ }
+ }
+}
+
IDTypeInfo IDType_ID_WM = {
.id_code = ID_WM,
.id_filter = 0,
@@ -87,6 +111,7 @@ IDTypeInfo IDType_ID_WM = {
.copy_data = NULL,
.free_data = window_manager_free_data,
.make_local = NULL,
+ .foreach_id = window_manager_foreach_id,
};
#define MAX_OP_REGISTERED 32
@@ -359,7 +384,7 @@ void wm_add_default(Main *bmain, bContext *C)
WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace);
CTX_wm_manager_set(C, wm);
- win = wm_window_new(bmain, wm, NULL);
+ win = wm_window_new(bmain, wm, NULL, false);
win->scene = CTX_data_scene(C);
STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name);
BKE_workspace_active_set(win->workspace_hook, workspace);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index a01ab1377c1..4cc9f4ee7d1 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -848,6 +848,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
+ wmWindowViewport(win);
if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) {
wm_stereo3d_draw_sidebyside(win, view);
}
@@ -982,10 +983,6 @@ void wm_draw_update(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
-#ifdef WITH_OPENSUBDIV
- BKE_subsurf_free_unused_buffers();
-#endif
-
GPU_free_unused_buffers(bmain);
for (win = wm->windows.first; win; win = win->next) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 61c99d72695..c7bda0bdae0 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -563,7 +563,7 @@ void wm_event_do_notifiers(bContext *C)
static int wm_event_always_pass(const wmEvent *event)
{
/* some events we always pass on, to ensure proper communication */
- return ISTIMER(event->type) || (event->type == WINDEACTIVATE);
+ return ISTIMER(event->type) || (event->type == WINDEACTIVATE) || (event->type == EVT_FILESELECT);
}
/** \} */
@@ -640,11 +640,11 @@ static int wm_handler_ui_call(bContext *C,
return WM_HANDLER_CONTINUE;
}
-static void wm_handler_ui_cancel(bContext *C)
+void wm_event_handler_ui_cancel_ex(bContext *C,
+ wmWindow *win,
+ ARegion *region,
+ bool reactivate_button)
{
- wmWindow *win = CTX_wm_window(C);
- ARegion *region = CTX_wm_region(C);
-
if (!region) {
return;
}
@@ -656,11 +656,19 @@ static void wm_handler_ui_cancel(bContext *C)
wmEvent event;
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_CANCEL;
+ event.val = reactivate_button ? 0 : 1;
handler->handle_fn(C, &event, handler->user_data);
}
}
}
+static void wm_event_handler_ui_cancel(bContext *C)
+{
+ wmWindow *win = CTX_wm_window(C);
+ ARegion *region = CTX_wm_region(C);
+ wm_event_handler_ui_cancel_ex(C, win, region, true);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1365,7 +1373,7 @@ static int wm_operator_invoke(bContext *C,
* while dragging the view or worse, that stay there permanently
* after the modal operator has swallowed all events and passed
* none to the UI handler */
- wm_handler_ui_cancel(C);
+ wm_event_handler_ui_cancel(C);
}
else {
WM_operator_free(op);
@@ -2661,6 +2669,12 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
return action;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Handle Single Event (All Handler Types)
+ * \{ */
+
static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers)
{
const bool do_debug_handler =
@@ -2962,6 +2976,14 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
return action;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Event Queue Utilities
+ *
+ * Utilities used by #wm_event_do_handlers.
+ * \{ */
+
static bool wm_event_inside_rect(const wmEvent *event, const rcti *rect)
{
if (wm_event_always_pass(event)) {
@@ -3126,6 +3148,14 @@ static void wm_event_free_and_remove_from_queue_if_valid(wmEvent *event)
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Main Event Queue (Every Window)
+ *
+ * Handle events for all windows, run from the #WM_main event loop.
+ * \{ */
+
/* called in main loop */
/* goes over entire hierarchy: events -> window -> screen -> area -> region */
void wm_event_do_handlers(bContext *C)
@@ -3434,19 +3464,13 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
const bool is_temp_screen = WM_window_is_temp_screen(win);
- const bool opens_window = (U.filebrowser_display_type == USER_TEMP_SPACE_DISPLAY_WINDOW);
- /* Don't add the file handler to the temporary window if one is opened, or else it owns the
- * handlers for itself, causing dangling pointers once it's destructed through a handler. It has
- * a parent which should hold the handlers itself. */
- ListBase *modalhandlers = (is_temp_screen && opens_window) ? &win->parent->modalhandlers :
- &win->modalhandlers;
/* Close any popups, like when opening a file browser from the splash. */
- UI_popup_handlers_remove_all(C, modalhandlers);
+ UI_popup_handlers_remove_all(C, &win->modalhandlers);
if (!is_temp_screen) {
/* only allow 1 file selector open per window */
- LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, modalhandlers) {
+ LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler->is_fileselect == false) {
@@ -3487,7 +3511,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
handler->context.area = CTX_wm_area(C);
handler->context.region = CTX_wm_region(C);
- BLI_addhead(modalhandlers, handler);
+ BLI_addhead(&win->modalhandlers, handler);
/* check props once before invoking if check is available
* ensures initial properties are valid */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index b9f0e3686db..cc81e4f2715 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1212,6 +1212,7 @@ static ImBuf *blend_file_thumb(const bContext *C,
ImBuf *ibuf;
BlendThumbnail *thumb;
wmWindowManager *wm = CTX_wm_manager(C);
+ const float pixelsize_old = U.pixelsize;
wmWindow *windrawable_old = wm->windrawable;
char err_out[256] = "unknown";
@@ -1246,6 +1247,10 @@ static ImBuf *blend_file_thumb(const bContext *C,
/* gets scaled to BLEN_THUMB_SIZE */
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ /* Note that with scaling, this ends up being 0.5,
+ * as it's a thumbnail, we don't need object centers and friends to be 1:1 size. */
+ U.pixelsize = 1.0f;
+
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
@@ -1276,6 +1281,8 @@ static ImBuf *blend_file_thumb(const bContext *C,
err_out);
}
+ U.pixelsize = pixelsize_old;
+
/* Reset to old drawable. */
if (windrawable_old) {
wm_window_make_drawable(wm, windrawable_old);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index a93d4c7bf37..fc3f0c87b69 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -125,6 +125,8 @@
#include "GPU_material.h"
#include "BKE_sound.h"
+#include "BKE_subdiv.h"
+
#include "COM_compositor.h"
#include "DEG_depsgraph.h"
@@ -132,10 +134,6 @@
#include "DRW_engine.h"
-#ifdef WITH_OPENSUBDIV
-# include "BKE_subsurf.h"
-#endif
-
CLG_LOGREF_DECLARE_GLOBAL(WM_LOG_OPERATORS, "wm.operator");
CLG_LOGREF_DECLARE_GLOBAL(WM_LOG_HANDLERS, "wm.handler");
CLG_LOGREF_DECLARE_GLOBAL(WM_LOG_EVENTS, "wm.event");
@@ -193,9 +191,8 @@ void WM_init_opengl(Main *bmain)
GPU_pass_cache_init();
-#ifdef WITH_OPENSUBDIV
- BKE_subsurf_osd_init();
-#endif
+ BKE_subdiv_init();
+
opengl_is_init = true;
}
@@ -576,11 +573,9 @@ void WM_exit_ex(bContext *C, const bool do_python)
COM_deinitialize();
#endif
- if (opengl_is_init) {
-#ifdef WITH_OPENSUBDIV
- BKE_subsurf_osd_cleanup();
-#endif
+ BKE_subdiv_exit();
+ if (opengl_is_init) {
GPU_free_unused_buffers(G_MAIN);
}
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c
index 8445fac0498..c821f5bfe89 100644
--- a/source/blender/windowmanager/intern/wm_splash_screen.c
+++ b/source/blender/windowmanager/intern/wm_splash_screen.c
@@ -129,6 +129,7 @@ static void get_version_string(char *ver, const int max_length)
version_cycle_number);
}
+#ifndef WITH_HEADLESS
static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf)
{
uchar *rct = (uchar *)ibuf->rect;
@@ -179,6 +180,7 @@ static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf)
}
}
}
+#endif /* WITH_HEADLESS */
static ImBuf *wm_block_splash_image(int width, int *r_height)
{
@@ -219,6 +221,7 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
return ibuf;
#else
+ UNUSED_VARS(width, r_height);
return NULL;
#endif
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 70601ae5e42..fcb2be0a0bb 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -286,14 +286,15 @@ static int find_free_winid(wmWindowManager *wm)
}
/* don't change context itself */
-wmWindow *wm_window_new(const Main *bmain, wmWindowManager *wm, wmWindow *parent)
+wmWindow *wm_window_new(const Main *bmain, wmWindowManager *wm, wmWindow *parent, bool dialog)
{
wmWindow *win = MEM_callocN(sizeof(wmWindow), "window");
BLI_addtail(&wm->windows, win);
win->winid = find_free_winid(wm);
- win->parent = (parent && parent->parent) ? parent->parent : parent;
+ /* Dialogs may have a child window as parent. Otherwise, a child must not be a parent too. */
+ win->parent = (!dialog && parent && parent->parent) ? parent->parent : parent;
win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)");
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
@@ -307,8 +308,9 @@ wmWindow *wm_window_copy(Main *bmain,
const bool duplicate_layout,
const bool child)
{
+ const bool is_dialog = GHOST_IsDialogWindow(win_src->ghostwin);
wmWindow *win_parent = (child) ? win_src : win_src->parent;
- wmWindow *win_dst = wm_window_new(bmain, wm, win_parent);
+ wmWindow *win_dst = wm_window_new(bmain, wm, win_parent, is_dialog);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
WorkSpaceLayout *layout_new;
@@ -417,7 +419,6 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win)
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{
wmWindow *win_other;
- const bool is_dialog = (G.background == false) ? GHOST_IsDialogWindow(win->ghostwin) : false;
/* First check if there is another main window remaining. */
for (win_other = wm->windows.first; win_other; win_other = win_other->next) {
@@ -431,20 +432,11 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
return;
}
- /* Close child windows and bring windows back to front that dialogs have pushed behind the main
- * window. */
- LISTBASE_FOREACH (wmWindow *, iter_win, &wm->windows) {
+ /* Close child windows */
+ LISTBASE_FOREACH_MUTABLE (wmWindow *, iter_win, &wm->windows) {
if (iter_win->parent == win) {
wm_window_close(C, wm, iter_win);
}
- else {
- if (G.background == false) {
- if (is_dialog && iter_win != win && iter_win->parent &&
- (GHOST_GetWindowState(iter_win->ghostwin) != GHOST_kWindowStateMinimized)) {
- wm_window_raise(iter_win);
- }
- }
- }
}
bScreen *screen = WM_window_get_active_screen(win);
@@ -834,7 +826,7 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win_prev = CTX_wm_window(C);
- wmWindow *win = wm_window_new(CTX_data_main(C), wm, win_prev);
+ wmWindow *win = wm_window_new(CTX_data_main(C), wm, win_prev, false);
win->posx = rect->xmin;
win->posy = rect->ymin;
@@ -905,7 +897,7 @@ wmWindow *WM_window_open_temp(bContext *C,
/* add new window? */
if (win == NULL) {
- win = wm_window_new(bmain, wm, win_prev);
+ win = wm_window_new(bmain, wm, win_prev, dialog);
win->posx = rect.xmin;
win->posy = rect.ymin;
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index ffa5baae9f1..efcf40d03eb 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -149,6 +149,11 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file);
void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
void wm_event_do_notifiers(bContext *C);
+void wm_event_handler_ui_cancel_ex(bContext *C,
+ wmWindow *win,
+ ARegion *region,
+ bool reactivate_button);
+
/* wm_event_query.c */
float wm_pressure_curve(float raw_pressure);
void wm_tablet_data_from_ghost(const struct GHOST_TabletData *tablet_data, wmTabletData *wmtab);
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index f16056cc91e..ffed86abfe7 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -333,6 +333,7 @@ enum {
EVT_BUT_OPEN = 0x5021, /* 20513 */
EVT_MODAL_MAP = 0x5022, /* 20514 */
EVT_DROP = 0x5023, /* 20515 */
+ /* When value is 0, re-activate, when 1, don't re-activate the button under the cursor. */
EVT_BUT_CANCEL = 0x5024, /* 20516 */
/* could become gizmo callback */
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 45cfe1431d7..5ca5711b4f2 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -33,7 +33,10 @@ void wm_ghost_exit(void);
void wm_get_screensize(int *r_width, int *r_height);
void wm_get_desktopsize(int *r_width, int *r_height);
-wmWindow *wm_window_new(const struct Main *bmain, wmWindowManager *wm, wmWindow *parent);
+wmWindow *wm_window_new(const struct Main *bmain,
+ wmWindowManager *wm,
+ wmWindow *parent,
+ bool dialog);
wmWindow *wm_window_copy(struct Main *bmain,
wmWindowManager *wm,
wmWindow *win_src,
diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c
index 69c9034d51f..90f30809136 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr.c
@@ -126,7 +126,12 @@ void wm_xr_exit(wmWindowManager *wm)
bool wm_xr_events_handle(wmWindowManager *wm)
{
if (wm->xr.runtime && wm->xr.runtime->context) {
- return GHOST_XrEventsHandle(wm->xr.runtime->context);
+ GHOST_XrEventsHandle(wm->xr.runtime->context);
+
+ /* wm_window_process_events() uses the return value to determine if it can put the main thread
+ * to sleep for some milliseconds. We never want that to happen while the VR session runs on
+ * the main thread. So always return true. */
+ return true;
}
return false;
}