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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-10-29 05:09:12 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-10-29 05:09:12 +0400
commit15ed8343437c6b304de72cd14591455da1d5b3ec (patch)
treecbe40f76668f5e8539744c4d2f8aeaa0ded72f52 /source/blender/windowmanager
parent5acd5d14970c829c2873623716a67beeb6da5278 (diff)
parentdd106b5c7a129e00bebe121c4da8cb90a16d48cb (diff)
Merged changes in the trunk up to revision 51718.
Conflicts resolved: source/blender/blenloader/intern/readfile.c source/blender/makesrna/intern/rna_scene.c release/datafiles/startup.blend
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h5
-rw-r--r--source/blender/windowmanager/intern/wm.c2
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c10
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c227
-rw-r--r--source/blender/windowmanager/intern/wm_files.c2
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c1
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c48
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c4
-rw-r--r--source/blender/windowmanager/intern/wm_window.c12
-rw-r--r--source/blender/windowmanager/wm_event_system.h70
12 files changed, 224 insertions, 161 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 99d1c14059a..d1c08f43d07 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -425,7 +425,7 @@ typedef struct wmEvent {
char ascii; /* from ghost, fallback if utf8 isn't set */
char pad;
- /* previous state */
+ /* previous state, used for double click and the 'click' */
short prevtype;
short prevval;
int prevx, prevy;
@@ -436,7 +436,8 @@ typedef struct wmEvent {
short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
short keymodifier; /* rawkey modifier */
- short pad1;
+ /* set in case a KM_PRESS went by unhandled */
+ short check_click;
/* keymap item, set by handler (weak?) */
const char *keymap_idname;
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index a34d294461c..8fe387765ce 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -78,7 +78,7 @@ void WM_operator_free(wmOperator *op)
if (op->py_instance) {
/* do this first in case there are any __del__ functions or
* similar that use properties */
- BPY_DECREF(op->py_instance);
+ BPY_DECREF_RNA_INVALIDATE(op->py_instance);
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 7853b40c98a..ebde6407a48 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -61,7 +61,7 @@ static GHOST_TStandardCursor convert_cursor(int curs)
case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow;
case CURSOR_WAIT: return GHOST_kStandardCursorWait;
case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair;
- case CURSOR_HELP:
+ case CURSOR_HELP:
#ifdef __APPLE__
return GHOST_kStandardCursorLeftRight;
#else
@@ -317,7 +317,7 @@ void WM_cursor_time(wmWindow *win, int nr)
/* Because defining a cursor mixes declarations and executable code
* each cursor needs it's own scoping block or it would be split up
* over several hundred lines of code. To enforce/document this better
- * I define 2 pretty braindead macros so it's obvious what the extra "[]"
+ * I define 2 pretty brain-dead macros so it's obvious what the extra "[]"
* are for */
#define BEGIN_CURSOR_BLOCK {
@@ -560,7 +560,7 @@ BEGIN_CURSOR_BLOCK
BlenderCursor[BC_CROSSCURSOR] = &CrossCursor;
END_CURSOR_BLOCK
- /********************** EditCross Cursor ***********************/
+ /********************** EditCross Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char editcross_sbm[] = {
0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03,
@@ -775,7 +775,7 @@ BEGIN_CURSOR_BLOCK
END_CURSOR_BLOCK
- /********************** TextEdit Cursor ***********************/
+ /********************** TextEdit Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char textedit_sbm[] = {
0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01,
@@ -808,7 +808,7 @@ BEGIN_CURSOR_BLOCK
END_CURSOR_BLOCK
- /********************** Paintbrush Cursor ***********************/
+ /********************** Paintbrush Cursor ***********************/
BEGIN_CURSOR_BLOCK
static char paintbrush_sbm[] = {
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index bbb2a54887e..0581000e07c 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -141,7 +141,7 @@ void wm_dropbox_free(void)
BLI_freelistN(&dm->dropboxes);
}
- BLI_freelistN(&dropboxes);
+ BLI_freelistN(&dropboxes);
}
/* *********************************** */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 73950bdfa19..9e072c4b03a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -339,6 +339,11 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
int retval;
+ /* UI code doesn't handle return values - it just always returns break.
+ to make the DBL_CLICK conversion work, we just don't send this to UI */
+ if (event->val == KM_DBL_CLICK)
+ return WM_HANDLER_CONTINUE;
+
/* UI is quite aggressive with swallowing events, like scrollwheel */
/* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
if (do_wheel_ui == FALSE) {
@@ -848,7 +853,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event,
WM_operator_last_properties_init(op);
}
- if ((G.debug & G_DEBUG_EVENTS) && event && event->type != MOUSEMOVE) {
+ if ((G.debug & G_DEBUG_HANDLERS) && event && event->type != MOUSEMOVE) {
printf("%s: handle evt %d win %d op %s\n",
__func__, event ? event->type : 0, CTX_wm_screen(C)->subwinactive, ot->idname);
}
@@ -1370,13 +1375,30 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (wm_eventmatch(event, kmi)) {
+ event->prevtype = event->type;
+ event->prevval = event->val;
event->type = EVT_MODAL_MAP;
event->val = kmi->propvalue;
+
+ break;
}
}
}
}
+/* bad hacking event system... better restore event type for checking of KM_CLICK for example */
+/* XXX modal maps could use different method (ton) */
+static void wm_event_modalmap_end(wmEvent *event)
+{
+ if (event->type == EVT_MODAL_MAP) {
+ event->type = event->prevtype;
+ event->prevtype = 0;
+ event->val = event->prevval;
+ event->prevval = 0;
+ }
+
+}
+
/* Warning: this function removes a modal handler, when finished */
static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler,
wmEvent *event, PointerRNA *properties)
@@ -1403,7 +1425,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
retval = ot->modal(C, op, event);
OPERATOR_RETVAL_CHECK(retval);
-
+ wm_event_modalmap_end(event);
+
/* when this is _not_ the case the modal modifier may have loaded
* a new blend file (demo mode does this), so we have to assume
* the event, operator etc have all been freed. - campbell */
@@ -1672,10 +1695,13 @@ static int wm_action_not_handled(int action)
return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
}
-static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers)
{
#ifndef NDEBUG
- const int do_debug_handler = (G.debug & G_DEBUG_EVENTS);
+ const int do_debug_handler = (G.debug & G_DEBUG_HANDLERS)
+ /* comment this out to flood the console! (if you really want to test) */
+ && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)
+ ;
#endif
wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler, *nexthandler;
@@ -1844,49 +1870,58 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
}
}
- /* test for CLICK event */
- if (wm_action_not_handled(action) && event->val == KM_RELEASE) {
- wmWindow *win = CTX_wm_window(C);
+ if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
+ wm_cursor_arrow_move(CTX_wm_window(C), event);
- if (win && win->eventstate->prevtype == event->type && win->eventstate->prevval == KM_PRESS) {
- /* test for double click first,
- * note1: this can be problematic because single click operators can get the
- * double click event but then with old mouse coords which is highly confusing,
- * so check for mouse moves too.
- * note2: the first click event will be handled but still used to create a
- * double click event if clicking again quickly.
- * If no double click events are found it will fallback to a single click.
- * So a double click event can result in 2 successive single click calls
- * if its not handled by the keymap - campbell */
- if ((ABS(event->x - win->eventstate->prevclickx)) <= 2 &&
- (ABS(event->y - win->eventstate->prevclicky)) <= 2 &&
- ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time))
- {
- event->val = KM_DBL_CLICK;
- /* removed this because in cases where we're this is used as a single click
- * event, this will give old coords,
- * since the distance is checked above, using new coords should be ok. */
- // event->x = win->eventstate->prevclickx;
- // event->y = win->eventstate->prevclicky;
- action |= wm_handlers_do(C, event, handlers);
- }
+ return action;
+}
- if (wm_action_not_handled(action)) {
- event->val = KM_CLICK;
- action |= wm_handlers_do(C, event, handlers);
+/* this calls handlers twice - to solve (double-)click events */
+static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+{
+ int action = wm_handlers_do_intern(C, event, handlers);
+
+ if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) {
+
+ /* test for CLICK events */
+ if (wm_action_not_handled(action)) {
+ wmWindow *win = CTX_wm_window(C);
+
+ /* eventstate stores if previous event was a KM_PRESS, in case that
+ wasn't handled, the KM_RELEASE will become a KM_CLICK */
+
+ if (win && event->val == KM_PRESS) {
+ win->eventstate->check_click = TRUE;
}
+
+ if (win && win->eventstate->prevtype == event->type) {
+
+ if (event->val == KM_RELEASE && win->eventstate->prevval == KM_PRESS && win->eventstate->check_click == TRUE) {
+ event->val = KM_CLICK;
+ // printf("add KM_CLICK\n");
+ action |= wm_handlers_do_intern(C, event, handlers);
-
- /* revert value if not handled */
- if (wm_action_not_handled(action)) {
- event->val = KM_RELEASE;
+ event->val = KM_RELEASE;
+ }
+ else if (event->val == KM_DBL_CLICK) {
+ event->val = KM_PRESS;
+ action |= wm_handlers_do_intern(C, event, handlers);
+
+ /* revert value if not handled */
+ if (wm_action_not_handled(action)) {
+ event->val = KM_DBL_CLICK;
+ }
+ }
}
}
+ else {
+ wmWindow *win = CTX_wm_window(C);
+
+ if(win)
+ win->eventstate->check_click = 0;
+ }
}
- if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
- wm_cursor_arrow_move(CTX_wm_window(C), event);
-
return action;
}
@@ -2064,7 +2099,7 @@ void wm_event_do_handlers(bContext *C)
while ( (event = win->queue.first) ) {
int action = WM_HANDLER_CONTINUE;
- if ((G.debug & G_DEBUG_EVENTS) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ if ((G.debug & G_DEBUG_HANDLERS) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
printf("%s: pass on evt %d val %d\n", __func__, event->type, event->val);
}
@@ -2180,40 +2215,6 @@ void wm_event_do_handlers(bContext *C)
}
}
- /* store last event for this window */
- /* mousemove and timer events don't overwrite last type */
- if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) {
- if (wm_action_not_handled(action)) {
- if (win->eventstate->prevtype == event->type) {
- /* set click time on first click (press -> release) */
- if (win->eventstate->prevval == KM_PRESS && event->val == KM_RELEASE) {
- win->eventstate->prevclicktime = PIL_check_seconds_timer();
- win->eventstate->prevclickx = event->x;
- win->eventstate->prevclicky = event->y;
- }
- }
- else {
- /* reset click time if event type not the same */
- win->eventstate->prevclicktime = 0;
- }
-
- win->eventstate->prevval = event->val;
- win->eventstate->prevtype = event->type;
- }
- else if (event->val == KM_CLICK) { /* keep click for double click later */
- win->eventstate->prevtype = event->type;
- win->eventstate->prevval = event->val;
- win->eventstate->prevclicktime = PIL_check_seconds_timer();
- win->eventstate->prevclickx = event->x;
- win->eventstate->prevclicky = event->y;
- }
- else { /* reset if not */
- win->eventstate->prevtype = -1;
- win->eventstate->prevval = 0;
- win->eventstate->prevclicktime = 0;
- }
- }
-
/* unlink and free here, blender-quit then frees all */
BLI_remlink(&win->queue, event);
wm_event_free(event);
@@ -2622,7 +2623,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
event->custom = EVT_DATA_TABLET;
event->customdata = wmtab;
event->customdatafree = 1;
- }
+ }
}
/* adds customdata to event */
@@ -2801,7 +2802,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
case GHOST_kEventButtonUp:
{
GHOST_TEventButtonData *bd = customdata;
+
+ /* copy prev state to event state */
+ evt->prevval = evt->val;
+ evt->prevtype = evt->type;
+ /* get value and type from ghost */
event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
if (bd->button == GHOST_kButtonMaskLeft)
@@ -2815,6 +2821,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
else
event.type = MIDDLEMOUSE;
+ /* copy to event state */
+ evt->val = event.val;
+ evt->type = event.type;
+
if (win->active == 0) {
int cx, cy;
@@ -2825,6 +2835,21 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
event.y = evt->y = cy;
}
+ /* double click test */
+ if (event.type == evt->prevtype && event.val == KM_PRESS) {
+ if ((ABS(event.x - evt->prevclickx)) <= 2 &&
+ (ABS(event.y - evt->prevclicky)) <= 2 &&
+ ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
+ {
+ event.val = KM_DBL_CLICK;
+ }
+ }
+ if (event.val == KM_RELEASE) {
+ evt->prevclicktime = PIL_check_seconds_timer();
+ evt->prevclickx = event.x;
+ evt->prevclicky = event.y;
+ }
+
/* add to other window if event is there (not to both!) */
owin = wm_event_cursor_other_windows(wm, win, &event);
if (owin) {
@@ -2855,6 +2880,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
+ /* copy prev state to event state */
+ evt->prevval = evt->val;
+ evt->prevtype = evt->type;
+
+ /* copy to event state */
+ evt->val = event.val;
+ evt->type = event.type;
+
/* exclude arrow keys, esc, etc from text input */
if (type == GHOST_kEventKeyUp) {
event.ascii = '\0';
@@ -2880,28 +2913,28 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
}
}
- /* modifiers */
+ /* modifiers assign to eventstate, so next event gets the modifer (makes modifier key events work) */
/* assigning both first and second is strange - campbell */
switch (event.type) {
case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
- event.shift = evt->shift = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->shift = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case LEFTCTRLKEY: case RIGHTCTRLKEY:
- event.ctrl = evt->ctrl = (event.val == KM_PRESS) ?
- ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->ctrl = (event.val == KM_PRESS) ?
+ ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case LEFTALTKEY: case RIGHTALTKEY:
- event.alt = evt->alt = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->alt = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
case OSKEY:
- event.oskey = evt->oskey = (event.val == KM_PRESS) ?
- ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
- FALSE;
+ evt->oskey = (event.val == KM_PRESS) ?
+ ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+ FALSE;
break;
default:
if (event.val == KM_PRESS && event.keymodifier == 0)
@@ -2911,12 +2944,24 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
break;
}
+ /* double click test */
+ if (event.type == evt->prevtype && event.val == KM_PRESS) {
+ if ((ABS(event.x - evt->prevclickx)) <= 2 &&
+ (ABS(event.y - evt->prevclicky)) <= 2 &&
+ ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time))
+ {
+ // printf("double click\n");
+ evt->val = event.val = KM_DBL_CLICK;
+ }
+ }
+
/* this case happens on some systems that on holding a key pressed,
* generate press events without release, we still want to keep the
* modifier in win->eventstate, but for the press event of the same
* key we don't want the key modifier */
if (event.keymodifier == event.type)
event.keymodifier = 0;
+
/* this case happened with an external numpad, it's not really clear
* why, but it's also impossible to map a key modifier to an unknwon
* key, so it shouldn't harm */
@@ -2927,6 +2972,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
if (event.type == ESCKEY && event.val == KM_PRESS)
G.is_break = TRUE;
+ if (event.val == KM_RELEASE) {
+ evt->prevclicktime = PIL_check_seconds_timer();
+ evt->prevclickx = event.x;
+ evt->prevclicky = event.y;
+ }
+
wm_event_add(win, &event);
break;
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 433c447bfd4..5baf223dc3e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -718,7 +718,7 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
IB_rect, FALSE, FALSE, err_out);
}
- if (ibuf) {
+ if (ibuf) {
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
/* dirty oversampling */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 658a13a8918..89fa92b7373 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -423,6 +423,7 @@ void WM_exit_ext(bContext *C, const short do_python)
#ifdef WITH_INTERNATIONAL
BLF_free_unifont();
+ BLF_lang_free();
#endif
ANIM_keyingset_infos_exit();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 4a410363167..0917d766051 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -466,7 +466,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
if (wm_job->flag & WM_JOB_PROGRESS)
WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
wm_job->do_update = FALSE;
- }
+ }
if (wm_job->ready) {
if (wm_job->endjob)
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 8c9d4861a9e..af6ec370fea 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -674,6 +674,8 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
else {
pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = uiPupMenuLayout(pup);
+ /* set this so the default execution context is the same as submenus */
+ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
}
@@ -745,7 +747,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op)
wmOperator *op = (wmOperator *)arg_op;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
#if 0 /* ok, this isn't so easy... */
uiDefBut(block, LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, 180, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -807,7 +809,7 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op); /* call exec direct */
- }
+ }
else {
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -993,7 +995,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
/* if register is not enabled, the operator gets freed on OPERATOR_FINISHED
* ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */
@@ -1071,7 +1073,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
/* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items
* where quitting by accident is very annoying */
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
@@ -1112,7 +1114,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
@@ -1215,7 +1217,7 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op)
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
WM_event_add_notifier(C, NC_WINDOW, NULL);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
@@ -1317,10 +1319,14 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 5;
rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5;
-#endif //WITH_BUILDINFO
+#endif /* WITH_BUILDINFO */
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
+
+ /* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized
+ * with the OS when the splash shows, window clipping in this case gives
+ * ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
but = uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
uiButSetFunc(but, wm_block_splash_close, block, NULL);
@@ -1329,7 +1335,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
#ifdef WITH_BUILDINFO
uiDefBut(block, LABEL, 0, version_buf, 494 - ver_width, 282 - 24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, LABEL, 0, revision_buf, 494 - rev_width, 282 - 36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
-#endif //WITH_BUILDINFO
+#endif /* WITH_BUILDINFO */
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style);
@@ -1459,7 +1465,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_
uiBut *but;
block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
@@ -1501,12 +1507,12 @@ static int wm_search_menu_poll(bContext *C)
else {
ScrArea *sa = CTX_wm_area(C);
if (sa) {
- if (sa->spacetype == SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console
- if (sa->spacetype == SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor
+ if (sa->spacetype == SPACE_CONSOLE) return 0; /* XXX - so we can use the shortcut in the console */
+ if (sa->spacetype == SPACE_TEXT) return 0; /* XXX - so we can use the spacebar in the text editor */
}
else {
Object *editob = CTX_data_edit_object(C);
- if (editob && editob->type == OB_FONT) return 0; // XXX - so we can use the spacebar for entering text
+ if (editob && editob->type == OB_FONT) return 0; /* XXX - so we can use the spacebar for entering text */
}
}
return 1;
@@ -1715,7 +1721,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev
{
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op);
- }
+ }
else {
/* XXX TODO solve where to get last linked library from */
if (G.lib[0] != '\0') {
@@ -2184,7 +2190,7 @@ static int wm_exit_blender_op(bContext *C, wmOperator *op)
{
WM_operator_free(op);
- WM_exit(C);
+ WM_exit(C);
return OPERATOR_FINISHED;
}
@@ -2282,10 +2288,10 @@ static int border_apply_rect(wmOperator *op)
/* operator arguments and storage. */
- RNA_int_set(op->ptr, "xmin", MIN2(rect->xmin, rect->xmax));
- RNA_int_set(op->ptr, "ymin", MIN2(rect->ymin, rect->ymax));
- RNA_int_set(op->ptr, "xmax", MAX2(rect->xmin, rect->xmax));
- RNA_int_set(op->ptr, "ymax", MAX2(rect->ymin, rect->ymax));
+ RNA_int_set(op->ptr, "xmin", min_ii(rect->xmin, rect->xmax));
+ RNA_int_set(op->ptr, "ymin", min_ii(rect->ymin, rect->ymax));
+ RNA_int_set(op->ptr, "xmax", max_ii(rect->xmin, rect->xmax));
+ RNA_int_set(op->ptr, "ymax", max_ii(rect->ymin, rect->ymax));
return 1;
}
@@ -3483,7 +3489,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
if (type == 0) {
if (ar)
ED_region_do_draw(C, ar);
- }
+ }
else if (type == 1) {
wmWindow *win = CTX_wm_window(C);
@@ -3856,7 +3862,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_border");
- WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); // XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel
+ WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */
}
/* zoom to border modal operators */
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 4078a88b2fd..e33f936b4da 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -192,7 +192,7 @@ void wm_subwindow_close(wmWindow *win, int swinid)
wm_subwindow_free(swin);
BLI_remlink(&win->subwindows, swin);
MEM_freeN(swin);
- }
+ }
else {
printf("%s: Internal error, bad winid: %d\n", __func__, swinid);
}
@@ -398,7 +398,7 @@ int WM_framebuffer_to_index(unsigned int col)
return col & 0xFFFFFF;
default: // 18 bits...
return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2);
- }
+ }
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 44827302d7d..7d5dc858b00 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -164,7 +164,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
if (CTX_wm_window(C) == win)
CTX_wm_window_set(C, NULL);
- }
+ }
/* always set drawable and active to NULL,
* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
@@ -414,6 +414,10 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
win->posy = wm_init_state.start_y;
win->sizex = wm_init_state.size_x;
win->sizey = wm_init_state.size_y;
+
+ /* we can't properly resize a maximized window */
+ win->windowstate = GHOST_kWindowStateNormal;
+
wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM;
}
@@ -648,7 +652,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
else if (!GHOST_ValidWindow(g_system, ghostwin)) {
/* XXX - should be checked, why are we getting an event here, and */
/* what is it? */
- puts("<!> event has invalid window");
+ puts("<!> event has invalid window");
return 1;
}
else {
@@ -1001,7 +1005,7 @@ void wm_ghost_init(bContext *C)
g_system = GHOST_CreateSystem();
GHOST_AddEventConsumer(g_system, consumer);
- }
+ }
}
void wm_ghost_exit(void)
@@ -1076,7 +1080,7 @@ char *WM_clipboard_text_get(int selection)
return NULL;
/* always convert from \r\n to \n */
- newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get");
+ newbuf = MEM_callocN(strlen(buf) + 1, __func__);
for (p = buf, p2 = newbuf; *p; p++) {
if (*p != '\r')
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index a33d37ac50e..2d0dd2ef911 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -32,10 +32,10 @@
#define __WM_EVENT_SYSTEM_H__
/* return value of handler-operator call */
-#define WM_HANDLER_CONTINUE 0
-#define WM_HANDLER_BREAK 1
-#define WM_HANDLER_HANDLED 2
-#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
+#define WM_HANDLER_CONTINUE 0
+#define WM_HANDLER_BREAK 1
+#define WM_HANDLER_HANDLED 2
+#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
struct ScrArea;
struct ARegion;
@@ -44,40 +44,40 @@ struct ARegion;
typedef struct wmEventHandler {
struct wmEventHandler *next, *prev;
-
- int type, flag; /* type default=0, rest is custom */
-
+
+ int type, flag; /* type default=0, rest is custom */
+
/* keymap handler */
- wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
- rcti *bblocal, *bbwin; /* optional local and windowspace bb */
-
+ wmKeyMap *keymap; /* pointer to builtin/custom keymaps */
+ rcti *bblocal, *bbwin; /* optional local and windowspace bb */
+
/* modal operator handler */
- wmOperator *op; /* for derived/modal handlers */
- struct ScrArea *op_area; /* for derived/modal handlers */
- struct ARegion *op_region; /* for derived/modal handlers */
+ wmOperator *op; /* for derived/modal handlers */
+ struct ScrArea *op_area; /* for derived/modal handlers */
+ struct ARegion *op_region; /* for derived/modal handlers */
/* ui handler */
- wmUIHandlerFunc ui_handle; /* callback receiving events */
- wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */
- void *ui_userdata; /* user data pointer */
- struct ScrArea *ui_area; /* for derived/modal handlers */
- struct ARegion *ui_region; /* for derived/modal handlers */
- struct ARegion *ui_menu; /* for derived/modal handlers */
-
+ wmUIHandlerFunc ui_handle; /* callback receiving events */
+ wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */
+ void *ui_userdata; /* user data pointer */
+ struct ScrArea *ui_area; /* for derived/modal handlers */
+ struct ARegion *ui_region; /* for derived/modal handlers */
+ struct ARegion *ui_menu; /* for derived/modal handlers */
+
/* fileselect handler re-uses modal operator data */
- struct bScreen *filescreen; /* screen it started in, to validate exec */
-
+ struct bScreen *filescreen; /* screen it started in, to validate exec */
+
/* drop box handler */
ListBase *dropboxes;
-
+
} wmEventHandler;
/* handler flag */
/* after this handler all others are ignored */
-#define WM_HANDLER_BLOCKING 1
+#define WM_HANDLER_BLOCKING 1
/* handler tagged to be freed in wm_handlers_do() */
-#define WM_HANDLER_DO_FREE 2
+#define WM_HANDLER_DO_FREE 2
@@ -89,23 +89,23 @@ enum {
/* wm_event_system.c */
-void wm_event_free_all (wmWindow *win);
-void wm_event_free (wmEvent *event);
-void wm_event_free_handler (wmEventHandler *handler);
+void wm_event_free_all (wmWindow *win);
+void wm_event_free (wmEvent *event);
+void wm_event_free_handler (wmEventHandler *handler);
- /* goes over entire hierarchy: events -> window -> screen -> area -> region */
-void wm_event_do_handlers (bContext *C);
+ /* goes over entire hierarchy: events -> window -> screen -> area -> region */
+void wm_event_do_handlers (bContext *C);
-void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
+void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
-void wm_event_do_notifiers (bContext *C);
+void wm_event_do_notifiers (bContext *C);
/* wm_keymap.c */
/* wm_dropbox.c */
-void wm_dropbox_free(void);
-void wm_drags_check_ops(bContext *C, wmEvent *event);
-void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
+void wm_dropbox_free(void);
+void wm_drags_check_ops(bContext *C, wmEvent *event);
+void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
#endif /* __WM_EVENT_SYSTEM_H__ */