- Made view2d manipulations redraw on area level
- simplified call to send Notifiers:

  WM_event_add_notifier(bContext *C, int type, int value, void *data)

  This brings back more control to WM, no context messing within
  operators. :) Handlers that execute operators will be responsible
  for delivering correct contextes.

  In general: should lead to making context not exposed, but only 
  readable via some callbacks.
This commit is contained in:
Ton Roosendaal 2008-12-03 13:44:16 +00:00
parent d8ed4c389c
commit 167ac3606b
10 changed files with 55 additions and 58 deletions

@ -1183,7 +1183,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiActiva
}
if(changed || handled)
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiActivateBut *data, wmEvent *event)
@ -1209,7 +1209,7 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
if(handled) {
ui_check_but(but);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
}
@ -1265,7 +1265,7 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiActivate
if(data->interactive) ui_apply_button(block, but, data, 1);
else ui_check_but(but);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
/* ****************** block opening for various types **************** */
@ -2647,7 +2647,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiActivateButState st
}
data->state= state;
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
static void button_activate_init(bContext *C, ARegion *ar, wmOperator *op, uiBut *but, uiBut *lastbut)
@ -2746,7 +2746,7 @@ static void button_activate_exit(bContext *C, uiActivateBut *data, wmOperator *o
}
/* redraw */
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
/* clean up */
button_disable_timers(C, data);
@ -2863,7 +2863,7 @@ static int button_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
if(event->customdata == data->tooltiptimer) {
if(!data->tooltip) {
data->tooltip= ui_tooltip_create(C, data->region, but);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
WM_event_remove_window_timer(C->window, data->tooltiptimer);
@ -2891,14 +2891,14 @@ static int button_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
if(but && but->activate == data) {
if(!(but->flag & UI_SELECT)) {
but->flag |= UI_SELECT;
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
}
else {
but= ui_but_find_activated(data->region, data, &block);
if(but->flag & UI_SELECT) {
but->flag &= ~UI_SELECT;
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
}
break;

@ -332,8 +332,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
ar->winrct.ymax= y2;
/* notify change and redraw */
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
return ar;
}
@ -342,8 +342,8 @@ void ui_tooltip_free(bContext *C, ARegion *ar)
{
ui_remove_temporary_region(C, C->window->screen, ar);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
/************************* Creating Menu Blocks **********************/
@ -650,8 +650,8 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *
block->flag |= UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT;
/* notify change and redraw */
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
SWAP(ARegion*, C->region, ar); /* XXX 2.50 bad context swapping */
WM_operator_invoke(C, WM_operatortype_find("ED_UI_OT_menu_block_handle"), NULL);
@ -665,8 +665,8 @@ void ui_menu_block_free(bContext *C, uiMenuBlockHandle *handle)
ui_remove_temporary_region(C, C->window->screen, handle->region);
MEM_freeN(handle);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
/***************************** Menu Button ***************************/

@ -34,6 +34,8 @@
#include "DNA_space_types.h"
#include "DNA_view2d_types.h"
#include "BLI_blenlib.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
@ -157,7 +159,7 @@ static void view_pan_apply(bContext *C, wmOperator *op)
}
/* request updates to be done... */
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
}
@ -480,7 +482,7 @@ static void view_zoom_apply(bContext *C, wmOperator *op)
}
/* request updates to be done... */
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
}

