diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-10 14:17:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-10 14:17:59 +0400 |
commit | ac9ec06ec121589fedbfeaa10137140b45bfd668 (patch) | |
tree | ab08f9528136f0b8813593b78621f869d98d655e /source/blender/windowmanager | |
parent | 3c064f4553e4be988fe4fcec450b59b935fa3c80 (diff) | |
parent | 63af7068ad17f30a526ccb81fbe74253b064bc89 (diff) |
Merged changes in the trunk up to revision 54421.
Conflicts resolved:
release/datafiles/startup.blend
release/scripts/startup/bl_ui/properties_render.py
source/blender/SConscript
source/blender/blenloader/intern/readfile.c
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 61 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 37 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 7 |
6 files changed, 99 insertions, 31 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index bea54154e47..e91d4f388af 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -148,11 +148,11 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap); struct wmEventHandler *WM_event_add_ui_handler( const struct bContext *C, ListBase *handlers, - int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), + int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata), void (*remove)(struct bContext *C, void *userdata), void *userdata); void WM_event_remove_ui_handler(ListBase *handlers, - int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), + int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata), void (*remove)(struct bContext *C, void *userdata), void *userdata, int postpone); void WM_event_remove_area_handler(struct ListBase *handlers, void *area); @@ -311,6 +311,8 @@ void WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval void WM_event_print(struct wmEvent *event); #endif +void WM_operator_region_active_win_set(struct bContext *C); + /* drag and drop */ struct wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value); void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale, int sx, int sy); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 942cce1b6dd..881d4464ed6 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -188,7 +188,7 @@ enum { #define WM_UI_HANDLER_CONTINUE 0 #define WM_UI_HANDLER_BREAK 1 -typedef int (*wmUIHandlerFunc)(struct bContext *C, struct wmEvent *event, void *userdata); +typedef int (*wmUIHandlerFunc)(struct bContext *C, const struct wmEvent *event, void *userdata); typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata); /* ************** Notifiers ****************** */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 84fee9ff34c..9e3722777ba 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -282,7 +282,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX context in notifiers? */ CTX_wm_window_set(C, win); - /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name+2, note->category); */ + /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name + 2, note->category); */ ED_screen_do_listen(C, note); for (ar = win->screen->regionbase.first; ar; ar = ar->next) { @@ -453,6 +453,22 @@ static void wm_operator_print(bContext *C, wmOperator *op) MEM_freeN(buf); } +/** + * Sets the active region for this space from the context. + * + * \see #BKE_area_find_region_active_win + */ +void WM_operator_region_active_win_set(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa) { + ARegion *ar = CTX_wm_region(C); + if (ar && ar->regiontype == RGN_TYPE_WINDOW) { + sa->region_active_win = BLI_findindex(&sa->regionbase, ar); + } + } +} + /* for debugging only, getting inspecting events manually is tedious */ #ifndef NDEBUG @@ -573,10 +589,13 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) MEM_freeN(buf); } - if (wm_operator_register_check(wm, op->type)) + if (wm_operator_register_check(wm, op->type)) { wm_operator_register(C, op); - else + WM_operator_region_active_win_set(C); + } + else { WM_operator_free(op); + } } } @@ -1045,7 +1064,14 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA } if (!(ar && ar->regiontype == type) && area) { - ARegion *ar1 = BKE_area_find_region_type(area, type); + ARegion *ar1; + if (type == RGN_TYPE_WINDOW) { + ar1 = BKE_area_find_region_active_win(area); + } + else { + ar1 = BKE_area_find_region_type(area, type); + } + if (ar1) CTX_wm_region_set(C, ar1); } @@ -1357,8 +1383,8 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve } else { /* modal keymap checking returns handled events fine, but all hardcoded modal - handling typically swallows all events (OPERATOR_RUNNING_MODAL). - This bypass just disables support for double clicks in hardcoded modal handlers */ + * handling typically swallows all events (OPERATOR_RUNNING_MODAL). + * This bypass just disables support for double clicks in hardcoded modal handlers */ if (event->val == KM_DBL_CLICK) { event->prevval = event->val; event->val = KM_PRESS; @@ -1417,20 +1443,10 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand if (ot->flag & OPTYPE_UNDO) wm->op_undo_depth--; - /* putting back screen context, reval can pass trough after modal failures! */ - if ((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) { - CTX_wm_area_set(C, area); - CTX_wm_region_set(C, region); - } - else { - /* this special cases is for areas and regions that get removed */ - CTX_wm_area_set(C, NULL); - CTX_wm_region_set(C, NULL); - } - if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) wm_operator_reports(C, op, retval, FALSE); + /* important to run 'wm_operator_finished' before NULLing the context members */ if (retval & OPERATOR_FINISHED) { wm_operator_finished(C, op, 0); handler->op = NULL; @@ -1440,6 +1456,17 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand handler->op = NULL; } + /* putting back screen context, reval can pass trough after modal failures! */ + if ((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) { + CTX_wm_area_set(C, area); + CTX_wm_region_set(C, region); + } + else { + /* this special cases is for areas and regions that get removed */ + CTX_wm_area_set(C, NULL); + CTX_wm_region_set(C, NULL); + } + /* remove modal handler, operator itself should have been canceled and freed */ if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { WM_cursor_grab_disable(CTX_wm_window(C), NULL); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 2d4e4a5334a..d1156f77e41 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -527,14 +527,15 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory /* put aside screens to match with persistent windows later */ wm_window_match_init(C, &wmbase); - if (!from_memory && BLI_exists(startstr)) { - success = (BKE_read_file(C, startstr, NULL) != BKE_READ_FILE_FAIL); - - } - - if (U.themes.first == NULL) { - printf("\nNote: No (valid) "STRINGIFY (BLENDER_STARTUP_FILE)" found, fall back to built-in default.\n\n"); - success = 0; + if (!from_memory) { + if (BLI_exists(startstr)) { + success = (BKE_read_file(C, startstr, NULL) != BKE_READ_FILE_FAIL); + } + + if (U.themes.first == NULL) { + printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", startstr); + success = 0; + } } if (success == 0) { diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 44c5693c3e3..d8b987a196c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -43,6 +43,7 @@ #include "GHOST_C-api.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -114,6 +115,17 @@ void wm_get_screensize(int *width_r, int *height_r) *height_r = uiheight; } +/* size of all screens, useful since the mouse is bound by this */ +void wm_get_screensize_all(int *width_r, int *height_r) +{ + unsigned int uiwidth; + unsigned int uiheight; + + GHOST_GetAllDisplayDimensions(g_system, &uiwidth, &uiheight); + *width_r = uiwidth; + *height_r = uiheight; +} + /* keeps offset and size within monitor bounds */ /* XXX solve dual screen... */ static void wm_window_check_position(rcti *rect) @@ -425,10 +437,19 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y); } #else + /* note!, this isnt quite correct, active screen maybe offset 1000s if PX, + * we'd need a wm_get_screensize like function that gives offset, + * in practice the window manager will likely move to the correct monitor */ wm_init_state.start_x = 0; wm_init_state.start_y = 0; - #endif + +#if !defined(__APPLE__) && !defined(WIN32) /* X11 */ + /* X11, start maximized but use default same size */ + wm_init_state.size_x = min_ii(wm_init_state.size_x, WM_WIN_INIT_SIZE_X); + wm_init_state.size_y = min_ii(wm_init_state.size_y, WM_WIN_INIT_SIZE_Y); +#endif + } for (win = wm->windows.first; win; win = win->next) { @@ -439,8 +460,18 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) win->sizex = wm_init_state.size_x; win->sizey = wm_init_state.size_y; - /* we can't properly resize a maximized window */ +#if !defined(__APPLE__) && !defined(WIN32) /* X11 */ + if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) { + /* we can't properly resize a maximized window */ + win->windowstate = GHOST_kWindowStateNormal; + } + else { + /* loading without userpref, default to maximized */ + win->windowstate = GHOST_kWindowStateMaximized; + } +#else win->windowstate = GHOST_kWindowStateNormal; +#endif wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM; } @@ -820,7 +851,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr GHOST_DisposeRectangle(client_rect); - wm_get_screensize(&scr_w, &scr_h); + wm_get_screensize_all(&scr_w, &scr_h); sizex = r - l; sizey = b - t; posx = l; diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index ce360f5ef56..c4c64ed429f 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -40,6 +40,7 @@ void wm_ghost_init (bContext *C); void wm_ghost_exit(void); void wm_get_screensize(int *width_r, int *height_r); +void wm_get_screensize_all(int *width_r, int *height_r); wmWindow *wm_window_new (bContext *C); void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win); @@ -68,5 +69,11 @@ void wm_window_testbreak (void); int wm_window_duplicate_exec(bContext *C, struct wmOperator *op); int wm_window_fullscreen_toggle_exec(bContext *C, struct wmOperator *op); +/* Initial (unmaximized) size to start with for + * systems that can't find it for themselves (X11). + * Clamped by real desktop limits */ +#define WM_WIN_INIT_SIZE_X 1800 +#define WM_WIN_INIT_SIZE_Y 1000 + #endif /* __WM_WINDOW_H__ */ |