fix [#30087] operator_context is different for popup and submenu's *TODO, after 2.62*

having context different for menu vs submenu is quite confusing, now they are both: WM_OP_INVOKE_REGION_WIN
this changes WM_menu_invoke behavior.
This commit is contained in:
Campbell Barton 2012-10-26 06:22:54 +00:00
parent 2d39533da8
commit dbde62d124
5 changed files with 19 additions and 1 deletions

@ -1450,6 +1450,11 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
menu.type = mt;
menu.layout = layout;
if (G.debug & G_DEBUG_WM) {
printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
}
mt->draw(C, &menu);
}

@ -46,6 +46,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_global.h"
#include "WM_api.h"
#include "WM_types.h"
@ -2510,6 +2511,9 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
/* note, this intentionally differs from the menu & submenu default because many operators
* use popups like this to select one of their options - where having invoke doesn't make sense */
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
/* create in advance so we can let buttons point to retval already */
@ -2721,6 +2725,10 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
menu.layout = layout;
menu.type = mt;
if (G.debug & G_DEBUG_WM) {
printf("%s: opening menu \"%s\"\n", __func__, idname);
}
mt->draw(C, &menu);
uiPupMenuEnd(C, pup);

@ -3082,6 +3082,9 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
}
else {
if (sync) {
/* note: this is very simplistic,
* its has problem that it may skip too many frames.
* however at least this gives a less jittery playback */
const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
/* skip frames */

@ -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);
}

@ -1080,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')