@ -335,7 +335,7 @@ static int screen_area_rip_op(bContext *C, wmOperator *op)
area_copy_data((ScrArea *)newsc->areabase.first, C->area, 0);
/* screen, areas init */
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
return OPERATOR_FINISHED;
}
@ -517,7 +517,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int
}
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
}
static void area_move_apply(bContext *C, wmOperator *op)
@ -766,7 +766,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
if(dir=='h') sd->origval= sd->nedge->v1->vec.y;
else sd->origval= sd->nedge->v1->vec.x;
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
return 1;
}
@ -781,7 +781,7 @@ static void area_split_exit(bContext *C, wmOperator *op)
op->customdata = NULL;
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
/* this makes sure aligned edges will result in aligned grabbing */
removedouble_scrverts(C->screen);
@ -887,7 +887,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval;
area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
break;
case LEFTMOUSE:
@ -1090,7 +1090,7 @@ static int area_join_cancel(bContext *C, wmOperator *op)
jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
area_join_exit(C, op);
@ -1137,7 +1137,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
jd->sa2 = NULL;
}
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
else {
/* we are back in the area previously selected for keeping
@ -1162,7 +1162,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
}
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
}
}
@ -1170,7 +1170,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
if(event->val==0) {
area_join_apply(C, op);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
area_join_exit(C, op);
return OPERATOR_FINISHED;
}

@ -56,6 +56,7 @@
#include "UI_interface_icons.h"
#include "UI_view2d.h"
#include "UI_resources.h"
#include "UI_text.h"
#include "ED_markers.h"
#include "ED_screen.h"
@ -244,7 +245,6 @@ typedef struct MarkerMove {
ListBase *markers;
int event_type; /* store invoke-event, to verify */
int *oldframe, evtx, firstx;
short swinid;
} MarkerMove;
/* copy selection to temp buffer */
@ -293,7 +293,6 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt)
mm->evtx= evt->x;
mm->firstx= evt->x;
mm->swinid= C->region->swinid;
mm->event_type= evt->type;
/* add temp handler */
@ -327,13 +326,12 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
/* only for modal */
static void ed_marker_move_cancel(bContext *C, wmOperator *op)
{
MarkerMove *mm= op->customdata;
RNA_int_set(op->ptr, "frs", 0);
ed_marker_move_apply(C, op);
ed_marker_move_exit(C, op);
WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
}
@ -375,7 +373,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
case RIGHTMOUSE:
if(WM_modal_tweak_check(evt, mm->event_type)) {
ed_marker_move_exit(C, op);
WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
return OPERATOR_FINISHED;
}
@ -452,7 +450,7 @@ XXX else if (mm->slink->spacetype == SPACE_ACTION) {
}
}
WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
// headerprint(str); XXX
}
}
@ -620,7 +618,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend)
select_timeline_marker_frame(cfra, 0);
/* XXX notifier for markers... */
WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
return OPERATOR_PASS_THROUGH;
}
@ -682,7 +680,6 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
{
View2D *v2d= UI_view2d_fromcontext(C);
ListBase *markers= context_get_markers(C);
wmGesture *gesture= op->customdata;
TimeMarker *marker;
float xminf, xmaxf, yminf, ymaxf;
int event_type= RNA_int_get(op->ptr, "event_type");
@ -714,8 +711,8 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
}
}
/* XXX notifier for markers..., XXX swinid??? */
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX notifier for markers... */
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
return 1;
}
@ -769,7 +766,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
}
/* XXX notifier for markers... */
WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
return OPERATOR_FINISHED;
}
@ -817,7 +814,7 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op)
/* XXX notifier for markers... */
if(changed)
WM_event_add_notifier(C->wm, C->window, C->region->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
return OPERATOR_FINISHED;
}

@ -85,7 +85,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
if(cfra!=CFRA)
CFRA= cfra;
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
}

@ -77,9 +77,7 @@ void WM_event_add_message(wmWindowManager *wm, void *customdata,
short customdatafree);
void WM_event_add_mousemove(bContext *C);
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window,
int swinid, int type,
int value, void *data);
void WM_event_add_notifier(bContext *C, int type, int value, void *data);
void wm_event_add (wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */

@ -92,15 +92,15 @@ void wm_event_free_all(wmWindow *win)
/* ********************* notifiers, listeners *************** */
/* win and swinid are optional context limitors */
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type, int value, void *data)
/* XXX: in future, which notifiers to send to other windows? */
void WM_event_add_notifier(bContext *C, int type, int value, void *data)
{
wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
BLI_addtail(&wm->queue, note);
BLI_addtail(&C->wm->queue, note);
note->window= window;
note->swinid= swinid;
note->window= C->window;
if(C->region) note->swinid= C->region->swinid;
note->type= type;
note->value= value;
note->data= data;

@ -183,7 +183,7 @@ static void border_select_end(bContext *C, wmOperator *op)
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
}
@ -194,7 +194,7 @@ int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* add modal handler */
WM_event_add_modal_handler(C, &C->window->handlers, op);
WM_event_add_notifier(C->wm, C->window, C->screen->subwinactive, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
return OPERATOR_RUNNING_MODAL;
}
@ -219,7 +219,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
rect->ymax= event->y - sy;
}
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
break;
@ -229,7 +229,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
if(event->val==1) {
if(gesture->type==WM_GESTURE_CROSS_RECT && gesture->mode==0) {
gesture->mode= 1;
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
}
}
else {
@ -254,7 +254,7 @@ static int tweak_gesture_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* add modal handler */
WM_event_add_modal_handler(C, &C->window->handlers, op);
WM_event_add_notifier(C->wm, C->window, C->screen->subwinactive, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
return OPERATOR_RUNNING_MODAL;
}
@ -266,7 +266,7 @@ static void tweak_gesture_end(bContext *C, wmOperator *op)
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_AREA_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
}
@ -302,7 +302,7 @@ static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
}
else
WM_event_add_notifier(C->wm, C->window, gesture->swinid, WM_NOTE_GESTURE_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_GESTURE_REDRAW, 0, NULL);
break;

@ -423,7 +423,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
if(G.f & G_DEBUG) printf("ghost redraw\n");
wm_window_make_drawable(C, win);
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
break;
}
@ -468,13 +468,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
}
wm_window_make_drawable(C, win);
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
break;
}
default:
if(type==GHOST_kEventKeyDown) // XXX debug
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
wm_event_add_ghostevent(win, type, data);
break;
}