style cleanup: wm, mosyly adding space around ops

This commit is contained in:
2012-03-27 01:24:16 +00:00
parent 126c9d4caa
commit ae654301b0
14 changed files with 2587 additions and 2588 deletions

View File

@@ -69,7 +69,7 @@
/* ****************************************************** */ /* ****************************************************** */
#define MAX_OP_REGISTERED 32 #define MAX_OP_REGISTERED 32
void WM_operator_free(wmOperator *op) void WM_operator_free(wmOperator *op)
{ {
@@ -83,7 +83,7 @@ void WM_operator_free(wmOperator *op)
#endif #endif
if (op->ptr) { if (op->ptr) {
op->properties= op->ptr->data; op->properties = op->ptr->data;
MEM_freeN(op->ptr); MEM_freeN(op->ptr);
} }
@@ -99,7 +99,7 @@ void WM_operator_free(wmOperator *op)
if (op->macro.first) { if (op->macro.first) {
wmOperator *opm, *opmnext; wmOperator *opm, *opmnext;
for (opm= op->macro.first; opm; opm= opmnext) { for (opm = op->macro.first; opm; opm = opmnext) {
opmnext = opm->next; opmnext = opm->next;
WM_operator_free(opm); WM_operator_free(opm);
} }
@@ -118,22 +118,22 @@ static void wm_reports_free(wmWindowManager *wm)
/* called on event handling by event_system.c */ /* called on event handling by event_system.c */
void wm_operator_register(bContext *C, wmOperator *op) void wm_operator_register(bContext *C, wmOperator *op)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
int tot; int tot;
BLI_addtail(&wm->operators, op); BLI_addtail(&wm->operators, op);
tot= BLI_countlist(&wm->operators); tot = BLI_countlist(&wm->operators);
while (tot>MAX_OP_REGISTERED) { while (tot > MAX_OP_REGISTERED) {
wmOperator *opt= wm->operators.first; wmOperator *opt = wm->operators.first;
BLI_remlink(&wm->operators, opt); BLI_remlink(&wm->operators, opt);
WM_operator_free(opt); WM_operator_free(opt);
tot--; tot--;
} }
/* so the console is redrawn */ /* so the console is redrawn */
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL); WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL);
} }
@@ -141,24 +141,24 @@ void WM_operator_stack_clear(wmWindowManager *wm)
{ {
wmOperator *op; wmOperator *op;
while ((op= wm->operators.first)) { while ((op = wm->operators.first)) {
BLI_remlink(&wm->operators, op); BLI_remlink(&wm->operators, op);
WM_operator_free(op); WM_operator_free(op);
} }
WM_main_add_notifier(NC_WM|ND_HISTORY, NULL); WM_main_add_notifier(NC_WM | ND_HISTORY, NULL);
} }
/* ****************************************** */ /* ****************************************** */
static GHash *menutypes_hash= NULL; static GHash *menutypes_hash = NULL;
MenuType *WM_menutype_find(const char *idname, int quiet) MenuType *WM_menutype_find(const char *idname, int quiet)
{ {
MenuType* mt; MenuType *mt;
if (idname[0]) { if (idname[0]) {
mt= BLI_ghash_lookup(menutypes_hash, idname); mt = BLI_ghash_lookup(menutypes_hash, idname);
if (mt) if (mt)
return mt; return mt;
} }
@@ -169,13 +169,13 @@ MenuType *WM_menutype_find(const char *idname, int quiet)
return NULL; return NULL;
} }
int WM_menutype_add(MenuType* mt) int WM_menutype_add(MenuType *mt)
{ {
BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt); BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt);
return 1; return 1;
} }
void WM_menutype_freelink(MenuType* mt) void WM_menutype_freelink(MenuType *mt)
{ {
BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN); BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN);
} }
@@ -183,15 +183,15 @@ void WM_menutype_freelink(MenuType* mt)
/* called on initialize WM_init() */ /* called on initialize WM_init() */
void WM_menutype_init(void) void WM_menutype_init(void)
{ {
menutypes_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh"); menutypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh");
} }
void WM_menutype_free(void) void WM_menutype_free(void)
{ {
GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash); GHashIterator *iter = BLI_ghashIterator_new(menutypes_hash);
for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
MenuType *mt= BLI_ghashIterator_getValue(iter); MenuType *mt = BLI_ghashIterator_getValue(iter);
if (mt->ext.free) { if (mt->ext.free) {
mt->ext.free(mt->ext.data); mt->ext.free(mt->ext.data);
} }
@@ -199,22 +199,22 @@ void WM_menutype_free(void)
BLI_ghashIterator_free(iter); BLI_ghashIterator_free(iter);
BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN); BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN);
menutypes_hash= NULL; menutypes_hash = NULL;
} }
/* ****************************************** */ /* ****************************************** */
void WM_keymap_init(bContext *C) void WM_keymap_init(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
/* create standard key configs */ /* create standard key configs */
if (!wm->defaultconf) if (!wm->defaultconf)
wm->defaultconf= WM_keyconfig_new(wm, "Blender"); wm->defaultconf = WM_keyconfig_new(wm, "Blender");
if (!wm->addonconf) if (!wm->addonconf)
wm->addonconf= WM_keyconfig_new(wm, "Blender Addon"); wm->addonconf = WM_keyconfig_new(wm, "Blender Addon");
if (!wm->userconf) if (!wm->userconf)
wm->userconf= WM_keyconfig_new(wm, "Blender User"); wm->userconf = WM_keyconfig_new(wm, "Blender User");
/* initialize only after python init is done, for keymaps that /* initialize only after python init is done, for keymaps that
* use python operators */ * use python operators */
@@ -237,15 +237,15 @@ void WM_keymap_init(bContext *C)
void WM_check(bContext *C) void WM_check(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
/* wm context */ /* wm context */
if (wm==NULL) { if (wm == NULL) {
wm= CTX_data_main(C)->wm.first; wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm); CTX_wm_manager_set(C, wm);
} }
if (wm==NULL) return; if (wm == NULL) return;
if (wm->windows.first==NULL) return; if (wm->windows.first == NULL) return;
if (!G.background) { if (!G.background) {
/* case: fileread */ /* case: fileread */
@@ -268,18 +268,18 @@ void WM_check(bContext *C)
void wm_clear_default_size(bContext *C) void wm_clear_default_size(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win; wmWindow *win;
/* wm context */ /* wm context */
if (wm==NULL) { if (wm == NULL) {
wm= CTX_data_main(C)->wm.first; wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm); CTX_wm_manager_set(C, wm);
} }
if (wm==NULL) return; if (wm == NULL) return;
if (wm->windows.first==NULL) return; if (wm->windows.first == NULL) return;
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
win->sizex = 0; win->sizex = 0;
win->sizey = 0; win->sizey = 0;
win->posx = 0; win->posx = 0;
@@ -291,18 +291,18 @@ void wm_clear_default_size(bContext *C)
/* on startup, it adds all data, for matching */ /* on startup, it adds all data, for matching */
void wm_add_default(bContext *C) void wm_add_default(bContext *C)
{ {
wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); wmWindowManager *wm = alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
wmWindow *win; wmWindow *win;
bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */ bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */
CTX_wm_manager_set(C, wm); CTX_wm_manager_set(C, wm);
win= wm_window_new(C); win = wm_window_new(C);
win->screen= screen; win->screen = screen;
screen->winid= win->winid; screen->winid = win->winid;
BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname)); BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname));
wm->winactive= win; wm->winactive = win;
wm->file_saved= 1; wm->file_saved = 1;
wm_window_make_drawable(C, win); wm_window_make_drawable(C, win);
} }
@@ -317,19 +317,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
if (wm->autosavetimer) if (wm->autosavetimer)
wm_autosave_timer_ended(wm); wm_autosave_timer_ended(wm);
while ((win= wm->windows.first)) { while ((win = wm->windows.first)) {
BLI_remlink(&wm->windows, win); BLI_remlink(&wm->windows, win);
win->screen= NULL; /* prevent draw clear to use screen */ win->screen = NULL; /* prevent draw clear to use screen */
wm_draw_window_clear(win); wm_draw_window_clear(win);
wm_window_free(C, wm, win); wm_window_free(C, wm, win);
} }
while ((op= wm->operators.first)) { while ((op = wm->operators.first)) {
BLI_remlink(&wm->operators, op); BLI_remlink(&wm->operators, op);
WM_operator_free(op); WM_operator_free(op);
} }
while ((keyconf=wm->keyconfigs.first)) { while ((keyconf = wm->keyconfigs.first)) {
BLI_remlink(&wm->keyconfigs, keyconf); BLI_remlink(&wm->keyconfigs, keyconf);
WM_keyconfig_free(keyconf); WM_keyconfig_free(keyconf);
} }
@@ -341,14 +341,14 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_reports_free(wm); wm_reports_free(wm);
if (C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL); if (C && CTX_wm_manager(C) == wm) CTX_wm_manager_set(C, NULL);
} }
void wm_close_and_free_all(bContext *C, ListBase *wmlist) void wm_close_and_free_all(bContext *C, ListBase *wmlist)
{ {
wmWindowManager *wm; wmWindowManager *wm;
while ((wm=wmlist->first)) { while ((wm = wmlist->first)) {
wm_close_and_free(C, wm); wm_close_and_free(C, wm);
BLI_remlink(wmlist, wm); BLI_remlink(wmlist, wm);
MEM_freeN(wm); MEM_freeN(wm);

View File

@@ -62,23 +62,23 @@ static int checkAppleVideoCard(void)
long value; long value;
long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */ long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */
display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() ); display_mask = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID() );
theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend); theErr = CGLQueryRendererInfo(display_mask, &rend, &nrend);
if (theErr == 0) { if (theErr == 0) {
theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend); theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend);
if (theErr == 0) { if (theErr == 0) {
for (j = 0; j < nrend; j++) { for (j = 0; j < nrend; j++) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value); theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value);
if (value > maxvram) if (value > maxvram)
maxvram = value; maxvram = value;
if ((theErr == 0) && (value >= 20000000)) { if ((theErr == 0) && (value >= 20000000)) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value); theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value);
if ((theErr == 0) && (value != 0)) { if ((theErr == 0) && (value != 0)) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value); theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value);
if ((theErr == 0) && (value != 0)) { if ((theErr == 0) && (value != 0)) {
/*fprintf(stderr,"make it big\n");*/ /*fprintf(stderr,"make it big\n");*/
CGLDestroyRendererInfo (rend); CGLDestroyRendererInfo(rend);
macPrefState = 8; macPrefState = 8;
return 1; return 1;
} }
@@ -87,18 +87,18 @@ static int checkAppleVideoCard(void)
} }
} }
} }
if (maxvram < 7500000 ) { /* put a standard alert and quit*/ if (maxvram < 7500000) { /* put a standard alert and quit*/
SInt16 junkHit; SInt16 junkHit;
char inError[] = "* Not enough VRAM "; char inError[] = "* Not enough VRAM ";
char inText[] = "* blender needs at least 8Mb "; char inText[] = "* blender needs at least 8Mb ";
inError[0] = 16; inError[0] = 16;
inText[0] = 28; inText[0] = 28;
fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram); fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
StandardAlert ( kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit); StandardAlert(kAlertStopAlert, (ConstStr255Param) & inError, (ConstStr255Param) & inText, NULL, &junkHit);
abort(); abort();
} }
CGLDestroyRendererInfo (rend); CGLDestroyRendererInfo(rend);
return 0; return 0;
} }
@@ -106,7 +106,7 @@ static void getMacAvailableBounds(short *top, short *left, short *bottom, short
{ {
Rect outAvailableRect; Rect outAvailableRect;
GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
*top = outAvailableRect.top; *top = outAvailableRect.top;
*left = outAvailableRect.left; *left = outAvailableRect.left;
@@ -124,14 +124,14 @@ void wm_set_apple_prefsize(int scr_x, int scr_y)
short top, left, bottom, right; short top, left, bottom, right;
getMacAvailableBounds(&top, &left, &bottom, &right); getMacAvailableBounds(&top, &left, &bottom, &right);
WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64); WM_setprefsize(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64);
G.windowstate= 0; G.windowstate = 0;
} }
else { else {
/* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
WM_setprefsize(120, 40, 850, 684); WM_setprefsize(120, 40, 850, 684);
G.windowstate= 0; G.windowstate = 0;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,7 @@
/* ****************************************************** */ /* ****************************************************** */
static ListBase dropboxes= {NULL, NULL}; static ListBase dropboxes = {NULL, NULL};
/* drop box maps are stored global for now */ /* drop box maps are stored global for now */
/* these are part of blender's UI/space specs, and not like keymaps */ /* these are part of blender's UI/space specs, and not like keymaps */
@@ -83,15 +83,15 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
{ {
wmDropBoxMap *dm; wmDropBoxMap *dm;
for (dm= dropboxes.first; dm; dm= dm->next) for (dm = dropboxes.first; dm; dm = dm->next)
if (dm->spaceid==spaceid && dm->regionid==regionid) if (dm->spaceid == spaceid && dm->regionid == regionid)
if (0==strncmp(idname, dm->idname, KMAP_MAX_NAME)) if (0 == strncmp(idname, dm->idname, KMAP_MAX_NAME))
return &dm->dropboxes; return &dm->dropboxes;
dm= MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME); BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME);
dm->spaceid= spaceid; dm->spaceid = spaceid;
dm->regionid= regionid; dm->regionid = regionid;
BLI_addtail(&dropboxes, dm); BLI_addtail(&dropboxes, dm);
return &dm->dropboxes; return &dm->dropboxes;
@@ -100,16 +100,16 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, wmEvent *), wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, wmEvent *),
void (*copy)(wmDrag *, wmDropBox *)) void (*copy)(wmDrag *, wmDropBox *))
{ {
wmDropBox *drop= MEM_callocN(sizeof(wmDropBox), "wmDropBox"); wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox");
drop->poll= poll; drop->poll = poll;
drop->copy= copy; drop->copy = copy;
drop->ot= WM_operatortype_find(idname, 0); drop->ot = WM_operatortype_find(idname, 0);
drop->opcontext= WM_OP_INVOKE_DEFAULT; drop->opcontext = WM_OP_INVOKE_DEFAULT;
if (drop->ot==NULL) { if (drop->ot == NULL) {
MEM_freeN(drop); MEM_freeN(drop);
printf("Error: dropbox with unknown operator: %s\n", idname); printf("Error: dropbox with unknown operator: %s\n", idname);
return NULL; return NULL;
@@ -125,10 +125,10 @@ void wm_dropbox_free(void)
{ {
wmDropBoxMap *dm; wmDropBoxMap *dm;
for (dm= dropboxes.first; dm; dm= dm->next) { for (dm = dropboxes.first; dm; dm = dm->next) {
wmDropBox *drop; wmDropBox *drop;
for (drop= dm->dropboxes.first; drop; drop= drop->next) { for (drop = dm->dropboxes.first; drop; drop = drop->next) {
if (drop->ptr) { if (drop->ptr) {
WM_operator_properties_free(drop->ptr); WM_operator_properties_free(drop->ptr);
MEM_freeN(drop->ptr); MEM_freeN(drop->ptr);
@@ -145,40 +145,40 @@ void wm_dropbox_free(void)
/* note that the pointer should be valid allocated and not on stack */ /* note that the pointer should be valid allocated and not on stack */
wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value) wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag= MEM_callocN(sizeof(struct wmDrag), "new drag"); wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag");
/* keep track of future multitouch drag too, add a mousepointer id or so */ /* keep track of future multitouch drag too, add a mousepointer id or so */
/* if multiple drags are added, they're drawn as list */ /* if multiple drags are added, they're drawn as list */
BLI_addtail(&wm->drags, drag); BLI_addtail(&wm->drags, drag);
drag->icon= icon; drag->icon = icon;
drag->type= type; drag->type = type;
if (type==WM_DRAG_PATH) if (type == WM_DRAG_PATH)
BLI_strncpy(drag->path, poin, FILE_MAX); BLI_strncpy(drag->path, poin, FILE_MAX);
else else
drag->poin= poin; drag->poin = poin;
drag->value= value; drag->value = value;
return drag; return drag;
} }
void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy) void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy)
{ {
drag->imb= imb; drag->imb = imb;
drag->scale= scale; drag->scale = scale;
drag->sx= sx; drag->sx = sx;
drag->sy= sy; drag->sy = sy;
} }
static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event) static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event)
{ {
wmEventHandler *handler= handlers->first; wmEventHandler *handler = handlers->first;
for (; handler; handler= handler->next) { for (; handler; handler = handler->next) {
if (handler->dropboxes) { if (handler->dropboxes) {
wmDropBox *drop= handler->dropboxes->first; wmDropBox *drop = handler->dropboxes->first;
for (; drop; drop= drop->next) { for (; drop; drop = drop->next) {
if (drop->poll(C, drag, event)) if (drop->poll(C, drag, event))
return drop->ot->name; return drop->ot->name;
} }
@@ -190,18 +190,18 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag,
/* return active operator name when mouse is in box */ /* return active operator name when mouse is in box */
static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
const char *name; const char *name;
name= dropbox_active(C, &win->handlers, drag, event); name = dropbox_active(C, &win->handlers, drag, event);
if (name) return name; if (name) return name;
name= dropbox_active(C, &sa->handlers, drag, event); name = dropbox_active(C, &sa->handlers, drag, event);
if (name) return name; if (name) return name;
name= dropbox_active(C, &ar->handlers, drag, event); name = dropbox_active(C, &ar->handlers, drag, event);
if (name) return name; if (name) return name;
return NULL; return NULL;
@@ -210,20 +210,20 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event) static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
/* for multiwin drags, we only do this if mouse inside */ /* for multiwin drags, we only do this if mouse inside */
if (event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey) if (event->x < 0 || event->y < 0 || event->x > win->sizex || event->y > win->sizey)
return; return;
drag->opname[0]= 0; drag->opname[0] = 0;
/* check buttons (XXX todo rna and value) */ /* check buttons (XXX todo rna and value) */
if ( UI_but_active_drop_name(C) ) { if (UI_but_active_drop_name(C) ) {
strcpy(drag->opname, "Paste name"); strcpy(drag->opname, "Paste name");
} }
else { else {
const char *opname= wm_dropbox_active(C, drag, event); const char *opname = wm_dropbox_active(C, drag, event);
if (opname) { if (opname) {
BLI_strncpy(drag->opname, opname, FILE_MAX); BLI_strncpy(drag->opname, opname, FILE_MAX);
@@ -238,10 +238,10 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event)
/* called in inner handler loop, region context */ /* called in inner handler loop, region context */
void wm_drags_check_ops(bContext *C, wmEvent *event) void wm_drags_check_ops(bContext *C, wmEvent *event)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag; wmDrag *drag;
for (drag= wm->drags.first; drag; drag= drag->next) { for (drag = wm->drags.first; drag; drag = drag->next) {
wm_drop_operator_options(C, drag, event); wm_drop_operator_options(C, drag, event);
} }
} }
@@ -250,7 +250,7 @@ void wm_drags_check_ops(bContext *C, wmEvent *event)
static void wm_drop_operator_draw(const char *name, int x, int y) static void wm_drop_operator_draw(const char *name, int x, int y)
{ {
int width= UI_GetStringWidth(name); int width = UI_GetStringWidth(name);
glColor4ub(0, 0, 0, 50); glColor4ub(0, 0, 0, 50);
@@ -258,16 +258,16 @@ static void wm_drop_operator_draw(const char *name, int x, int y)
uiRoundBox(x, y, x + width + 8, y + 15, 4); uiRoundBox(x, y, x + width + 8, y + 15, 4);
glColor4ub(255, 255, 255, 255); glColor4ub(255, 255, 255, 255);
UI_DrawString(x+4, y+4, name); UI_DrawString(x + 4, y + 4, name);
} }
static const char *wm_drag_name(wmDrag *drag) static const char *wm_drag_name(wmDrag *drag)
{ {
switch(drag->type) { switch (drag->type) {
case WM_DRAG_ID: case WM_DRAG_ID:
{ {
ID *id= (ID *)drag->poin; ID *id = (ID *)drag->poin;
return id->name+2; return id->name + 2;
} }
case WM_DRAG_PATH: case WM_DRAG_PATH:
return drag->path; return drag->path;
@@ -293,12 +293,12 @@ static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2)
/* if rect set, do not draw */ /* if rect set, do not draw */
void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag; wmDrag *drag;
int cursorx, cursory, x, y; int cursorx, cursory, x, y;
cursorx= win->eventstate->x; cursorx = win->eventstate->x;
cursory= win->eventstate->y; cursory = win->eventstate->y;
if (rect) { if (rect) {
rect->xmin = rect->xmax = cursorx; rect->xmin = rect->xmax = cursorx;
rect->ymin = rect->ymax = cursory; rect->ymin = rect->ymax = cursory;
@@ -306,44 +306,44 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
/* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */
glEnable(GL_BLEND); glEnable(GL_BLEND);
for (drag= wm->drags.first; drag; drag= drag->next) { for (drag = wm->drags.first; drag; drag = drag->next) {
/* image or icon */ /* image or icon */
if (drag->imb) { if (drag->imb) {
x= cursorx - drag->sx/2; x = cursorx - drag->sx / 2;
y= cursory - drag->sy/2; y = cursory - drag->sy / 2;
if (rect) if (rect)
drag_rect_minmax(rect, x, y, x+drag->sx, y+drag->sy); drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy);
else { else {
glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */
glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale); glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale);
} }
} }
else { else {
x= cursorx - 8; x = cursorx - 8;
y= cursory - 2; y = cursory - 2;
/* icons assumed to be 16 pixels */ /* icons assumed to be 16 pixels */
if (rect) if (rect)
drag_rect_minmax(rect, x, y, x+16, y+16); drag_rect_minmax(rect, x, y, x + 16, y + 16);
else else
UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8); UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8);
} }
/* item name */ /* item name */
if (drag->imb) { if (drag->imb) {
x= cursorx - drag->sx/2; x = cursorx - drag->sx / 2;
y= cursory - drag->sy/2 - 16; y = cursory - drag->sy / 2 - 16;
} }
else { else {
x= cursorx + 10; x = cursorx + 10;
y= cursory + 1; y = cursory + 1;
} }
if (rect) { if (rect) {
int w= UI_GetStringWidth(wm_drag_name(drag)); int w = UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x+w, y+16); drag_rect_minmax(rect, x, y, x + w, y + 16);
} }
else { else {
glColor4ub(255, 255, 255, 255); glColor4ub(255, 255, 255, 255);
@@ -353,17 +353,17 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
/* operator name with roundbox */ /* operator name with roundbox */
if (drag->opname[0]) { if (drag->opname[0]) {
if (drag->imb) { if (drag->imb) {
x= cursorx - drag->sx/2; x = cursorx - drag->sx / 2;
y= cursory + drag->sy/2 + 4; y = cursory + drag->sy / 2 + 4;
} }
else { else {
x= cursorx - 8; x = cursorx - 8;
y= cursory + 16; y = cursory + 16;
} }
if (rect) { if (rect) {
int w= UI_GetStringWidth(wm_drag_name(drag)); int w = UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x+w, y+16); drag_rect_minmax(rect, x, y, x + w, y + 16);
} }
else else
wm_drop_operator_draw(drag->opname, x, y); wm_drop_operator_draw(drag->opname, x, y);

View File

@@ -66,27 +66,27 @@
#include "wm_event_system.h" #include "wm_event_system.h"
/* swap */ /* swap */
#define WIN_NONE_OK 0 #define WIN_NONE_OK 0
#define WIN_BACK_OK 1 #define WIN_BACK_OK 1
#define WIN_FRONT_OK 2 #define WIN_FRONT_OK 2
#define WIN_BOTH_OK 3 #define WIN_BOTH_OK 3
/* ******************* drawing, overlays *************** */ /* ******************* drawing, overlays *************** */
static void wm_paintcursor_draw(bContext *C, ARegion *ar) static void wm_paintcursor_draw(bContext *C, ARegion *ar)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
if (wm->paintcursors.first) { if (wm->paintcursors.first) {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
bScreen *screen= win->screen; bScreen *screen = win->screen;
wmPaintCursor *pc; wmPaintCursor *pc;
if (screen->subwinactive == ar->swinid) { if (screen->subwinactive == ar->swinid) {
for (pc= wm->paintcursors.first; pc; pc= pc->next) { for (pc = wm->paintcursors.first; pc; pc = pc->next) {
if (pc->poll == NULL || pc->poll(C)) { if (pc->poll == NULL || pc->poll(C)) {
ARegion *ar_other= CTX_wm_region(C); ARegion *ar_other = CTX_wm_region(C);
if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
int x = 0, y = 0; int x = 0, y = 0;
wm_get_cursor_position(win, &x, &y); wm_get_cursor_position(win, &x, &y);
@@ -112,13 +112,13 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
static void wm_area_mark_invalid_backbuf(ScrArea *sa) static void wm_area_mark_invalid_backbuf(ScrArea *sa)
{ {
if (sa->spacetype == SPACE_VIEW3D) if (sa->spacetype == SPACE_VIEW3D)
((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF; ((View3D *)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF;
} }
static int wm_area_test_invalid_backbuf(ScrArea *sa) static int wm_area_test_invalid_backbuf(ScrArea *sa)
{ {
if (sa->spacetype == SPACE_VIEW3D) if (sa->spacetype == SPACE_VIEW3D)
return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF); return (((View3D *)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
else else
return 1; return 1;
} }
@@ -127,7 +127,7 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
{ {
if (sa->spacetype == SPACE_VIEW3D) { if (sa->spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = ar->regiondata; RegionView3D *rv3d = ar->regiondata;
RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL; RenderEngine *engine = (rv3d) ? rv3d->render_engine : NULL;
if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) { if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
ar->do_draw = 1; ar->do_draw = 1;
@@ -141,15 +141,15 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
static void wm_method_draw_full(bContext *C, wmWindow *win) static void wm_method_draw_full(bContext *C, wmWindow *win)
{ {
bScreen *screen= win->screen; bScreen *screen = win->screen;
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
/* draw area regions */ /* draw area regions */
for (sa= screen->areabase.first; sa; sa= sa->next) { for (sa = screen->areabase.first; sa; sa = sa->next) {
CTX_wm_area_set(C, sa); CTX_wm_area_set(C, sa);
for (ar=sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) { if (ar->swinid) {
CTX_wm_region_set(C, ar); CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar); ED_region_do_draw(C, ar);
@@ -167,7 +167,7 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
ED_area_overdraw(C); ED_area_overdraw(C);
/* draw overlapping regions */ /* draw overlapping regions */
for (ar=screen->regionbase.first; ar; ar= ar->next) { for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) { if (ar->swinid) {
CTX_wm_menu_set(C, ar); CTX_wm_menu_set(C, ar);
ED_region_do_draw(C, ar); ED_region_do_draw(C, ar);
@@ -191,12 +191,12 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
for (sa= screen->areabase.first; sa; sa= sa->next) { for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar= sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) { if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
ar->do_draw= RGN_DRAW; ar->do_draw = RGN_DRAW;
memset(&ar->drawrct, 0, sizeof(ar->drawrct)); memset(&ar->drawrct, 0, sizeof(ar->drawrct));
ar->swap= WIN_NONE_OK; ar->swap = WIN_NONE_OK;
} }
} }
} }
@@ -207,50 +207,50 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
{ {
ARegion *ar; ARegion *ar;
for (ar= screen->regionbase.first; ar; ar= ar->next) { for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) { if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
ar->do_draw= RGN_DRAW; ar->do_draw = RGN_DRAW;
memset(&ar->drawrct, 0, sizeof(ar->drawrct)); memset(&ar->drawrct, 0, sizeof(ar->drawrct));
ar->swap= WIN_NONE_OK; ar->swap = WIN_NONE_OK;
} }
} }
} }
static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen= win->screen; bScreen *screen = win->screen;
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
static rcti rect= {0, 0, 0, 0}; static rcti rect = {0, 0, 0, 0};
/* after backbuffer selection draw, we need to redraw */ /* after backbuffer selection draw, we need to redraw */
for (sa= screen->areabase.first; sa; sa= sa->next) for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar= sa->regionbase.first; ar; ar= ar->next) for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->swinid && !wm_area_test_invalid_backbuf(sa)) if (ar->swinid && !wm_area_test_invalid_backbuf(sa))
ED_region_tag_redraw(ar); ED_region_tag_redraw(ar);
/* flush overlapping regions */ /* flush overlapping regions */
if (screen->regionbase.first) { if (screen->regionbase.first) {
/* flush redraws of area regions up to overlapping regions */ /* flush redraws of area regions up to overlapping regions */
for (sa= screen->areabase.first; sa; sa= sa->next) for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar= sa->regionbase.first; ar; ar= ar->next) for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->swinid && ar->do_draw) if (ar->swinid && ar->do_draw)
wm_flush_regions_up(screen, &ar->winrct); wm_flush_regions_up(screen, &ar->winrct);
/* flush between overlapping regions */ /* flush between overlapping regions */
for (ar= screen->regionbase.last; ar; ar= ar->prev) for (ar = screen->regionbase.last; ar; ar = ar->prev)
if (ar->swinid && ar->do_draw) if (ar->swinid && ar->do_draw)
wm_flush_regions_up(screen, &ar->winrct); wm_flush_regions_up(screen, &ar->winrct);
/* flush redraws of overlapping regions down to area regions */ /* flush redraws of overlapping regions down to area regions */
for (ar= screen->regionbase.last; ar; ar= ar->prev) for (ar = screen->regionbase.last; ar; ar = ar->prev)
if (ar->swinid && ar->do_draw) if (ar->swinid && ar->do_draw)
wm_flush_regions_down(screen, &ar->winrct); wm_flush_regions_down(screen, &ar->winrct);
} }
/* flush drag item */ /* flush drag item */
if (rect.xmin!=rect.xmax) { if (rect.xmin != rect.xmax) {
wm_flush_regions_down(screen, &rect); wm_flush_regions_down(screen, &rect);
rect.xmin = rect.xmax = 0; rect.xmin = rect.xmax = 0;
} }
@@ -260,10 +260,10 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
} }
/* draw marked area regions */ /* draw marked area regions */
for (sa= screen->areabase.first; sa; sa= sa->next) { for (sa = screen->areabase.first; sa; sa = sa->next) {
CTX_wm_area_set(C, sa); CTX_wm_area_set(C, sa);
for (ar=sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) { if (ar->swinid) {
if (ar->do_draw) { if (ar->do_draw) {
CTX_wm_region_set(C, ar); CTX_wm_region_set(C, ar);
@@ -273,7 +273,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
CTX_wm_region_set(C, NULL); CTX_wm_region_set(C, NULL);
if (exchange) if (exchange)
ar->swap= WIN_FRONT_OK; ar->swap = WIN_FRONT_OK;
} }
else if (exchange) { else if (exchange) {
if (ar->swap == WIN_FRONT_OK) { if (ar->swap == WIN_FRONT_OK) {
@@ -283,12 +283,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
ED_area_overdraw_flush(sa, ar); ED_area_overdraw_flush(sa, ar);
CTX_wm_region_set(C, NULL); CTX_wm_region_set(C, NULL);
ar->swap= WIN_BOTH_OK; ar->swap = WIN_BOTH_OK;
} }
else if (ar->swap == WIN_BACK_OK) else if (ar->swap == WIN_BACK_OK)
ar->swap= WIN_FRONT_OK; ar->swap = WIN_FRONT_OK;
else if (ar->swap == WIN_BOTH_OK) else if (ar->swap == WIN_BOTH_OK)
ar->swap= WIN_BOTH_OK; ar->swap = WIN_BOTH_OK;
} }
} }
} }
@@ -302,23 +302,23 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
ED_screen_draw(win); ED_screen_draw(win);
if (exchange) if (exchange)
screen->swap= WIN_FRONT_OK; screen->swap = WIN_FRONT_OK;
} }
else if (exchange) { else if (exchange) {
if (screen->swap==WIN_FRONT_OK) { if (screen->swap == WIN_FRONT_OK) {
ED_screen_draw(win); ED_screen_draw(win);
screen->swap= WIN_BOTH_OK; screen->swap = WIN_BOTH_OK;
} }
else if (screen->swap==WIN_BACK_OK) else if (screen->swap == WIN_BACK_OK)
screen->swap= WIN_FRONT_OK; screen->swap = WIN_FRONT_OK;
else if (screen->swap==WIN_BOTH_OK) else if (screen->swap == WIN_BOTH_OK)
screen->swap= WIN_BOTH_OK; screen->swap = WIN_BOTH_OK;
} }
ED_area_overdraw(C); ED_area_overdraw(C);
/* draw marked overlapping regions */ /* draw marked overlapping regions */
for (ar=screen->regionbase.first; ar; ar= ar->next) { for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid && ar->do_draw) { if (ar->swinid && ar->do_draw) {
CTX_wm_menu_set(C, ar); CTX_wm_menu_set(C, ar);
ED_region_do_draw(C, ar); ED_region_do_draw(C, ar);
@@ -357,7 +357,7 @@ static void wm_method_draw_damage(bContext *C, wmWindow *win)
#define MAX_N_TEX 3 #define MAX_N_TEX 3
typedef struct wmDrawTriple { typedef struct wmDrawTriple {
GLuint bind[MAX_N_TEX*MAX_N_TEX]; GLuint bind[MAX_N_TEX * MAX_N_TEX];
int x[MAX_N_TEX], y[MAX_N_TEX]; int x[MAX_N_TEX], y[MAX_N_TEX];
int nx, ny; int nx, ny;
GLenum target; GLenum target;
@@ -369,46 +369,46 @@ static void split_width(int x, int n, int *splitx, int *nx)
/* if already power of two just use it */ /* if already power of two just use it */
if (is_power_of_2_i(x)) { if (is_power_of_2_i(x)) {
splitx[0]= x; splitx[0] = x;
(*nx)++; (*nx)++;
return; return;
} }
if (n == 1) { if (n == 1) {
/* last part, we have to go larger */ /* last part, we have to go larger */
splitx[0]= power_of_2_max_i(x); splitx[0] = power_of_2_max_i(x);
(*nx)++; (*nx)++;
} }
else { else {
/* two or more parts to go, use smaller part */ /* two or more parts to go, use smaller part */
splitx[0]= power_of_2_min_i(x); splitx[0] = power_of_2_min_i(x);
newnx= ++(*nx); newnx = ++(*nx);
split_width(x-splitx[0], n-1, splitx+1, &newnx); split_width(x - splitx[0], n - 1, splitx + 1, &newnx);
for (waste=0, a=0; a<n; a++) for (waste = 0, a = 0; a < n; a++)
waste += splitx[a]; waste += splitx[a];
/* if we waste more space or use the same amount, /* if we waste more space or use the same amount,
* revert deeper splits and just use larger */ * revert deeper splits and just use larger */
if (waste >= power_of_2_max_i(x)) { if (waste >= power_of_2_max_i(x)) {
splitx[0]= power_of_2_max_i(x); splitx[0] = power_of_2_max_i(x);
memset(splitx+1, 0, sizeof(int)*(n-1)); memset(splitx + 1, 0, sizeof(int) * (n - 1));
} }
else else
*nx= newnx; *nx = newnx;
} }
} }
static void wm_draw_triple_free(wmWindow *win) static void wm_draw_triple_free(wmWindow *win)
{ {
if (win->drawdata) { if (win->drawdata) {
wmDrawTriple *triple= win->drawdata; wmDrawTriple *triple = win->drawdata;
glDeleteTextures(triple->nx*triple->ny, triple->bind); glDeleteTextures(triple->nx * triple->ny, triple->bind);
MEM_freeN(triple); MEM_freeN(triple);
win->drawdata= NULL; win->drawdata = NULL;
} }
} }
@@ -416,7 +416,7 @@ static void wm_draw_triple_fail(bContext *C, wmWindow *win)
{ {
wm_draw_window_clear(win); wm_draw_window_clear(win);
win->drawfail= 1; win->drawfail = 1;
wm_method_draw_overlap_all(C, win, 0); wm_method_draw_overlap_all(C, win, 0);
} }
@@ -427,29 +427,29 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
/* compute texture sizes */ /* compute texture sizes */
if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) { if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) {
triple->target= GL_TEXTURE_RECTANGLE_ARB; triple->target = GL_TEXTURE_RECTANGLE_ARB;
triple->nx= 1; triple->nx = 1;
triple->ny= 1; triple->ny = 1;
triple->x[0]= win->sizex; triple->x[0] = win->sizex;
triple->y[0]= win->sizey; triple->y[0] = win->sizey;
} }
else if (GPU_non_power_of_two_support()) { else if (GPU_non_power_of_two_support()) {
triple->target= GL_TEXTURE_2D; triple->target = GL_TEXTURE_2D;
triple->nx= 1; triple->nx = 1;
triple->ny= 1; triple->ny = 1;
triple->x[0]= win->sizex; triple->x[0] = win->sizex;
triple->y[0]= win->sizey; triple->y[0] = win->sizey;
} }
else { else {
triple->target= GL_TEXTURE_2D; triple->target = GL_TEXTURE_2D;
triple->nx= 0; triple->nx = 0;
triple->ny= 0; triple->ny = 0;
split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx); split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx);
split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny); split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny);
} }
/* generate texture names */ /* generate texture names */
glGenTextures(triple->nx*triple->ny, triple->bind); glGenTextures(triple->nx * triple->ny, triple->bind);
if (!triple->bind[0]) { if (!triple->bind[0]) {
/* not the typical failure case but we handle it anyway */ /* not the typical failure case but we handle it anyway */
@@ -457,8 +457,8 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
return 0; return 0;
} }
for (y=0; y<triple->ny; y++) { for (y = 0; y < triple->ny; y++) {
for (x=0; x<triple->nx; x++) { for (x = 0; x < triple->nx; x++) {
/* proxy texture is only guaranteed to test for the cases that /* proxy texture is only guaranteed to test for the cases that
* there is only one texture in use, which may not be the case */ * there is only one texture in use, which may not be the case */
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
@@ -471,7 +471,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
} }
/* setup actual texture */ /* setup actual texture */
glBindTexture(triple->target, triple->bind[x + y*triple->nx]); glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -497,16 +497,16 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
glEnable(triple->target); glEnable(triple->target);
for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) { for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) { for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x]; sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y]; sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
/* wmOrtho for the screen has this same offset */ /* wmOrtho for the screen has this same offset */
ratiox= sizex; ratiox = sizex;
ratioy= sizey; ratioy = sizey;
halfx= 0.375f; halfx = 0.375f;
halfy= 0.375f; halfy = 0.375f;
/* texture rectangle has unnormalized coordinates */ /* texture rectangle has unnormalized coordinates */
if (triple->target == GL_TEXTURE_2D) { if (triple->target == GL_TEXTURE_2D) {
@@ -516,21 +516,21 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
halfy /= triple->y[y]; halfy /= triple->y[y];
} }
glBindTexture(triple->target, triple->bind[x + y*triple->nx]); glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glColor3f(1.0f, 1.0f, 1.0f); glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(halfx, halfy); glTexCoord2f(halfx, halfy);
glVertex2f(offx, offy); glVertex2f(offx, offy);
glTexCoord2f(ratiox+halfx, halfy); glTexCoord2f(ratiox + halfx, halfy);
glVertex2f(offx+sizex, offy); glVertex2f(offx + sizex, offy);
glTexCoord2f(ratiox+halfx, ratioy+halfy); glTexCoord2f(ratiox + halfx, ratioy + halfy);
glVertex2f(offx+sizex, offy+sizey); glVertex2f(offx + sizex, offy + sizey);
glTexCoord2f(halfx, ratioy+halfy); glTexCoord2f(halfx, ratioy + halfy);
glVertex2f(offx, offy+sizey); glVertex2f(offx, offy + sizey);
glEnd(); glEnd();
} }
} }
@@ -543,12 +543,12 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
{ {
int x, y, sizex, sizey, offx, offy; int x, y, sizex, sizey, offx, offy;
for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) { for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) { for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x]; sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y]; sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
glBindTexture(triple->target, triple->bind[x + y*triple->nx]); glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey); glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey);
} }
} }
@@ -558,23 +558,23 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
static void wm_method_draw_triple(bContext *C, wmWindow *win) static void wm_method_draw_triple(bContext *C, wmWindow *win)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmDrawTriple *triple; wmDrawTriple *triple;
bScreen *screen= win->screen; bScreen *screen = win->screen;
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
int copytex= 0, paintcursor= 1; int copytex = 0, paintcursor = 1;
if (win->drawdata) { if (win->drawdata) {
glClearColor(0, 0, 0, 0); glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
wmSubWindowSet(win, screen->mainwin); wmSubWindowSet(win, screen->mainwin);
wm_triple_draw_textures(win, win->drawdata); wm_triple_draw_textures(win, win->drawdata);
} }
else { else {
win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
if (!wm_triple_gen_textures(win, win->drawdata)) { if (!wm_triple_gen_textures(win, win->drawdata)) {
wm_draw_triple_fail(C, win); wm_draw_triple_fail(C, win);
@@ -582,19 +582,19 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
} }
} }
triple= win->drawdata; triple = win->drawdata;
/* draw marked area regions */ /* draw marked area regions */
for (sa= screen->areabase.first; sa; sa= sa->next) { for (sa = screen->areabase.first; sa; sa = sa->next) {
CTX_wm_area_set(C, sa); CTX_wm_area_set(C, sa);
for (ar=sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid && ar->do_draw) { if (ar->swinid && ar->do_draw) {
CTX_wm_region_set(C, ar); CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar); ED_region_do_draw(C, ar);
ED_area_overdraw_flush(sa, ar); ED_area_overdraw_flush(sa, ar);
CTX_wm_region_set(C, NULL); CTX_wm_region_set(C, NULL);
copytex= 1; copytex = 1;
} }
} }
@@ -613,13 +613,13 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
ED_screen_draw(win); ED_screen_draw(win);
/* draw overlapping regions */ /* draw overlapping regions */
for (ar=screen->regionbase.first; ar; ar= ar->next) { for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) { if (ar->swinid) {
CTX_wm_menu_set(C, ar); CTX_wm_menu_set(C, ar);
ED_region_do_draw(C, ar); ED_region_do_draw(C, ar);
CTX_wm_menu_set(C, NULL); CTX_wm_menu_set(C, NULL);
/* when a menu is being drawn, don't do the paint cursors */ /* when a menu is being drawn, don't do the paint cursors */
paintcursor= 0; paintcursor = 0;
} }
} }
@@ -628,8 +628,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
wm_gesture_draw(win); wm_gesture_draw(win);
if (paintcursor && wm->paintcursors.first) { if (paintcursor && wm->paintcursors.first) {
for (sa= screen->areabase.first; sa; sa= sa->next) { for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar=sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid == screen->subwinactive) { if (ar->swinid == screen->subwinactive) {
CTX_wm_area_set(C, sa); CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar); CTX_wm_region_set(C, ar);
@@ -661,19 +661,19 @@ static int wm_draw_update_test_window(wmWindow *win)
{ {
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
int do_draw= 0; int do_draw = 0;
for (ar= win->screen->regionbase.first; ar; ar= ar->next) { for (ar = win->screen->regionbase.first; ar; ar = ar->next) {
if (ar->do_draw_overlay) { if (ar->do_draw_overlay) {
wm_tag_redraw_overlay(win, ar); wm_tag_redraw_overlay(win, ar);
ar->do_draw_overlay= 0; ar->do_draw_overlay = 0;
} }
if (ar->swinid && ar->do_draw) if (ar->swinid && ar->do_draw)
do_draw= 1; do_draw = 1;
} }
for (sa= win->screen->areabase.first; sa; sa= sa->next) { for (sa = win->screen->areabase.first; sa; sa = sa->next) {
for (ar=sa->regionbase.first; ar; ar= ar->next) { for (ar = sa->regionbase.first; ar; ar = ar->next) {
wm_region_test_render_do_draw(sa, ar); wm_region_test_render_do_draw(sa, ar);
if (ar->swinid && ar->do_draw) if (ar->swinid && ar->do_draw)
@@ -737,22 +737,22 @@ void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
if (ar && win) { if (ar && win) {
if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE)
ED_region_tag_redraw(ar); ED_region_tag_redraw(ar);
win->screen->do_draw_paintcursor= 1; win->screen->do_draw_paintcursor = 1;
} }
} }
void wm_draw_update(bContext *C) void wm_draw_update(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win; wmWindow *win;
int drawmethod; int drawmethod;
GPU_free_unused_buffers(); GPU_free_unused_buffers();
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
if (win->drawmethod != U.wmdrawmethod) { if (win->drawmethod != U.wmdrawmethod) {
wm_draw_window_clear(win); wm_draw_window_clear(win);
win->drawmethod= U.wmdrawmethod; win->drawmethod = U.wmdrawmethod;
} }
if (wm_draw_update_test_window(win)) { if (wm_draw_update_test_window(win)) {
@@ -765,7 +765,7 @@ void wm_draw_update(bContext *C)
if (win->screen->do_refresh) if (win->screen->do_refresh)
ED_screen_refresh(wm, win); ED_screen_refresh(wm, win);
drawmethod= wm_automatic_draw_method(win); drawmethod = wm_automatic_draw_method(win);
if (win->drawfail) if (win->drawfail)
wm_method_draw_overlap_all(C, win, 0); wm_method_draw_overlap_all(C, win, 0);
@@ -778,9 +778,9 @@ void wm_draw_update(bContext *C)
else // if (drawmethod == USER_DRAW_TRIPLE) else // if (drawmethod == USER_DRAW_TRIPLE)
wm_method_draw_triple(C, win); wm_method_draw_triple(C, win);
win->screen->do_draw_gesture= 0; win->screen->do_draw_gesture = 0;
win->screen->do_draw_paintcursor= 0; win->screen->do_draw_paintcursor = 0;
win->screen->do_draw_drag= 0; win->screen->do_draw_drag = 0;
wm_window_swap_buffers(win); wm_window_swap_buffers(win);
@@ -791,39 +791,39 @@ void wm_draw_update(bContext *C)
void wm_draw_window_clear(wmWindow *win) void wm_draw_window_clear(wmWindow *win)
{ {
bScreen *screen= win->screen; bScreen *screen = win->screen;
ScrArea *sa; ScrArea *sa;
ARegion *ar; ARegion *ar;
int drawmethod= wm_automatic_draw_method(win); int drawmethod = wm_automatic_draw_method(win);
if (drawmethod == USER_DRAW_TRIPLE) if (drawmethod == USER_DRAW_TRIPLE)
wm_draw_triple_free(win); wm_draw_triple_free(win);
/* clear screen swap flags */ /* clear screen swap flags */
if (screen) { if (screen) {
for (sa= screen->areabase.first; sa; sa= sa->next) for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar=sa->regionbase.first; ar; ar= ar->next) for (ar = sa->regionbase.first; ar; ar = ar->next)
ar->swap= WIN_NONE_OK; ar->swap = WIN_NONE_OK;
screen->swap= WIN_NONE_OK; screen->swap = WIN_NONE_OK;
} }
} }
void wm_draw_region_clear(wmWindow *win, ARegion *ar) void wm_draw_region_clear(wmWindow *win, ARegion *ar)
{ {
int drawmethod= wm_automatic_draw_method(win); int drawmethod = wm_automatic_draw_method(win);
if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
wm_flush_regions_down(win->screen, &ar->winrct); wm_flush_regions_down(win->screen, &ar->winrct);
win->screen->do_draw= 1; win->screen->do_draw = 1;
} }
void WM_redraw_windows(bContext *C) void WM_redraw_windows(bContext *C)
{ {
wmWindow *win_prev= CTX_wm_window(C); wmWindow *win_prev = CTX_wm_window(C);
ScrArea *area_prev= CTX_wm_area(C); ScrArea *area_prev = CTX_wm_area(C);
ARegion *ar_prev= CTX_wm_region(C); ARegion *ar_prev = CTX_wm_region(C);
wm_draw_update(C); wm_draw_update(C);

File diff suppressed because it is too large Load Diff

View File

@@ -28,9 +28,9 @@
*/ */
/* placed up here because of crappy /* placed up here because of crappy
* winsock stuff. * winsock stuff.
*/ */
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -131,20 +131,20 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
wmWindowManager *wm; wmWindowManager *wm;
wmWindow *win, *active_win; wmWindow *win, *active_win;
*wmlist= G.main->wm; *wmlist = G.main->wm;
G.main->wm.first= G.main->wm.last= NULL; G.main->wm.first = G.main->wm.last = NULL;
active_win = CTX_wm_window(C); active_win = CTX_wm_window(C);
/* first wrap up running stuff */ /* first wrap up running stuff */
/* code copied from wm_init_exit.c */ /* code copied from wm_init_exit.c */
for (wm= wmlist->first; wm; wm= wm->id.next) { for (wm = wmlist->first; wm; wm = wm->id.next) {
WM_jobs_stop_all(wm); WM_jobs_stop_all(wm);
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
CTX_wm_window_set(C, win); /* needed by operator close callbacks */ CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers); WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, win->screen); ED_screen_exit(C, win, win->screen);
@@ -158,13 +158,13 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
/* just had return; here from r12991, this code could just get removed?*/ /* just had return; here from r12991, this code could just get removed?*/
#if 0 #if 0
if (wm==NULL) return; if (wm == NULL) return;
if (G.fileflags & G_FILE_NO_UI) return; if (G.fileflags & G_FILE_NO_UI) return;
/* we take apart the used screens from non-active window */ /* we take apart the used screens from non-active window */
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME); BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
if (win!=wm->winactive) { if (win != wm->winactive) {
BLI_remlink(&G.main->screen, win->screen); BLI_remlink(&G.main->screen, win->screen);
//BLI_addtail(screenbase, win->screen); //BLI_addtail(screenbase, win->screen);
} }
@@ -185,8 +185,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
wmWindow *oldwin, *win; wmWindow *oldwin, *win;
/* cases 1 and 2 */ /* cases 1 and 2 */
if (oldwmlist->first==NULL) { if (oldwmlist->first == NULL) {
if (G.main->wm.first); /* nothing todo */ if (G.main->wm.first) ; /* nothing todo */
else else
wm_add_default(C); wm_add_default(C);
} }
@@ -194,29 +194,29 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* cases 3 and 4 */ /* cases 3 and 4 */
/* we've read file without wm..., keep current one entirely alive */ /* we've read file without wm..., keep current one entirely alive */
if (G.main->wm.first==NULL) { if (G.main->wm.first == NULL) {
bScreen *screen= NULL; bScreen *screen = NULL;
/* when loading without UI, no matching needed */ /* when loading without UI, no matching needed */
if (!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) { if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) {
/* match oldwm to new dbase, only old files */ /* match oldwm to new dbase, only old files */
for (wm= oldwmlist->first; wm; wm= wm->id.next) { for (wm = oldwmlist->first; wm; wm = wm->id.next) {
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
/* all windows get active screen from file */ /* all windows get active screen from file */
if (screen->winid==0) if (screen->winid == 0)
win->screen= screen; win->screen = screen;
else else
win->screen= ED_screen_duplicate(win, screen); win->screen = ED_screen_duplicate(win, screen);
BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname)); BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
win->screen->winid= win->winid; win->screen->winid = win->winid;
} }
} }
} }
G.main->wm= *oldwmlist; G.main->wm = *oldwmlist;
/* screens were read from file! */ /* screens were read from file! */
ED_screens_initialize(G.main->wm.first); ED_screens_initialize(G.main->wm.first);
@@ -224,47 +224,47 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
else { else {
/* what if old was 3, and loaded 1? */ /* what if old was 3, and loaded 1? */
/* this code could move to setup_appdata */ /* this code could move to setup_appdata */
oldwm= oldwmlist->first; oldwm = oldwmlist->first;
wm= G.main->wm.first; wm = G.main->wm.first;
/* preserve key configurations in new wm, to preserve their keymaps */ /* preserve key configurations in new wm, to preserve their keymaps */
wm->keyconfigs= oldwm->keyconfigs; wm->keyconfigs = oldwm->keyconfigs;
wm->addonconf= oldwm->addonconf; wm->addonconf = oldwm->addonconf;
wm->defaultconf= oldwm->defaultconf; wm->defaultconf = oldwm->defaultconf;
wm->userconf= oldwm->userconf; wm->userconf = oldwm->userconf;
oldwm->keyconfigs.first= oldwm->keyconfigs.last= NULL; oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL;
oldwm->addonconf= NULL; oldwm->addonconf = NULL;
oldwm->defaultconf= NULL; oldwm->defaultconf = NULL;
oldwm->userconf= NULL; oldwm->userconf = NULL;
/* ensure making new keymaps and set space types */ /* ensure making new keymaps and set space types */
wm->initialized= 0; wm->initialized = 0;
wm->winactive= NULL; wm->winactive = NULL;
/* only first wm in list has ghostwins */ /* only first wm in list has ghostwins */
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
for (oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) { for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
if (oldwin->winid == win->winid ) { if (oldwin->winid == win->winid) {
win->ghostwin= oldwin->ghostwin; win->ghostwin = oldwin->ghostwin;
win->active= oldwin->active; win->active = oldwin->active;
if (win->active) if (win->active)
wm->winactive= win; wm->winactive = win;
if (!G.background) /* file loading in background mode still calls this */ if (!G.background) /* file loading in background mode still calls this */
GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */
oldwin->ghostwin= NULL; oldwin->ghostwin = NULL;
win->eventstate= oldwin->eventstate; win->eventstate = oldwin->eventstate;
oldwin->eventstate= NULL; oldwin->eventstate = NULL;
/* ensure proper screen rescaling */ /* ensure proper screen rescaling */
win->sizex= oldwin->sizex; win->sizex = oldwin->sizex;
win->sizey= oldwin->sizey; win->sizey = oldwin->sizey;
win->posx= oldwin->posx; win->posx = oldwin->posx;
win->posy= oldwin->posy; win->posy = oldwin->posy;
} }
} }
} }
@@ -281,14 +281,14 @@ static void wm_init_userdef(bContext *C)
sound_init(CTX_data_main(C)); sound_init(CTX_data_main(C));
/* needed so loading a file from the command line respects user-pref [#26156] */ /* needed so loading a file from the command line respects user-pref [#26156] */
if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI; if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI;
else G.fileflags &= ~G_FILE_NO_UI; else G.fileflags &= ~G_FILE_NO_UI;
/* set the python auto-execute setting from user prefs */ /* set the python auto-execute setting from user prefs */
/* enabled by default, unless explicitly enabled in the command line which overrides */ /* enabled by default, unless explicitly enabled in the command line which overrides */
if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) { if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC;
else G.f &= ~G_SCRIPT_AUTOEXEC; else G.f &= ~G_SCRIPT_AUTOEXEC;
} }
/* update tempdir from user preferences */ /* update tempdir from user preferences */
@@ -298,11 +298,11 @@ static void wm_init_userdef(bContext *C)
/* return codes */ /* return codes */
#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ #define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */
#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ #define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */
#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ #define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */
#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ #define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */
#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ #define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */
/* intended to check for non-blender formats but for now it only reads blends */ /* intended to check for non-blender formats but for now it only reads blends */
@@ -315,32 +315,32 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name)
// make sure we're not trying to read a directory.... // make sure we're not trying to read a directory....
len= strlen(name); len = strlen(name);
if (ELEM(name[len-1], '/', '\\')) { if (ELEM(name[len - 1], '/', '\\')) {
retval= BKE_READ_EXOTIC_FAIL_PATH; retval = BKE_READ_EXOTIC_FAIL_PATH;
} }
else { else {
gzfile = BLI_gzopen(name,"rb"); gzfile = BLI_gzopen(name, "rb");
if (gzfile == NULL) { if (gzfile == NULL) {
retval= BKE_READ_EXOTIC_FAIL_OPEN; retval = BKE_READ_EXOTIC_FAIL_OPEN;
} }
else { else {
len= gzread(gzfile, header, sizeof(header)); len = gzread(gzfile, header, sizeof(header));
gzclose(gzfile); gzclose(gzfile);
if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) {
retval= BKE_READ_EXOTIC_OK_BLEND; retval = BKE_READ_EXOTIC_OK_BLEND;
} }
else { else {
//XXX waitcursor(1); //XXX waitcursor(1);
#if 0 /* historic stuff - no longer used */ #if 0 /* historic stuff - no longer used */
if (is_foo_format(name)) { if (is_foo_format(name)) {
read_foo(name); read_foo(name);
retval= BKE_READ_EXOTIC_OK_OTHER; retval = BKE_READ_EXOTIC_OK_OTHER;
} }
else else
#endif #endif
{ {
retval= BKE_READ_EXOTIC_FAIL_FORMAT; retval = BKE_READ_EXOTIC_FAIL_FORMAT;
} }
//XXX waitcursor(0); //XXX waitcursor(0);
} }
@@ -364,25 +364,25 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
/* first try to append data from exotic file formats... */ /* first try to append data from exotic file formats... */
/* it throws error box when file doesn't exist and returns -1 */ /* it throws error box when file doesn't exist and returns -1 */
/* note; it should set some error message somewhere... (ton) */ /* note; it should set some error message somewhere... (ton) */
retval= wm_read_exotic(CTX_data_scene(C), filepath); retval = wm_read_exotic(CTX_data_scene(C), filepath);
/* we didn't succeed, now try to read Blender file */ /* we didn't succeed, now try to read Blender file */
if (retval == BKE_READ_EXOTIC_OK_BLEND) { if (retval == BKE_READ_EXOTIC_OK_BLEND) {
int G_f= G.f; int G_f = G.f;
ListBase wmbase; ListBase wmbase;
/* put aside screens to match with persistent windows later */ /* put aside screens to match with persistent windows later */
/* also exit screens and editors */ /* also exit screens and editors */
wm_window_match_init(C, &wmbase); wm_window_match_init(C, &wmbase);
retval= BKE_read_file(C, filepath, reports); retval = BKE_read_file(C, filepath, reports);
G.save_over = 1; G.save_over = 1;
/* this flag is initialized by the operator but overwritten on read. /* this flag is initialized by the operator but overwritten on read.
* need to re-enable it here else drivers + registered scripts wont work. */ * need to re-enable it here else drivers + registered scripts wont work. */
if (G.f != G_f) { if (G.f != G_f) {
const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); const int flags_keep = (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
G.f= (G.f & ~flags_keep) | (G_f & flags_keep); G.f = (G.f & ~flags_keep) | (G_f & flags_keep);
} }
/* match the read WM with current WM */ /* match the read WM with current WM */
@@ -403,7 +403,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
} }
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL);
// refresh_interface_font(); // refresh_interface_font();
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
@@ -434,14 +434,14 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
/* TODO, make this show in header info window */ /* TODO, make this show in header info window */
{ {
Scene *sce; Scene *sce;
for (sce= G.main->scene.first; sce; sce= sce->id.next) { for (sce = G.main->scene.first; sce; sce = sce->id.next) {
if (sce->r.engine[0] && if (sce->r.engine[0] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL) BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{ {
BKE_reportf(reports, RPT_WARNING, BKE_reportf(reports, RPT_WARNING,
"Engine not available: '%s' for scene: %s, " "Engine not available: '%s' for scene: %s, "
"an addon may need to be installed or enabled", "an addon may need to be installed or enabled",
sce->r.engine, sce->id.name+2); sce->r.engine, sce->id.name + 2);
} }
} }
} }
@@ -449,13 +449,13 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
// XXX undo_editmode_clear(); // XXX undo_editmode_clear();
BKE_reset_undo(); BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */ BKE_write_undo(C, "original"); /* save current state */
} }
else if (retval == BKE_READ_EXOTIC_OK_OTHER) else if (retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file"); BKE_write_undo(C, "Import file");
else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) { else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) {
BKE_reportf(reports, RPT_ERROR, IFACE_("Can't read file: \"%s\", %s."), filepath, BKE_reportf(reports, RPT_ERROR, IFACE_("Can't read file: \"%s\", %s."), filepath,
errno ? strerror(errno) : IFACE_("Unable to open the file")); errno ? strerror(errno) : IFACE_("Unable to open the file"));
} }
else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) { else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath); BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath);
@@ -480,7 +480,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
{ {
ListBase wmbase; ListBase wmbase;
char tstr[FILE_MAX]; char tstr[FILE_MAX];
int success= 0; int success = 0;
free_ttfont(); /* still weird... what does it here? */ free_ttfont(); /* still weird... what does it here? */
@@ -505,12 +505,12 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
if (!from_memory && BLI_exists(tstr)) { if (!from_memory && BLI_exists(tstr)) {
success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL); success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
if (U.themes.first==NULL) { if (U.themes.first == NULL) {
printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n"); printf("\nError: No valid "STRINGIFY (BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
success = 0; success = 0;
} }
} }
if (success==0) { if (success == 0) {
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL); success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
if (wmbase.first == NULL) wm_clear_default_size(C); if (wmbase.first == NULL) wm_clear_default_size(C);
@@ -532,21 +532,21 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
wm_window_match_do(C, &wmbase); wm_window_match_do(C, &wmbase);
WM_check(C); /* opens window(s), checks keymaps */ WM_check(C); /* opens window(s), checks keymaps */
G.main->name[0]= '\0'; G.main->name[0] = '\0';
/* When loading factory settings, the reset solid OpenGL lights need to be applied. */ /* When loading factory settings, the reset solid OpenGL lights need to be applied. */
if (!G.background) GPU_default_lights(); if (!G.background) GPU_default_lights();
/* XXX */ /* XXX */
G.save_over = 0; // start with save preference untitled.blend G.save_over = 0; // start with save preference untitled.blend
G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */
// mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender"
// refresh_interface_font(); // refresh_interface_font();
// undo_editmode_clear(); // undo_editmode_clear();
BKE_reset_undo(); BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */ BKE_write_undo(C, "original"); /* save current state */
ED_editors_init(C); ED_editors_init(C);
DAG_on_visible_update(CTX_data_main(C), TRUE); DAG_on_visible_update(CTX_data_main(C), TRUE);
@@ -562,7 +562,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
} }
#endif #endif
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL);
/* in background mode the scene will stay NULL */ /* in background mode the scene will stay NULL */
if (!G.background) { if (!G.background) {
@@ -574,7 +574,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
int WM_read_homefile_exec(bContext *C, wmOperator *op) int WM_read_homefile_exec(bContext *C, wmOperator *op)
{ {
int from_memory= strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0; int from_memory = strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0;
return WM_read_homefile(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; return WM_read_homefile(C, op->reports, from_memory) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
} }
@@ -591,15 +591,15 @@ void WM_read_history(void)
BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE); BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE);
lines= BLI_file_read_as_lines(name); lines = BLI_file_read_as_lines(name);
G.recent_files.first = G.recent_files.last = NULL; G.recent_files.first = G.recent_files.last = NULL;
/* read list of recent opened files from recent-files.txt to memory */ /* read list of recent opened files from recent-files.txt to memory */
for (l= lines, num= 0; l && (num<U.recent_files); l= l->next) { for (l = lines, num = 0; l && (num < U.recent_files); l = l->next) {
line = l->link; line = l->link;
if (line[0] && BLI_exists(line)) { if (line[0] && BLI_exists(line)) {
recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile");
BLI_addtail(&(G.recent_files), recent); BLI_addtail(&(G.recent_files), recent);
recent->filepath = BLI_strdup(line); recent->filepath = BLI_strdup(line);
num++; num++;
@@ -627,21 +627,21 @@ static void write_history(void)
recent = G.recent_files.first; recent = G.recent_files.first;
/* refresh recent-files.txt of recent opened files, when current file was changed */ /* refresh recent-files.txt of recent opened files, when current file was changed */
if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) { if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) {
fp= BLI_fopen(name, "w"); fp = BLI_fopen(name, "w");
if (fp) { if (fp) {
/* add current file to the beginning of list */ /* add current file to the beginning of list */
recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile");
recent->filepath = BLI_strdup(G.main->name); recent->filepath = BLI_strdup(G.main->name);
BLI_addhead(&(G.recent_files), recent); BLI_addhead(&(G.recent_files), recent);
/* write current file to recent-files.txt */ /* write current file to recent-files.txt */
fprintf(fp, "%s\n", recent->filepath); fprintf(fp, "%s\n", recent->filepath);
recent = recent->next; recent = recent->next;
i=1; i = 1;
/* write rest of recent opened files to recent-files.txt */ /* write rest of recent opened files to recent-files.txt */
while ((i<U.recent_files) && (recent)) { while ((i < U.recent_files) && (recent)) {
/* this prevents to have duplicities in list */ /* this prevents to have duplicities in list */
if (BLI_path_cmp(recent->filepath, G.main->name)!=0) { if (BLI_path_cmp(recent->filepath, G.main->name) != 0) {
fprintf(fp, "%s\n", recent->filepath); fprintf(fp, "%s\n", recent->filepath);
recent = recent->next; recent = recent->next;
} }
@@ -666,21 +666,21 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
/* will be scaled down, but gives some nice oversampling */ /* will be scaled down, but gives some nice oversampling */
ImBuf *ibuf; ImBuf *ibuf;
int *thumb; int *thumb;
char err_out[256]= "unknown"; char err_out[256] = "unknown";
*thumb_pt= NULL; *thumb_pt = NULL;
/* scene can be NULL if running a script at startup and calling the save operator */ /* scene can be NULL if running a script at startup and calling the save operator */
if (G.background || scene==NULL || scene->camera==NULL) if (G.background || scene == NULL || scene->camera == NULL)
return NULL; return NULL;
/* gets scaled to BLEN_THUMB_SIZE */ /* gets scaled to BLEN_THUMB_SIZE */
ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, OB_SOLID, FALSE, err_out); IB_rect, OB_SOLID, FALSE, err_out);
if (ibuf) { if (ibuf) {
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
/* dirty oversampling */ /* dirty oversampling */
IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE); IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE);
@@ -689,7 +689,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
IMB_overlayblend_thumb(ibuf->rect, ibuf->x, ibuf->y, aspect); IMB_overlayblend_thumb(ibuf->rect, ibuf->x, ibuf->y, aspect);
/* first write into thumb buffer */ /* first write into thumb buffer */
thumb= MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb"); thumb = MEM_mallocN(((2 + (BLEN_THUMB_SIZE * BLEN_THUMB_SIZE))) * sizeof(int), "write_file thumb");
thumb[0] = BLEN_THUMB_SIZE; thumb[0] = BLEN_THUMB_SIZE;
thumb[1] = BLEN_THUMB_SIZE; thumb[1] = BLEN_THUMB_SIZE;
@@ -699,11 +699,11 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
else { else {
/* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */ /* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */
fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out); fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out);
thumb= NULL; thumb = NULL;
} }
/* must be freed by caller */ /* must be freed by caller */
*thumb_pt= thumb; *thumb_pt = thumb;
return ibuf; return ibuf;
} }
@@ -732,8 +732,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
int len; int len;
char filepath[FILE_MAX]; char filepath[FILE_MAX];
int *thumb= NULL; int *thumb = NULL;
ImBuf *ibuf_thumb= NULL; ImBuf *ibuf_thumb = NULL;
len = strlen(target); len = strlen(target);
@@ -752,7 +752,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* don't use 'target' anymore */ /* don't use 'target' anymore */
/* send the OnSave event */ /* send the OnSave event */
for (li= G.main->library.first; li; li= li->id.next) { for (li = G.main->library.first; li; li = li->id.next) {
if (BLI_path_cmp(li->filepath, filepath) == 0) { if (BLI_path_cmp(li->filepath, filepath) == 0) {
BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.240s'", filepath); BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.240s'", filepath);
return -1; return -1;
@@ -762,7 +762,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* blend file thumbnail */ /* blend file thumbnail */
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */ /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
if (U.flag & USER_SAVE_PREVIEWS) { if (U.flag & USER_SAVE_PREVIEWS) {
ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); ibuf_thumb = blend_file_thumb(CTX_data_scene(C), &thumb);
} }
BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE); BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE);
@@ -784,7 +784,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
if (!copy) { if (!copy) {
G.relbase_valid = 1; G.relbase_valid = 1;
BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
G.save_over = 1; /* disable untitled.blend convention */ G.save_over = 1; /* disable untitled.blend convention */
} }
@@ -804,7 +804,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* run this function after because the file cant be written before the blend is */ /* run this function after because the file cant be written before the blend is */
if (ibuf_thumb) { if (ibuf_thumb) {
ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); ibuf_thumb = IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb);
IMB_freeImBuf(ibuf_thumb); IMB_freeImBuf(ibuf_thumb);
} }
@@ -826,8 +826,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* operator entry */ /* operator entry */
int WM_write_homefile(bContext *C, wmOperator *op) int WM_write_homefile(bContext *C, wmOperator *op)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
char filepath[FILE_MAX]; char filepath[FILE_MAX];
int fileflags; int fileflags;
@@ -851,7 +851,7 @@ int WM_write_homefile(bContext *C, wmOperator *op)
printf("ok\n"); printf("ok\n");
G.save_over= 0; G.save_over = 0;
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@@ -891,7 +891,7 @@ void WM_autosave_init(wmWindowManager *wm)
wm_autosave_timer_ended(wm); wm_autosave_timer_ended(wm);
if (U.flag & USER_AUTOSAVE) if (U.flag & USER_AUTOSAVE)
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0);
} }
void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(wt)) void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(wt))
@@ -904,10 +904,10 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
WM_event_remove_timer(wm, NULL, wm->autosavetimer); WM_event_remove_timer(wm, NULL, wm->autosavetimer);
/* if a modal operator is running, don't autosave, but try again in 10 seconds */ /* if a modal operator is running, don't autosave, but try again in 10 seconds */
for (win=wm->windows.first; win; win=win->next) { for (win = wm->windows.first; win; win = win->next) {
for (handler=win->modalhandlers.first; handler; handler=handler->next) { for (handler = win->modalhandlers.first; handler; handler = handler->next) {
if (handler->op) { if (handler->op) {
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0); wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0);
return; return;
} }
} }
@@ -916,20 +916,20 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
wm_autosave_location(filepath); wm_autosave_location(filepath);
/* force save as regular blend file */ /* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN|G_FILE_HISTORY); fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
/* no error reporting to console */ /* no error reporting to console */
BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
/* do timer after file write, just in case file write takes a long time */ /* do timer after file write, just in case file write takes a long time */
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime * 60.0);
} }
void wm_autosave_timer_ended(wmWindowManager *wm) void wm_autosave_timer_ended(wmWindowManager *wm)
{ {
if (wm->autosavetimer) { if (wm->autosavetimer) {
WM_event_remove_timer(wm, NULL, wm->autosavetimer); WM_event_remove_timer(wm, NULL, wm->autosavetimer);
wm->autosavetimer= NULL; wm->autosavetimer = NULL;
} }
} }

View File

@@ -38,7 +38,7 @@
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_math.h" #include "BLI_math.h"
#include "BLI_scanfill.h" /* lasso tessellation */ #include "BLI_scanfill.h" /* lasso tessellation */
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
#include "BKE_context.h" #include "BKE_context.h"
@@ -60,32 +60,32 @@
/* context checked on having screen, window and area */ /* context checked on having screen, window and area */
wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
{ {
wmGesture *gesture= MEM_callocN(sizeof(wmGesture), "new gesture"); wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture");
wmWindow *window= CTX_wm_window(C); wmWindow *window = CTX_wm_window(C);
ARegion *ar= CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
int sx, sy; int sx, sy;
BLI_addtail(&window->gesture, gesture); BLI_addtail(&window->gesture, gesture);
gesture->type= type; gesture->type = type;
gesture->event_type= event->type; gesture->event_type = event->type;
gesture->swinid= ar->swinid; /* means only in area-region context! */ gesture->swinid = ar->swinid; /* means only in area-region context! */
wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy); wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
if (ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, if (ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK,
WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE))
{ {
rcti *rect= MEM_callocN(sizeof(rcti), "gesture rect new"); rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new");
gesture->customdata= rect; gesture->customdata = rect;
rect->xmin = event->x - sx; rect->xmin = event->x - sx;
rect->ymin = event->y - sy; rect->ymin = event->y - sy;
if (type==WM_GESTURE_CIRCLE) { if (type == WM_GESTURE_CIRCLE) {
#ifdef GESTURE_MEMORY #ifdef GESTURE_MEMORY
rect->xmax = circle_select_size; rect->xmax = circle_select_size;
#else #else
rect->xmax = 25; // XXX temp rect->xmax = 25; // XXX temp
#endif #endif
} }
else { else {
@@ -95,10 +95,10 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
} }
else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) { else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) {
short *lasso; short *lasso;
gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MIN_POINTS, "lasso points"); gesture->customdata = lasso = MEM_callocN(2 * sizeof(short) * WM_LASSO_MIN_POINTS, "lasso points");
lasso[0] = event->x - sx; lasso[0] = event->x - sx;
lasso[1] = event->y - sy; lasso[1] = event->y - sy;
gesture->points= 1; gesture->points = 1;
gesture->size = WM_LASSO_MIN_POINTS; gesture->size = WM_LASSO_MIN_POINTS;
} }
@@ -107,10 +107,10 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
void WM_gesture_end(bContext *C, wmGesture *gesture) void WM_gesture_end(bContext *C, wmGesture *gesture)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
if (win->tweak==gesture) if (win->tweak == gesture)
win->tweak= NULL; win->tweak = NULL;
BLI_remlink(&win->gesture, gesture); BLI_remlink(&win->gesture, gesture);
MEM_freeN(gesture->customdata); MEM_freeN(gesture->customdata);
MEM_freeN(gesture); MEM_freeN(gesture);
@@ -118,7 +118,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
void WM_gestures_remove(bContext *C) void WM_gestures_remove(bContext *C)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
while (win->gesture.first) while (win->gesture.first)
WM_gesture_end(C, win->gesture.first); WM_gesture_end(C, win->gesture.first);
@@ -128,32 +128,32 @@ void WM_gestures_remove(bContext *C)
/* tweak and line gestures */ /* tweak and line gestures */
int wm_gesture_evaluate(wmGesture *gesture) int wm_gesture_evaluate(wmGesture *gesture)
{ {
if (gesture->type==WM_GESTURE_TWEAK) { if (gesture->type == WM_GESTURE_TWEAK) {
rcti *rect= gesture->customdata; rcti *rect = gesture->customdata;
int dx= rect->xmax - rect->xmin; int dx = rect->xmax - rect->xmin;
int dy= rect->ymax - rect->ymin; int dy = rect->ymax - rect->ymin;
if (ABS(dx)+ABS(dy) > U.tweak_threshold) { if (ABS(dx) + ABS(dy) > U.tweak_threshold) {
int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f); int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f);
int val= EVT_GESTURE_W; int val = EVT_GESTURE_W;
if (theta==0) val= EVT_GESTURE_E; if (theta == 0) val = EVT_GESTURE_E;
else if (theta==1) val= EVT_GESTURE_NE; else if (theta == 1) val = EVT_GESTURE_NE;
else if (theta==2) val= EVT_GESTURE_N; else if (theta == 2) val = EVT_GESTURE_N;
else if (theta==3) val= EVT_GESTURE_NW; else if (theta == 3) val = EVT_GESTURE_NW;
else if (theta==-1) val= EVT_GESTURE_SE; else if (theta == -1) val = EVT_GESTURE_SE;
else if (theta==-2) val= EVT_GESTURE_S; else if (theta == -2) val = EVT_GESTURE_S;
else if (theta==-3) val= EVT_GESTURE_SW; else if (theta == -3) val = EVT_GESTURE_SW;
#if 0 #if 0
/* debug */ /* debug */
if (val==1) printf("tweak north\n"); if (val == 1) printf("tweak north\n");
if (val==2) printf("tweak north-east\n"); if (val == 2) printf("tweak north-east\n");
if (val==3) printf("tweak east\n"); if (val == 3) printf("tweak east\n");
if (val==4) printf("tweak south-east\n"); if (val == 4) printf("tweak south-east\n");
if (val==5) printf("tweak south\n"); if (val == 5) printf("tweak south\n");
if (val==6) printf("tweak south-west\n"); if (val == 6) printf("tweak south-west\n");
if (val==7) printf("tweak west\n"); if (val == 7) printf("tweak west\n");
if (val==8) printf("tweak north-west\n"); if (val == 8) printf("tweak north-west\n");
#endif #endif
return val; return val;
} }
@@ -166,7 +166,7 @@ int wm_gesture_evaluate(wmGesture *gesture)
static void wm_gesture_draw_rect(wmGesture *gt) static void wm_gesture_draw_rect(wmGesture *gt)
{ {
rcti *rect= (rcti *)gt->customdata; rcti *rect = (rcti *)gt->customdata;
glEnable(GL_BLEND); glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05); glColor4f(1.0, 1.0, 1.0, 0.05);
@@ -190,7 +190,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
static void wm_gesture_draw_line(wmGesture *gt) static void wm_gesture_draw_line(wmGesture *gt)
{ {
rcti *rect= (rcti *)gt->customdata; rcti *rect = (rcti *)gt->customdata;
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96); glColor3ub(96, 96, 96);
@@ -206,22 +206,22 @@ static void wm_gesture_draw_line(wmGesture *gt)
static void wm_gesture_draw_circle(wmGesture *gt) static void wm_gesture_draw_circle(wmGesture *gt)
{ {
rcti *rect= (rcti *)gt->customdata; rcti *rect = (rcti *)gt->customdata;
glTranslatef((float)rect->xmin, (float)rect->ymin, 0.0f); glTranslatef((float)rect->xmin, (float)rect->ymin, 0.0f);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05); glColor4f(1.0, 1.0, 1.0, 0.05);
glutil_draw_filled_arc(0.0, M_PI*2.0, rect->xmax, 40); glutil_draw_filled_arc(0.0, M_PI * 2.0, rect->xmax, 40);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96); glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA); glLineStipple(1, 0xAAAA);
glutil_draw_lined_arc(0.0, M_PI*2.0, rect->xmax, 40); glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40);
glColor3ub(255, 255, 255); glColor3ub(255, 255, 255);
glLineStipple(1, 0x5555); glLineStipple(1, 0x5555);
glutil_draw_lined_arc(0.0, M_PI*2.0, rect->xmax, 40); glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40);
glDisable(GL_LINE_STIPPLE); glDisable(GL_LINE_STIPPLE);
glTranslatef((float)-rect->xmin, (float)-rect->ymin, 0.0f); glTranslatef((float)-rect->xmin, (float)-rect->ymin, 0.0f);
@@ -230,24 +230,24 @@ static void wm_gesture_draw_circle(wmGesture *gt)
static void draw_filled_lasso(wmGesture *gt) static void draw_filled_lasso(wmGesture *gt)
{ {
ScanFillVert *v=NULL, *lastv=NULL, *firstv=NULL; ScanFillVert *v = NULL, *lastv = NULL, *firstv = NULL;
ScanFillFace *efa; ScanFillFace *efa;
short *lasso= (short *)gt->customdata; short *lasso = (short *)gt->customdata;
int i; int i;
BLI_begin_edgefill(); BLI_begin_edgefill();
for (i=0; i<gt->points; i++, lasso+=2) { for (i = 0; i < gt->points; i++, lasso += 2) {
float co[3]; float co[3];
co[0]= (float)lasso[0]; co[0] = (float)lasso[0];
co[1]= (float)lasso[1]; co[1] = (float)lasso[1];
co[2]= 0.0f; co[2] = 0.0f;
v = BLI_addfillvert(co); v = BLI_addfillvert(co);
if (lastv) if (lastv)
/* e = */ /* UNUSED */ BLI_addfilledge(lastv, v); /* e = */ /* UNUSED */ BLI_addfilledge(lastv, v);
lastv = v; lastv = v;
if (firstv==NULL) firstv = v; if (firstv == NULL) firstv = v;
} }
/* highly unlikely this will fail, but could crash if (gt->points == 0) */ /* highly unlikely this will fail, but could crash if (gt->points == 0) */
@@ -258,7 +258,7 @@ static void draw_filled_lasso(wmGesture *gt)
glEnable(GL_BLEND); glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05); glColor4f(1.0, 1.0, 1.0, 0.05);
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
for (efa = fillfacebase.first; efa; efa=efa->next) { for (efa = fillfacebase.first; efa; efa = efa->next) {
glVertex2fv(efa->v1->co); glVertex2fv(efa->v1->co);
glVertex2fv(efa->v2->co); glVertex2fv(efa->v2->co);
glVertex2fv(efa->v3->co); glVertex2fv(efa->v3->co);
@@ -272,7 +272,7 @@ static void draw_filled_lasso(wmGesture *gt)
static void wm_gesture_draw_lasso(wmGesture *gt) static void wm_gesture_draw_lasso(wmGesture *gt)
{ {
short *lasso= (short *)gt->customdata; short *lasso = (short *)gt->customdata;
int i; int i;
draw_filled_lasso(gt); draw_filled_lasso(gt);
@@ -281,19 +281,19 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
glColor3ub(96, 96, 96); glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA); glLineStipple(1, 0xAAAA);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (i=0; i<gt->points; i++, lasso+=2) for (i = 0; i < gt->points; i++, lasso += 2)
glVertex2sv(lasso); glVertex2sv(lasso);
if (gt->type==WM_GESTURE_LASSO) if (gt->type == WM_GESTURE_LASSO)
glVertex2sv((short *)gt->customdata); glVertex2sv((short *)gt->customdata);
glEnd(); glEnd();
glColor3ub(255, 255, 255); glColor3ub(255, 255, 255);
glLineStipple(1, 0x5555); glLineStipple(1, 0x5555);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
lasso= (short *)gt->customdata; lasso = (short *)gt->customdata;
for (i=0; i<gt->points; i++, lasso+=2) for (i = 0; i < gt->points; i++, lasso += 2)
glVertex2sv(lasso); glVertex2sv(lasso);
if (gt->type==WM_GESTURE_LASSO) if (gt->type == WM_GESTURE_LASSO)
glVertex2sv((short *)gt->customdata); glVertex2sv((short *)gt->customdata);
glEnd(); glEnd();
@@ -303,7 +303,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
{ {
rcti *rect= (rcti *)gt->customdata; rcti *rect = (rcti *)gt->customdata;
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96); glColor3ub(96, 96, 96);
@@ -321,41 +321,41 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
/* called in wm_draw.c */ /* called in wm_draw.c */
void wm_gesture_draw(wmWindow *win) void wm_gesture_draw(wmWindow *win)
{ {
wmGesture *gt= (wmGesture *)win->gesture.first; wmGesture *gt = (wmGesture *)win->gesture.first;
for (; gt; gt= gt->next) { for (; gt; gt = gt->next) {
/* all in subwindow space */ /* all in subwindow space */
wmSubWindowSet(win, gt->swinid); wmSubWindowSet(win, gt->swinid);
if (gt->type==WM_GESTURE_RECT) if (gt->type == WM_GESTURE_RECT)
wm_gesture_draw_rect(gt); wm_gesture_draw_rect(gt);
// else if (gt->type==WM_GESTURE_TWEAK) // else if (gt->type==WM_GESTURE_TWEAK)
// wm_gesture_draw_line(gt); // wm_gesture_draw_line(gt);
else if (gt->type==WM_GESTURE_CIRCLE) else if (gt->type == WM_GESTURE_CIRCLE)
wm_gesture_draw_circle(gt); wm_gesture_draw_circle(gt);
else if (gt->type==WM_GESTURE_CROSS_RECT) { else if (gt->type == WM_GESTURE_CROSS_RECT) {
if (gt->mode==1) if (gt->mode == 1)
wm_gesture_draw_rect(gt); wm_gesture_draw_rect(gt);
else else
wm_gesture_draw_cross(win, gt); wm_gesture_draw_cross(win, gt);
} }
else if (gt->type==WM_GESTURE_LINES) else if (gt->type == WM_GESTURE_LINES)
wm_gesture_draw_lasso(gt); wm_gesture_draw_lasso(gt);
else if (gt->type==WM_GESTURE_LASSO) else if (gt->type == WM_GESTURE_LASSO)
wm_gesture_draw_lasso(gt); wm_gesture_draw_lasso(gt);
else if (gt->type==WM_GESTURE_STRAIGHTLINE) else if (gt->type == WM_GESTURE_STRAIGHTLINE)
wm_gesture_draw_line(gt); wm_gesture_draw_line(gt);
} }
} }
void wm_gesture_tag_redraw(bContext *C) void wm_gesture_tag_redraw(bContext *C)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
bScreen *screen= CTX_wm_screen(C); bScreen *screen = CTX_wm_screen(C);
ARegion *ar= CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
if (screen) if (screen)
screen->do_draw_gesture= 1; screen->do_draw_gesture = 1;
wm_tag_redraw_overlay(win, ar); wm_tag_redraw_overlay(win, ar);
} }

View File

@@ -68,7 +68,7 @@
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
#include "RE_engine.h" #include "RE_engine.h"
#include "RE_pipeline.h" /* RE_ free stuff */ #include "RE_pipeline.h" /* RE_ free stuff */
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
#include "BPY_extern.h" #include "BPY_extern.h"
@@ -125,20 +125,20 @@ int wm_start_with_console = 0; /* used in creator.c */
void WM_init(bContext *C, int argc, const char **argv) void WM_init(bContext *C, int argc, const char **argv)
{ {
if (!G.background) { if (!G.background) {
wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_ghost_init(C); /* note: it assigns C to ghost! */
wm_init_cursor_data(); wm_init_cursor_data();
} }
GHOST_CreateSystemPaths(); GHOST_CreateSystemPaths();
wm_operatortype_init(); wm_operatortype_init();
WM_menutype_init(); WM_menutype_init();
set_free_windowmanager_cb(wm_close_and_free); /* library.c */ set_free_windowmanager_cb(wm_close_and_free); /* library.c */
set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ set_blender_test_break_cb(wm_window_testbreak); /* blender.c */
DAG_editors_update_cb(ED_render_id_flush_update, ED_render_scene_update); /* depsgraph.c */ DAG_editors_update_cb(ED_render_id_flush_update, ED_render_scene_update); /* depsgraph.c */
ED_spacetypes_init(); /* editors/space_api/spacetype.c */ ED_spacetypes_init(); /* editors/space_api/spacetype.c */
ED_file_init(); /* for fsmenu */ ED_file_init(); /* for fsmenu */
ED_init_node_butfuncs(); ED_init_node_butfuncs();
BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */ BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
@@ -203,8 +203,8 @@ void WM_init(bContext *C, int argc, const char **argv)
void WM_init_splash(bContext *C) void WM_init_splash(bContext *C)
{ {
if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { if ((U.uiflag & USER_SPLASH_DISABLE) == 0) {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *prevwin= CTX_wm_window(C); wmWindow *prevwin = CTX_wm_window(C);
if (wm->windows.first) { if (wm->windows.first) {
CTX_wm_window_set(C, wm->windows.first); CTX_wm_window_set(C, wm->windows.first);
@@ -216,18 +216,18 @@ void WM_init_splash(bContext *C)
int WM_init_game(bContext *C) int WM_init_game(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow* win; wmWindow *win;
ScrArea *sa; ScrArea *sa;
ARegion *ar= NULL; ARegion *ar = NULL;
Scene *scene= CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
if (!scene) { if (!scene) {
// XXX, this should not be needed. // XXX, this should not be needed.
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
scene= bmain->scene.first; scene = bmain->scene.first;
} }
win = wm->windows.first; win = wm->windows.first;
@@ -237,7 +237,7 @@ int WM_init_game(bContext *C)
CTX_wm_window_set(C, win); CTX_wm_window_set(C, win);
sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
// if we have a valid 3D view // if we have a valid 3D view
if (sa && ar) { if (sa && ar) {
@@ -251,7 +251,7 @@ int WM_init_game(bContext *C)
WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL); WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
/* toolbox, properties panel and header are hidden */ /* toolbox, properties panel and header are hidden */
for (arhide=sa->regionbase.first; arhide; arhide=arhide->next) { for (arhide = sa->regionbase.first; arhide; arhide = arhide->next) {
if (arhide->regiontype != RGN_TYPE_WINDOW) { if (arhide->regiontype != RGN_TYPE_WINDOW) {
if (!(arhide->flag & RGN_FLAG_HIDDEN)) { if (!(arhide->flag & RGN_FLAG_HIDDEN)) {
ED_region_toggle_hidden(C, arhide); ED_region_toggle_hidden(C, arhide);
@@ -308,7 +308,7 @@ static void free_openrecent(void)
{ {
struct RecentFile *recent; struct RecentFile *recent;
for (recent = G.recent_files.first; recent; recent=recent->next) for (recent = G.recent_files.first; recent; recent = recent->next)
MEM_freeN(recent->filepath); MEM_freeN(recent->filepath);
BLI_freelistN(&(G.recent_files)); BLI_freelistN(&(G.recent_files));
@@ -317,7 +317,7 @@ static void free_openrecent(void)
/* bad stuff*/ /* bad stuff*/
// XXX copy/paste buffer stuff... // XXX copy/paste buffer stuff...
extern void free_anim_copybuf(void); extern void free_anim_copybuf(void);
extern void free_anim_drivers_copybuf(void); extern void free_anim_drivers_copybuf(void);
extern void free_fmodifiers_copybuf(void); extern void free_fmodifiers_copybuf(void);
@@ -339,9 +339,9 @@ void WM_exit_ext(bContext *C, const short do_python)
WM_jobs_stop_all(CTX_wm_manager(C)); WM_jobs_stop_all(CTX_wm_manager(C));
for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) { for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
CTX_wm_window_set(C, win); /* needed by operator close callbacks */ CTX_wm_window_set(C, win); /* needed by operator close callbacks */
WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers); WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, win->screen); ED_screen_exit(C, win, win->screen);
@@ -366,15 +366,15 @@ void WM_exit_ext(bContext *C, const short do_python)
BKE_freecubetable(); BKE_freecubetable();
ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */
if (C && CTX_wm_manager(C)) if (C && CTX_wm_manager(C))
wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */
seq_free_clipboard(); /* sequencer.c */ seq_free_clipboard(); /* sequencer.c */
BKE_tracking_free_clipboard(); BKE_tracking_free_clipboard();
free_blender(); /* blender.c, does entire library and spacetypes */ free_blender(); /* blender.c, does entire library and spacetypes */
// free_matcopybuf(); // free_matcopybuf();
free_anim_copybuf(); free_anim_copybuf();
free_anim_drivers_copybuf(); free_anim_drivers_copybuf();
@@ -418,7 +418,7 @@ void WM_exit_ext(bContext *C, const short do_python)
GPU_extensions_exit(); GPU_extensions_exit();
if (!G.background) { if (!G.background) {
BKE_undo_save_quit(); // saves quit.blend if global undo is on BKE_undo_save_quit(); /* saves quit.blend if global undo is on */
} }
BKE_reset_undo(); BKE_reset_undo();
@@ -438,7 +438,7 @@ void WM_exit_ext(bContext *C, const short do_python)
GHOST_DisposeSystemPaths(); GHOST_DisposeSystemPaths();
if (MEM_get_memory_blocks_in_use()!=0) { if (MEM_get_memory_blocks_in_use() != 0) {
printf("Error: Not freed memory blocks: %d\n", MEM_get_memory_blocks_in_use()); printf("Error: Not freed memory blocks: %d\n", MEM_get_memory_blocks_in_use());
MEM_printmemlist(); MEM_printmemlist();
} }
@@ -458,5 +458,5 @@ void WM_exit_ext(bContext *C, const short do_python)
void WM_exit(bContext *C) void WM_exit(bContext *C)
{ {
WM_exit_ext(C, 1); WM_exit_ext(C, 1);
exit(G.afbreek==1); exit(G.afbreek == 1);
} }

View File

@@ -72,11 +72,11 @@
* *
* Stop job * Stop job
* - signal job to end * - signal job to end
* on end, job will tag itself as sleeping * on end, job will tag itself as sleeping
* *
* Remove job * Remove job
* - signal job to end * - signal job to end
* on end, job will remove itself * on end, job will remove itself
* *
* When job is done: * When job is done:
* - it puts timer to sleep (or removes?) * - it puts timer to sleep (or removes?)
@@ -134,12 +134,12 @@ struct wmJob {
*/ */
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
{ {
wmJob *steve, *found=NULL; wmJob *steve, *found = NULL;
for (steve= wm->jobs.first; steve; steve= steve->next) for (steve = wm->jobs.first; steve; steve = steve->next)
if (steve->owner==owner) { if (steve->owner == owner) {
found= steve; found = steve;
if (name && strcmp(steve->name, name)==0) if (name && strcmp(steve->name, name) == 0)
return steve; return steve;
} }
@@ -153,15 +153,15 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
* when stopped it starts the new one */ * when stopped it starts the new one */
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag) wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag)
{ {
wmJob *steve= wm_job_find(wm, owner, name); wmJob *steve = wm_job_find(wm, owner, name);
if (steve==NULL) { if (steve == NULL) {
steve= MEM_callocN(sizeof(wmJob), "new job"); steve = MEM_callocN(sizeof(wmJob), "new job");
BLI_addtail(&wm->jobs, steve); BLI_addtail(&wm->jobs, steve);
steve->win= win; steve->win = win;
steve->owner= owner; steve->owner = owner;
steve->flag= flag; steve->flag = flag;
BLI_strncpy(steve->name, name, sizeof(steve->name)); BLI_strncpy(steve->name, name, sizeof(steve->name));
} }
@@ -173,8 +173,8 @@ int WM_jobs_test(wmWindowManager *wm, void *owner)
{ {
wmJob *steve; wmJob *steve;
for (steve= wm->jobs.first; steve; steve= steve->next) for (steve = wm->jobs.first; steve; steve = steve->next)
if (steve->owner==owner) if (steve->owner == owner)
if (steve->running) if (steve->running)
return 1; return 1;
return 0; return 0;
@@ -182,7 +182,7 @@ int WM_jobs_test(wmWindowManager *wm, void *owner)
float WM_jobs_progress(wmWindowManager *wm, void *owner) float WM_jobs_progress(wmWindowManager *wm, void *owner)
{ {
wmJob *steve= wm_job_find(wm, owner, NULL); wmJob *steve = wm_job_find(wm, owner, NULL);
if (steve && steve->flag & WM_JOB_PROGRESS) if (steve && steve->flag & WM_JOB_PROGRESS)
return steve->progress; return steve->progress;
@@ -192,7 +192,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner)
char *WM_jobs_name(wmWindowManager *wm, void *owner) char *WM_jobs_name(wmWindowManager *wm, void *owner)
{ {
wmJob *steve= wm_job_find(wm, owner, NULL); wmJob *steve = wm_job_find(wm, owner, NULL);
if (steve) if (steve)
return steve->name; return steve->name;
@@ -205,7 +205,7 @@ int WM_jobs_is_running(wmJob *steve)
return steve->running; return steve->running;
} }
void* WM_jobs_get_customdata(wmJob * steve) void *WM_jobs_get_customdata(wmJob *steve)
{ {
if (!steve->customdata) { if (!steve->customdata) {
return steve->run_customdata; return steve->run_customdata;
@@ -221,12 +221,12 @@ void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *))
if (steve->customdata) if (steve->customdata)
steve->free(steve->customdata); steve->free(steve->customdata);
steve->customdata= customdata; steve->customdata = customdata;
steve->free= free; steve->free = free;
if (steve->running) { if (steve->running) {
/* signal job to end */ /* signal job to end */
steve->stop= 1; steve->stop = 1;
} }
} }
@@ -238,23 +238,23 @@ void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note, unsigned in
} }
void WM_jobs_callbacks(wmJob *steve, void WM_jobs_callbacks(wmJob *steve,
void (*startjob)(void *, short *, short *, float *), void (*startjob)(void *, short *, short *, float *),
void (*initjob)(void *), void (*initjob)(void *),
void (*update)(void *), void (*update)(void *),
void (*endjob)(void *)) void (*endjob)(void *))
{ {
steve->startjob= startjob; steve->startjob = startjob;
steve->initjob= initjob; steve->initjob = initjob;
steve->update= update; steve->update = update;
steve->endjob= endjob; steve->endjob = endjob;
} }
static void *do_job_thread(void *job_v) static void *do_job_thread(void *job_v)
{ {
wmJob *steve= job_v; wmJob *steve = job_v;
steve->startjob(steve->run_customdata, &steve->stop, &steve->do_update, &steve->progress); steve->startjob(steve->run_customdata, &steve->stop, &steve->do_update, &steve->progress);
steve->ready= 1; steve->ready = 1;
return NULL; return NULL;
} }
@@ -263,41 +263,41 @@ static void *do_job_thread(void *job_v)
static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
{ {
wmJob *steve; wmJob *steve;
int suspend= 0; int suspend = 0;
/* job added with suspend flag, we wait 1 timer step before activating it */ /* job added with suspend flag, we wait 1 timer step before activating it */
if (test->flag & WM_JOB_SUSPEND) { if (test->flag & WM_JOB_SUSPEND) {
suspend= 1; suspend = 1;
test->flag &= ~WM_JOB_SUSPEND; test->flag &= ~WM_JOB_SUSPEND;
} }
else { else {
/* check other jobs */ /* check other jobs */
for (steve= wm->jobs.first; steve; steve= steve->next) { for (steve = wm->jobs.first; steve; steve = steve->next) {
/* obvious case, no test needed */ /* obvious case, no test needed */
if (steve==test || !steve->running) continue; if (steve == test || !steve->running) continue;
/* if new job is not render, then check for same startjob */ /* if new job is not render, then check for same startjob */
if (0==(test->flag & WM_JOB_EXCL_RENDER)) if (0 == (test->flag & WM_JOB_EXCL_RENDER))
if (steve->startjob!=test->startjob) if (steve->startjob != test->startjob)
continue; continue;
/* if new job is render, any render job should be stopped */ /* if new job is render, any render job should be stopped */
if (test->flag & WM_JOB_EXCL_RENDER) if (test->flag & WM_JOB_EXCL_RENDER)
if (0==(steve->flag & WM_JOB_EXCL_RENDER)) if (0 == (steve->flag & WM_JOB_EXCL_RENDER))
continue; continue;
suspend= 1; suspend = 1;
/* if this job has higher priority, stop others */ /* if this job has higher priority, stop others */
if (test->flag & WM_JOB_PRIORITY) { if (test->flag & WM_JOB_PRIORITY) {
steve->stop= 1; steve->stop = 1;
// printf("job stopped: %s\n", steve->name); // printf("job stopped: %s\n", steve->name);
} }
} }
} }
/* possible suspend ourselfs, waiting for other jobs, or de-suspend */ /* possible suspend ourselfs, waiting for other jobs, or de-suspend */
test->suspended= suspend; test->suspended = suspend;
// if (suspend) printf("job suspended: %s\n", test->name); // if (suspend) printf("job suspended: %s\n", test->name);
} }
@@ -307,7 +307,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
{ {
if (steve->running) { if (steve->running) {
/* signal job to end and restart */ /* signal job to end and restart */
steve->stop= 1; steve->stop = 1;
// printf("job started a running job, ending... %s\n", steve->name); // printf("job started a running job, ending... %s\n", steve->name);
} }
else { else {
@@ -316,20 +316,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
wm_jobs_test_suspend_stop(wm, steve); wm_jobs_test_suspend_stop(wm, steve);
if (steve->suspended==0) { if (steve->suspended == 0) {
/* copy to ensure proper free in end */ /* copy to ensure proper free in end */
steve->run_customdata= steve->customdata; steve->run_customdata = steve->customdata;
steve->run_free= steve->free; steve->run_free = steve->free;
steve->free= NULL; steve->free = NULL;
steve->customdata= NULL; steve->customdata = NULL;
steve->running= 1; steve->running = 1;
if (steve->initjob) if (steve->initjob)
steve->initjob(steve->run_customdata); steve->initjob(steve->run_customdata);
steve->stop= 0; steve->stop = 0;
steve->ready= 0; steve->ready = 0;
steve->progress= 0.0; steve->progress = 0.0;
// printf("job started: %s\n", steve->name); // printf("job started: %s\n", steve->name);
@@ -338,8 +338,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
} }
/* restarted job has timer already */ /* restarted job has timer already */
if (steve->wt==NULL) if (steve->wt == NULL)
steve->wt= WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep);
} }
else printf("job fails, not initialized\n"); else printf("job fails, not initialized\n");
} }
@@ -350,7 +350,7 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve)
{ {
if (steve->running) { if (steve->running) {
/* signal job to end */ /* signal job to end */
steve->stop= 1; steve->stop = 1;
BLI_end_threads(&steve->threads); BLI_end_threads(&steve->threads);
if (steve->endjob) if (steve->endjob)
@@ -374,7 +374,7 @@ void WM_jobs_stop_all(wmWindowManager *wm)
{ {
wmJob *steve; wmJob *steve;
while ((steve= wm->jobs.first)) while ((steve = wm->jobs.first))
wm_jobs_kill_job(wm, steve); wm_jobs_kill_job(wm, steve);
} }
@@ -384,10 +384,10 @@ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
{ {
wmJob *steve; wmJob *steve;
for (steve= wm->jobs.first; steve; steve= steve->next) for (steve = wm->jobs.first; steve; steve = steve->next)
if (steve->owner==owner || steve->startjob==startjob) if (steve->owner == owner || steve->startjob == startjob)
if (steve->running) if (steve->running)
steve->stop= 1; steve->stop = 1;
} }
/* actually terminate thread and job timer */ /* actually terminate thread and job timer */
@@ -395,15 +395,15 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho
{ {
wmJob *steve; wmJob *steve;
steve= wm->jobs.first; steve = wm->jobs.first;
while (steve) { while (steve) {
if (steve->owner==owner || steve->startjob==startjob) { if (steve->owner == owner || steve->startjob == startjob) {
wmJob* bill = steve; wmJob *bill = steve;
steve= steve->next; steve = steve->next;
wm_jobs_kill_job(wm, bill); wm_jobs_kill_job(wm, bill);
} }
else { else {
steve= steve->next; steve = steve->next;
} }
} }
} }
@@ -414,8 +414,8 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt)
{ {
wmJob *steve; wmJob *steve;
for (steve= wm->jobs.first; steve; steve= steve->next) { for (steve = wm->jobs.first; steve; steve = steve->next) {
if (steve->wt==wt) { if (steve->wt == wt) {
wm_jobs_kill_job(wm, steve); wm_jobs_kill_job(wm, steve);
return; return;
} }
@@ -425,15 +425,15 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt)
/* hardcoded to event TIMERJOBS */ /* hardcoded to event TIMERJOBS */
void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
{ {
wmJob *steve= wm->jobs.first, *stevenext; wmJob *steve = wm->jobs.first, *stevenext;
float total_progress= 0.f; float total_progress = 0.f;
float jobs_progress=0; float jobs_progress = 0;
for (; steve; steve= stevenext) { for (; steve; steve = stevenext) {
stevenext= steve->next; stevenext = steve->next;
if (steve->wt==wt) { if (steve->wt == wt) {
/* running threads */ /* running threads */
if (steve->threads.first) { if (steve->threads.first) {
@@ -446,8 +446,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
WM_event_add_notifier(C, steve->note, NULL); WM_event_add_notifier(C, steve->note, NULL);
if (steve->flag & WM_JOB_PROGRESS) if (steve->flag & WM_JOB_PROGRESS)
WM_event_add_notifier(C, NC_WM|ND_JOB, NULL); WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
steve->do_update= 0; steve->do_update = 0;
} }
if (steve->ready) { if (steve->ready) {
@@ -456,19 +456,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
/* free own data */ /* free own data */
steve->run_free(steve->run_customdata); steve->run_free(steve->run_customdata);
steve->run_customdata= NULL; steve->run_customdata = NULL;
steve->run_free= NULL; steve->run_free = NULL;
// if (steve->stop) printf("job ready but stopped %s\n", steve->name); // if (steve->stop) printf("job ready but stopped %s\n", steve->name);
// else printf("job finished %s\n", steve->name); // else printf("job finished %s\n", steve->name);
steve->running= 0; steve->running = 0;
BLI_end_threads(&steve->threads); BLI_end_threads(&steve->threads);
if (steve->endnote) if (steve->endnote)
WM_event_add_notifier(C, steve->endnote, NULL); WM_event_add_notifier(C, steve->endnote, NULL);
WM_event_add_notifier(C, NC_WM|ND_JOB, NULL); WM_event_add_notifier(C, NC_WM | ND_JOB, NULL);
/* new job added for steve? */ /* new job added for steve? */
if (steve->customdata) { if (steve->customdata) {
@@ -477,7 +477,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
} }
else { else {
WM_event_remove_timer(wm, steve->win, steve->wt); WM_event_remove_timer(wm, steve->win, steve->wt);
steve->wt= NULL; steve->wt = NULL;
/* remove steve */ /* remove steve */
BLI_remlink(&wm->jobs, steve); BLI_remlink(&wm->jobs, steve);
@@ -520,7 +520,7 @@ int WM_jobs_has_running(wmWindowManager *wm)
{ {
wmJob *steve; wmJob *steve;
for (steve= wm->jobs.first; steve; steve= steve->next) for (steve = wm->jobs.first; steve; steve = steve->next)
if (steve->running) if (steve->running)
return 1; return 1;

View File

@@ -61,21 +61,21 @@
#include "wm_event_types.h" #include "wm_event_types.h"
/******************************* Keymap Item ********************************** /******************************* Keymap Item **********************************
* Item in a keymap, that maps from an event to an operator or modal map item */ * Item in a keymap, that maps from an event to an operator or modal map item */
static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi) static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
{ {
wmKeyMapItem *kmin = MEM_dupallocN(kmi); wmKeyMapItem *kmin = MEM_dupallocN(kmi);
kmin->prev= kmin->next= NULL; kmin->prev = kmin->next = NULL;
kmin->flag &= ~KMI_UPDATE; kmin->flag &= ~KMI_UPDATE;
if (kmin->properties) { if (kmin->properties) {
kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"); kmin->ptr = MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
WM_operator_properties_create(kmin->ptr, kmin->idname); WM_operator_properties_create(kmin->ptr, kmin->idname);
kmin->properties= IDP_CopyProperty(kmin->properties); kmin->properties = IDP_CopyProperty(kmin->properties);
kmin->ptr->data= kmin->properties; kmin->ptr->data = kmin->properties;
} }
return kmin; return kmin;
@@ -101,8 +101,8 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b)
if (strcmp(a->idname, b->idname) != 0) if (strcmp(a->idname, b->idname) != 0)
return 0; return 0;
if (!((a->ptr==NULL && b->ptr==NULL) || if (!((a->ptr == NULL && b->ptr == NULL) ||
(a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data)))) (a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data))))
return 0; return 0;
if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
@@ -172,7 +172,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname)
{ {
wmKeyConfig *keyconf; wmKeyConfig *keyconf;
keyconf= MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname)); BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname));
BLI_addtail(&wm->keyconfigs, keyconf); BLI_addtail(&wm->keyconfigs, keyconf);
@@ -205,7 +205,7 @@ void WM_keyconfig_free(wmKeyConfig *keyconf)
{ {
wmKeyMap *km; wmKeyMap *km;
while ((km= keyconf->keymaps.first)) { while ((km = keyconf->keymaps.first)) {
WM_keymap_free(km); WM_keymap_free(km);
BLI_freelinkN(&keyconf->keymaps, km); BLI_freelinkN(&keyconf->keymaps, km);
} }
@@ -217,8 +217,8 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
{ {
wmKeyConfig *kc; wmKeyConfig *kc;
for (kc= lb->first; kc; kc= kc->next) for (kc = lb->first; kc; kc = kc->next)
if (0==strncmp(idname, kc->idname, KMAP_MAX_NAME)) if (0 == strncmp(idname, kc->idname, KMAP_MAX_NAME))
return kc; return kc;
return NULL; return NULL;
@@ -229,7 +229,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
wmKeyConfig *keyconf; wmKeyConfig *keyconf;
/* first try from preset */ /* first try from preset */
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr); keyconf = wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
if (keyconf) if (keyconf)
return keyconf; return keyconf;
@@ -255,11 +255,11 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid) static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
{ {
wmKeyMap *km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list"); wmKeyMap *km = MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
BLI_strncpy(km->idname, idname, KMAP_MAX_NAME); BLI_strncpy(km->idname, idname, KMAP_MAX_NAME);
km->spaceid= spaceid; km->spaceid = spaceid;
km->regionid= regionid; km->regionid = regionid;
return km; return km;
} }
@@ -270,18 +270,18 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
wmKeyMapItem *kmi, *kmin; wmKeyMapItem *kmi, *kmin;
wmKeyMapDiffItem *kmdi, *kmdin; wmKeyMapDiffItem *kmdi, *kmdin;
keymapn->modal_items= keymap->modal_items; keymapn->modal_items = keymap->modal_items;
keymapn->poll= keymap->poll; keymapn->poll = keymap->poll;
keymapn->items.first= keymapn->items.last= NULL; keymapn->items.first = keymapn->items.last = NULL;
keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED); keymapn->flag &= ~(KEYMAP_UPDATE | KEYMAP_EXPANDED);
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) { for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
kmdin= wm_keymap_diff_item_copy(kmdi); kmdin = wm_keymap_diff_item_copy(kmdi);
BLI_addtail(&keymapn->items, kmdin); BLI_addtail(&keymapn->items, kmdin);
} }
for (kmi=keymap->items.first; kmi; kmi=kmi->next) { for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
kmin= wm_keymap_item_copy(kmi); kmin = wm_keymap_item_copy(kmi);
BLI_addtail(&keymapn->items, kmin); BLI_addtail(&keymapn->items, kmin);
} }
@@ -293,10 +293,10 @@ void WM_keymap_free(wmKeyMap *keymap)
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
wmKeyMapDiffItem *kmdi; wmKeyMapDiffItem *kmdi;
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next)
wm_keymap_diff_item_free(kmdi); wm_keymap_diff_item_free(kmdi);
for (kmi=keymap->items.first; kmi; kmi=kmi->next) for (kmi = keymap->items.first; kmi; kmi = kmi->next)
wm_keymap_item_free(kmi); wm_keymap_item_free(kmi);
BLI_freelistN(&keymap->diff_items); BLI_freelistN(&keymap->diff_items);
@@ -305,18 +305,18 @@ void WM_keymap_free(wmKeyMap *keymap)
static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier) static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier)
{ {
kmi->type= type; kmi->type = type;
kmi->val= val; kmi->val = val;
kmi->keymodifier= keymodifier; kmi->keymodifier = keymodifier;
if (modifier == KM_ANY) { if (modifier == KM_ANY) {
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY; kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
} }
else { else {
kmi->shift= (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE); kmi->shift = (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE);
kmi->ctrl= (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE); kmi->ctrl = (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE);
kmi->alt= (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE); kmi->alt = (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE);
kmi->oskey= (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE); kmi->oskey = (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE);
} }
} }
@@ -337,9 +337,9 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
for (kmi = keymap->items.first; kmi; kmi = kmi->next) for (kmi = keymap->items.first; kmi; kmi = kmi->next)
if (strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0) if (strncmp(kmi->idname, idname, OP_MAX_TYPENAME) == 0)
break; break;
if (kmi==NULL) { if (kmi == NULL) {
kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&keymap->items, kmi); BLI_addtail(&keymap->items, kmi);
@@ -402,7 +402,7 @@ static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
{ {
wmKeyMapItem *kmi, *kmin; wmKeyMapItem *kmi, *kmin;
for (kmi=addonmap->items.first; kmi; kmi=kmi->next) { for (kmi = addonmap->items.first; kmi; kmi = kmi->next) {
kmin = wm_keymap_item_copy(kmi); kmin = wm_keymap_item_copy(kmi);
keymap_item_set_id(keymap, kmin); keymap_item_set_id(keymap, kmin);
BLI_addhead(&keymap->items, kmin); BLI_addhead(&keymap->items, kmin);
@@ -413,7 +413,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need
{ {
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
for (kmi=km->items.first; kmi; kmi=kmi->next) for (kmi = km->items.first; kmi; kmi = kmi->next)
if (wm_keymap_item_equals(kmi, needle)) if (wm_keymap_item_equals(kmi, needle))
return kmi; return kmi;
@@ -424,7 +424,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte
{ {
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
for (kmi=km->items.first; kmi; kmi=kmi->next) for (kmi = km->items.first; kmi; kmi = kmi->next)
if (wm_keymap_item_equals_result(kmi, needle)) if (wm_keymap_item_equals_result(kmi, needle))
return kmi; return kmi;
@@ -436,7 +436,7 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km
wmKeyMapItem *kmi, *to_kmi, *orig_kmi; wmKeyMapItem *kmi, *to_kmi, *orig_kmi;
wmKeyMapDiffItem *kmdi; wmKeyMapDiffItem *kmdi;
for (kmi=from_km->items.first; kmi; kmi=kmi->next) { for (kmi = from_km->items.first; kmi; kmi = kmi->next) {
to_kmi = WM_keymap_item_find_id(to_km, kmi->id); to_kmi = WM_keymap_item_find_id(to_km, kmi->id);
if (!to_kmi) { if (!to_kmi) {
@@ -467,7 +467,7 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km
} }
} }
for (kmi=to_km->items.first; kmi; kmi=kmi->next) { for (kmi = to_km->items.first; kmi; kmi = kmi->next) {
if (kmi->id < 0) { if (kmi->id < 0) {
/* add item */ /* add item */
kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"); kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
@@ -482,7 +482,7 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
wmKeyMapDiffItem *kmdi; wmKeyMapDiffItem *kmdi;
wmKeyMapItem *kmi_remove, *kmi_add; wmKeyMapItem *kmi_remove, *kmi_add;
for (kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) { for (kmdi = diff_km->diff_items.first; kmdi; kmdi = kmdi->next) {
/* find item to remove */ /* find item to remove */
kmi_remove = NULL; kmi_remove = NULL;
if (kmdi->remove_item) { if (kmdi->remove_item) {
@@ -527,7 +527,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
/* remove previous keymap in list, we will replace it */ /* remove previous keymap in list, we will replace it */
km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid); km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid);
if (km) { if (km) {
expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED)); expanded = (km->flag & (KEYMAP_EXPANDED | KEYMAP_CHILDREN_EXPANDED));
WM_keymap_free(km); WM_keymap_free(km);
BLI_freelinkN(lb, km); BLI_freelinkN(lb, km);
} }
@@ -541,7 +541,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
km = wm_keymap_copy(usermap); km = wm_keymap_copy(usermap);
/* try to find corresponding id's for items */ /* try to find corresponding id's for items */
for (kmi=km->items.first; kmi; kmi=kmi->next) { for (kmi = km->items.first; kmi; kmi = kmi->next) {
orig_kmi = wm_keymap_find_item_equals(defaultmap, kmi); orig_kmi = wm_keymap_find_item_equals(defaultmap, kmi);
if (!orig_kmi) if (!orig_kmi)
orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi); orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi);
@@ -564,7 +564,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
/* tag as being user edited */ /* tag as being user edited */
if (usermap) if (usermap)
km->flag |= KEYMAP_USER_MODIFIED; km->flag |= KEYMAP_USER_MODIFIED;
km->flag |= KEYMAP_USER|expanded; km->flag |= KEYMAP_USER | expanded;
/* apply user changes of diff keymap */ /* apply user changes of diff keymap */
if (usermap && (usermap->flag & KEYMAP_DIFF)) if (usermap && (usermap->flag & KEYMAP_DIFF))
@@ -596,7 +596,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
} }
/* create diff keymap */ /* create diff keymap */
diffmap= wm_keymap_new(km->idname, km->spaceid, km->regionid); diffmap = wm_keymap_new(km->idname, km->spaceid, km->regionid);
diffmap->flag |= KEYMAP_DIFF; diffmap->flag |= KEYMAP_DIFF;
if (defaultmap->flag & KEYMAP_MODAL) if (defaultmap->flag & KEYMAP_MODAL)
diffmap->flag |= KEYMAP_MODAL; diffmap->flag |= KEYMAP_MODAL;
@@ -628,9 +628,9 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
{ {
wmKeyMap *km; wmKeyMap *km;
for (km= lb->first; km; km= km->next) for (km = lb->first; km; km = km->next)
if (km->spaceid==spaceid && km->regionid==regionid) if (km->spaceid == spaceid && km->regionid == regionid)
if (0==strncmp(idname, km->idname, KMAP_MAX_NAME)) if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME))
return km; return km;
return NULL; return NULL;
@@ -638,10 +638,10 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
{ {
wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
if (km==NULL) { if (km == NULL) {
km= wm_keymap_new(idname, spaceid, regionid); km = wm_keymap_new(idname, spaceid, regionid);
BLI_addtail(&keyconf->keymaps, km); BLI_addtail(&keyconf->keymaps, km);
WM_keyconfig_update_tag(km, NULL); WM_keyconfig_update_tag(km, NULL);
@@ -652,7 +652,7 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid,
wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid) wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid); return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid);
} }
@@ -663,14 +663,14 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid,
wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPropertyItem *items) wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPropertyItem *items)
{ {
wmKeyMap *km= WM_keymap_find(keyconf, idname, 0, 0); wmKeyMap *km = WM_keymap_find(keyconf, idname, 0, 0);
km->flag |= KEYMAP_MODAL; km->flag |= KEYMAP_MODAL;
km->modal_items= items; km->modal_items = items;
if (!items) { if (!items) {
/* init modal items from default config */ /* init modal items from default config */
wmWindowManager *wm = G.main->wm.first; wmWindowManager *wm = G.main->wm.first;
wmKeyMap *defaultkm= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
if (defaultkm) { if (defaultkm) {
km->modal_items = defaultkm->modal_items; km->modal_items = defaultkm->modal_items;
@@ -685,9 +685,9 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
{ {
wmKeyMap *km; wmKeyMap *km;
for (km= keyconf->keymaps.first; km; km= km->next) for (km = keyconf->keymaps.first; km; km = km->next)
if (km->flag & KEYMAP_MODAL) if (km->flag & KEYMAP_MODAL)
if (0==strncmp(idname, km->idname, KMAP_MAX_NAME)) if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME))
break; break;
return km; return km;
@@ -699,7 +699,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&km->items, kmi); BLI_addtail(&km->items, kmi);
kmi->propvalue= value; kmi->propvalue = value;
keymap_event_set(kmi, type, val, modifier, keymodifier); keymap_event_set(kmi, type, val, modifier, keymodifier);
@@ -712,7 +712,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
{ {
wmOperatorType *ot= WM_operatortype_find(opname, 0); wmOperatorType *ot = WM_operatortype_find(opname, 0);
if (ot) if (ot)
ot->modalkeymap = km; ot->modalkeymap = km;
@@ -724,7 +724,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
const char *WM_key_event_string(short type) const char *WM_key_event_string(short type)
{ {
const char *name= NULL; const char *name = NULL;
if (RNA_enum_name(event_type_items, (int)type, &name)) if (RNA_enum_name(event_type_items, (int)type, &name))
return name; return name;
@@ -735,12 +735,12 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
{ {
char buf[128]; char buf[128];
buf[0]= 0; buf[0] = 0;
if (kmi->shift == KM_ANY && if (kmi->shift == KM_ANY &&
kmi->ctrl == KM_ANY && kmi->ctrl == KM_ANY &&
kmi->alt == KM_ANY && kmi->alt == KM_ANY &&
kmi->oskey == KM_ANY) { kmi->oskey == KM_ANY) {
strcat(buf, "Any "); strcat(buf, "Any ");
} }
@@ -770,20 +770,20 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
} }
static wmKeyMapItem *wm_keymap_item_find_handlers( static wmKeyMapItem *wm_keymap_item_find_handlers(
const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler; wmEventHandler *handler;
wmKeyMap *keymap; wmKeyMap *keymap;
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
/* find keymap item in handlers */ /* find keymap item in handlers */
for (handler=handlers->first; handler; handler=handler->next) { for (handler = handlers->first; handler; handler = handler->next) {
keymap= WM_keymap_active(wm, handler->keymap); keymap = WM_keymap_active(wm, handler->keymap);
if (keymap && (!keymap->poll || keymap->poll((bContext*)C))) { if (keymap && (!keymap->poll || keymap->poll((bContext *)C))) {
for (kmi=keymap->items.first; kmi; kmi=kmi->next) { for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) { if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
if (hotkey) if (hotkey)
@@ -792,12 +792,12 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (compare_props) { if (compare_props) {
if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) { if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
if (keymap_r) *keymap_r= keymap; if (keymap_r) *keymap_r = keymap;
return kmi; return kmi;
} }
} }
else { else {
if (keymap_r) *keymap_r= keymap; if (keymap_r) *keymap_r = keymap;
return kmi; return kmi;
} }
} }
@@ -806,54 +806,54 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
} }
/* ensure un-initialized keymap is never used */ /* ensure un-initialized keymap is never used */
if (keymap_r) *keymap_r= NULL; if (keymap_r) *keymap_r = NULL;
return NULL; return NULL;
} }
static wmKeyMapItem *wm_keymap_item_find_props( static wmKeyMapItem *wm_keymap_item_find_props(
const bContext *C, const char *opname, int opcontext, const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{ {
wmWindow *win= CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
wmKeyMapItem *found= NULL; wmKeyMapItem *found = NULL;
/* look into multiple handler lists to find the item */ /* look into multiple handler lists to find the item */
if (win) if (win)
found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
if (sa && found==NULL) if (sa && found == NULL)
found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
if (found==NULL) { if (found == NULL) {
if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
if (sa) { if (sa) {
if (!(ar && ar->regiontype == RGN_TYPE_WINDOW)) if (!(ar && ar->regiontype == RGN_TYPE_WINDOW))
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar) if (ar)
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
} }
} }
else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS)) if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS))
ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); ar = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
if (ar) if (ar)
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
} }
else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW)) if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW))
ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
if (ar) if (ar)
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
} }
else { else {
if (ar) if (ar)
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
} }
} }
@@ -861,20 +861,20 @@ static wmKeyMapItem *wm_keymap_item_find_props(
} }
static wmKeyMapItem *wm_keymap_item_find( static wmKeyMapItem *wm_keymap_item_find(
const bContext *C, const char *opname, int opcontext, const bContext *C, const char *opname, int opcontext,
IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r) IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r)
{ {
wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r); wmKeyMapItem *found = wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
if (!found && sloppy) if (!found && sloppy)
found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r); found = wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r);
return found; return found;
} }
char *WM_key_event_operator_string( char *WM_key_event_operator_string(
const bContext *C, const char *opname, int opcontext, const bContext *C, const char *opname, int opcontext,
IDProperty *properties, const short sloppy, char *str, int len) IDProperty *properties, const short sloppy, char *str, int len)
{ {
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL); wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL);
@@ -887,8 +887,8 @@ char *WM_key_event_operator_string(
} }
int WM_key_event_operator_id( int WM_key_event_operator_id(
const bContext *C, const char *opname, int opcontext, const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int hotkey, wmKeyMap **keymap_r) IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
{ {
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r); wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r);
@@ -898,7 +898,7 @@ int WM_key_event_operator_id(
return 0; return 0;
} }
int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
{ {
int k1type, k2type; int k1type, k2type;
@@ -950,7 +950,7 @@ static int WM_KEYMAP_UPDATE = 0;
void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi) void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi)
{ {
/* quick tag to do delayed keymap updates */ /* quick tag to do delayed keymap updates */
WM_KEYMAP_UPDATE= 1; WM_KEYMAP_UPDATE = 1;
if (km) if (km)
km->flag |= KEYMAP_UPDATE; km->flag |= KEYMAP_UPDATE;
@@ -963,11 +963,11 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km)
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
int update; int update;
update= (km->flag & KEYMAP_UPDATE); update = (km->flag & KEYMAP_UPDATE);
km->flag &= ~KEYMAP_UPDATE; km->flag &= ~KEYMAP_UPDATE;
for (kmi=km->items.first; kmi; kmi=kmi->next) { for (kmi = km->items.first; kmi; kmi = kmi->next) {
update= update || (kmi->flag & KMI_UPDATE); update = update || (kmi->flag & KMI_UPDATE);
kmi->flag &= ~KMI_UPDATE; kmi->flag &= ~KMI_UPDATE;
} }
@@ -976,12 +976,12 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km)
static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km) static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km)
{ {
wmKeyConfig *keyconf= WM_keyconfig_active(wm); wmKeyConfig *keyconf = WM_keyconfig_active(wm);
wmKeyMap *keymap; wmKeyMap *keymap;
keymap= WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid); keymap = WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid);
if (!keymap) if (!keymap)
keymap= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid); keymap = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
return keymap; return keymap;
} }
@@ -999,27 +999,27 @@ void WM_keyconfig_update(wmWindowManager *wm)
return; return;
/* update operator properties for non-modal user keymaps */ /* update operator properties for non-modal user keymaps */
for (km=U.user_keymaps.first; km; km=km->next) { for (km = U.user_keymaps.first; km; km = km->next) {
if ((km->flag & KEYMAP_MODAL) == 0) { if ((km->flag & KEYMAP_MODAL) == 0) {
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
if (kmdi->add_item) if (kmdi->add_item)
wm_keymap_item_properties_set(kmdi->add_item); wm_keymap_item_properties_set(kmdi->add_item);
if (kmdi->remove_item) if (kmdi->remove_item)
wm_keymap_item_properties_set(kmdi->remove_item); wm_keymap_item_properties_set(kmdi->remove_item);
} }
for (kmi=km->items.first; kmi; kmi=kmi->next) for (kmi = km->items.first; kmi; kmi = kmi->next)
wm_keymap_item_properties_set(kmi); wm_keymap_item_properties_set(kmi);
} }
} }
/* update U.user_keymaps with user key configuration changes */ /* update U.user_keymaps with user key configuration changes */
for (km=wm->userconf->keymaps.first; km; km=km->next) { for (km = wm->userconf->keymaps.first; km; km = km->next) {
/* only diff if the user keymap was modified */ /* only diff if the user keymap was modified */
if (wm_keymap_test_and_clear_update(km)) { if (wm_keymap_test_and_clear_update(km)) {
/* find keymaps */ /* find keymaps */
defaultmap= wm_keymap_preset(wm, km); defaultmap = wm_keymap_preset(wm, km);
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
/* diff */ /* diff */
if (defaultmap) if (defaultmap)
@@ -1028,25 +1028,25 @@ void WM_keyconfig_update(wmWindowManager *wm)
} }
/* create user key configuration from preset + addon + user preferences */ /* create user key configuration from preset + addon + user preferences */
for (km=wm->defaultconf->keymaps.first; km; km=km->next) { for (km = wm->defaultconf->keymaps.first; km; km = km->next) {
/* find keymaps */ /* find keymaps */
defaultmap= wm_keymap_preset(wm, km); defaultmap = wm_keymap_preset(wm, km);
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
usermap= WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid); usermap = WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid);
/* add */ /* add */
kmn= wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap); kmn = wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap);
if (kmn) { if (kmn) {
kmn->modal_items= km->modal_items; kmn->modal_items = km->modal_items;
kmn->poll= km->poll; kmn->poll = km->poll;
} }
/* in case of old non-diff keymaps, force extra update to create diffs */ /* in case of old non-diff keymaps, force extra update to create diffs */
compat_update = compat_update || (usermap && !(usermap->flag & KEYMAP_DIFF)); compat_update = compat_update || (usermap && !(usermap->flag & KEYMAP_DIFF));
} }
WM_KEYMAP_UPDATE= 0; WM_KEYMAP_UPDATE = 0;
if (compat_update) { if (compat_update) {
WM_keyconfig_update_tag(NULL, NULL); WM_keyconfig_update_tag(NULL, NULL);
@@ -1067,7 +1067,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
return NULL; return NULL;
/* first user defined keymaps */ /* first user defined keymaps */
km= WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); km = WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (km) if (km)
return km; return km;
@@ -1088,8 +1088,8 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
return; return;
/* construct default keymap from preset + addons */ /* construct default keymap from preset + addons */
defaultmap= wm_keymap_preset(wm, keymap); defaultmap = wm_keymap_preset(wm, keymap);
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (addonmap) { if (addonmap) {
defaultmap = wm_keymap_copy(defaultmap); defaultmap = wm_keymap_copy(defaultmap);
@@ -1110,11 +1110,11 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
if (kmi->properties) { if (kmi->properties) {
IDP_FreeProperty(kmi->properties); IDP_FreeProperty(kmi->properties);
MEM_freeN(kmi->properties); MEM_freeN(kmi->properties);
kmi->properties= NULL; kmi->properties = NULL;
} }
kmi->properties= IDP_CopyProperty(orig->properties); kmi->properties = IDP_CopyProperty(orig->properties);
kmi->ptr->data= kmi->properties; kmi->ptr->data = kmi->properties;
} }
kmi->propvalue = orig->propvalue; kmi->propvalue = orig->propvalue;
@@ -1143,7 +1143,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C)
wmKeyMap *usermap; wmKeyMap *usermap;
/* remove keymap from U.user_keymaps and update */ /* remove keymap from U.user_keymaps and update */
usermap= WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid); usermap = WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (usermap) { if (usermap) {
WM_keymap_free(usermap); WM_keymap_free(usermap);
@@ -1158,7 +1158,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
{ {
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
for (kmi=keymap->items.first; kmi; kmi=kmi->next) { for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (kmi->id == id) { if (kmi->id == id) {
return kmi; return kmi;
} }
@@ -1171,7 +1171,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
/* Needs to be kept up to date with Keymap and Operator naming */ /* Needs to be kept up to date with Keymap and Operator naming */
wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
{ {
wmKeyMap *km=NULL; wmKeyMap *km = NULL;
SpaceLink *sl = CTX_wm_space_data(C); SpaceLink *sl = CTX_wm_space_data(C);
/* Window */ /* Window */
@@ -1206,7 +1206,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Mesh", 0, 0); km = WM_keymap_find_all(C, "Mesh", 0, 0);
/* some mesh operators are active in object mode too, like add-prim */ /* some mesh operators are active in object mode too, like add-prim */
if (km && km->poll && km->poll((bContext *)C)==0) { if (km && km->poll && km->poll((bContext *)C) == 0) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0); km = WM_keymap_find_all(C, "Object Mode", 0, 0);
} }
} }
@@ -1214,7 +1214,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Curve", 0, 0); km = WM_keymap_find_all(C, "Curve", 0, 0);
/* some curve operators are active in object mode too, like add-prim */ /* some curve operators are active in object mode too, like add-prim */
if (km && km->poll && km->poll((bContext *)C)==0) { if (km && km->poll && km->poll((bContext *)C) == 0) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0); km = WM_keymap_find_all(C, "Object Mode", 0, 0);
} }
} }
@@ -1225,7 +1225,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Pose", 0, 0); km = WM_keymap_find_all(C, "Pose", 0, 0);
} }
else if (strstr(opname, "SCULPT_OT")) { else if (strstr(opname, "SCULPT_OT")) {
switch(CTX_data_mode_enum(C)) { switch (CTX_data_mode_enum(C)) {
case OB_MODE_SCULPT: case OB_MODE_SCULPT:
km = WM_keymap_find_all(C, "Sculpt", 0, 0); km = WM_keymap_find_all(C, "Sculpt", 0, 0);
break; break;
@@ -1238,7 +1238,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Metaball", 0, 0); km = WM_keymap_find_all(C, "Metaball", 0, 0);
/* some mball operators are active in object mode too, like add-prim */ /* some mball operators are active in object mode too, like add-prim */
if (km && km->poll && km->poll((bContext *)C)==0) { if (km && km->poll && km->poll((bContext *)C) == 0) {
km = WM_keymap_find_all(C, "Object Mode", 0, 0); km = WM_keymap_find_all(C, "Object Mode", 0, 0);
} }
} }
@@ -1254,7 +1254,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (strstr(opname, "PAINT_OT")) { else if (strstr(opname, "PAINT_OT")) {
/* check for relevant mode */ /* check for relevant mode */
switch(CTX_data_mode_enum(C)) { switch (CTX_data_mode_enum(C)) {
case OB_MODE_WEIGHT_PAINT: case OB_MODE_WEIGHT_PAINT:
km = WM_keymap_find_all(C, "Weight Paint", 0, 0); km = WM_keymap_find_all(C, "Weight Paint", 0, 0);
break; break;
@@ -1331,7 +1331,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (strstr(opname, "TRANSFORM_OT")) { else if (strstr(opname, "TRANSFORM_OT")) {
/* check for relevant editor */ /* check for relevant editor */
switch(sl->spacetype) { switch (sl->spacetype) {
case SPACE_VIEW3D: case SPACE_VIEW3D:
km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0); km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
break; break;

File diff suppressed because it is too large Load Diff

View File

@@ -87,7 +87,7 @@ void wm_subwindows_free(wmWindow *win)
{ {
wmSubWindow *swin; wmSubWindow *swin;
for (swin= win->subwindows.first; swin; swin= swin->next) for (swin = win->subwindows.first; swin; swin = swin->next)
wm_subwindow_free(swin); wm_subwindow_free(swin);
BLI_freelistN(&win->subwindows); BLI_freelistN(&win->subwindows);
@@ -105,35 +105,35 @@ static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
{ {
wmSubWindow *swin; wmSubWindow *swin;
for (swin= win->subwindows.first; swin; swin= swin->next) for (swin = win->subwindows.first; swin; swin = swin->next)
if (swin->swinid==swinid) if (swin->swinid == swinid)
break; break;
return swin; return swin;
} }
void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y) void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y)
{ {
wmSubWindow *swin= swin_from_swinid(win, swinid); wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) { if (swin) {
*x= swin->winrct.xmax - swin->winrct.xmin + 1; *x = swin->winrct.xmax - swin->winrct.xmin + 1;
*y= swin->winrct.ymax - swin->winrct.ymin + 1; *y = swin->winrct.ymax - swin->winrct.ymin + 1;
} }
} }
void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y) void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y)
{ {
wmSubWindow *swin= swin_from_swinid(win, swinid); wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) { if (swin) {
*x= swin->winrct.xmin; *x = swin->winrct.xmin;
*y= swin->winrct.ymin; *y = swin->winrct.ymin;
} }
} }
void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4])
{ {
wmSubWindow *swin= swin_from_swinid(win, swinid); wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) { if (swin) {
/* used by UI, should find a better way to get the matrix there */ /* used by UI, should find a better way to get the matrix there */
@@ -141,10 +141,10 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4])
int width, height; int width, height;
wm_subwindow_getsize(win, swin->swinid, &width, &height); wm_subwindow_getsize(win, swin->swinid, &width, &height);
orthographic_m4(mat, -0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f, -100, 100); orthographic_m4(mat, -0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f, -100, 100);
} }
else else
glGetFloatv(GL_PROJECTION_MATRIX, (float*)mat); glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat);
} }
} }
@@ -154,25 +154,25 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
{ {
wmSubWindow *swin; wmSubWindow *swin;
int width, height; int width, height;
int freewinid= 1; int freewinid = 1;
for (swin= win->subwindows.first; swin; swin= swin->next) for (swin = win->subwindows.first; swin; swin = swin->next)
if (freewinid <= swin->swinid) if (freewinid <= swin->swinid)
freewinid= swin->swinid+1; freewinid = swin->swinid + 1;
win->curswin= swin= MEM_callocN(sizeof(wmSubWindow), "swinopen"); win->curswin = swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
BLI_addtail(&win->subwindows, swin); BLI_addtail(&win->subwindows, swin);
if (G.f & G_DEBUG) printf("swin %d added\n", freewinid); if (G.f & G_DEBUG) printf("swin %d added\n", freewinid);
swin->swinid= freewinid; swin->swinid = freewinid;
swin->winrct= *winrct; swin->winrct = *winrct;
/* and we appy it all right away */ /* and we appy it all right away */
wmSubWindowSet(win, swin->swinid); wmSubWindowSet(win, swin->swinid);
/* extra service */ /* extra service */
wm_subwindow_getsize(win, swin->swinid, &width, &height); wm_subwindow_getsize(win, swin->swinid, &width, &height);
wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
glLoadIdentity(); glLoadIdentity();
return swin->swinid; return swin->swinid;
@@ -181,11 +181,11 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
void wm_subwindow_close(wmWindow *win, int swinid) void wm_subwindow_close(wmWindow *win, int swinid)
{ {
wmSubWindow *swin= swin_from_swinid(win, swinid); wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) { if (swin) {
if (swin==win->curswin) if (swin == win->curswin)
win->curswin= NULL; win->curswin = NULL;
wm_subwindow_free(swin); wm_subwindow_free(swin);
BLI_remlink(&win->subwindows, swin); BLI_remlink(&win->subwindows, swin);
MEM_freeN(swin); MEM_freeN(swin);
@@ -199,12 +199,12 @@ void wm_subwindow_close(wmWindow *win, int swinid)
/* pixels go from 0-99 for a 100 pixel window */ /* pixels go from 0-99 for a 100 pixel window */
void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
{ {
wmSubWindow *swin= swin_from_swinid(win, swinid); wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) { if (swin) {
int width, height; int width, height;
swin->winrct= *winrct; swin->winrct = *winrct;
/* CRITICAL, this clamping ensures that /* CRITICAL, this clamping ensures that
* the viewport never goes outside the screen * the viewport never goes outside the screen
@@ -227,7 +227,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
/* extra service */ /* extra service */
wmSubWindowSet(win, swinid); wmSubWindowSet(win, swinid);
wm_subwindow_getsize(win, swinid, &width, &height); wm_subwindow_getsize(win, swinid, &width, &height);
wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
} }
else { else {
printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid); printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid);
@@ -238,35 +238,35 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
/* ----------------- exported in WM_api.h ------------------------------------------------------ */ /* ----------------- exported in WM_api.h ------------------------------------------------------ */
/* internal state, no threaded opengl! XXX */ /* internal state, no threaded opengl! XXX */
static wmWindow *_curwindow= NULL; static wmWindow *_curwindow = NULL;
static wmSubWindow *_curswin= NULL; static wmSubWindow *_curswin = NULL;
void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
{ {
int width, height; int width, height;
_curswin= swin_from_swinid(win, swinid); _curswin = swin_from_swinid(win, swinid);
if (_curswin==NULL) { if (_curswin == NULL) {
printf("wmSubWindowSet %d: doesn't exist\n", swinid); printf("wmSubWindowSet %d: doesn't exist\n", swinid);
return; return;
} }
win->curswin= _curswin; win->curswin = _curswin;
_curwindow= win; _curwindow = win;
width= _curswin->winrct.xmax - _curswin->winrct.xmin + 1; width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1;
height= _curswin->winrct.ymax - _curswin->winrct.ymin + 1; height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) { if (srct) {
width= srct->xmax - srct->xmin + 1; width = srct->xmax - srct->xmin + 1;
height= srct->ymax - srct->ymin + 1; height = srct->ymax - srct->ymin + 1;
glScissor(srct->xmin, srct->ymin, width, height); glScissor(srct->xmin, srct->ymin, width, height);
} }
else else
glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
glLoadIdentity(); glLoadIdentity();
glFlush(); glFlush();
@@ -300,8 +300,8 @@ void wmOrtho(float x1, float x2, float y1, float y2, float n, float f)
void wmOrtho2(float x1, float x2, float y1, float y2) void wmOrtho2(float x1, float x2, float y1, float y2)
{ {
/* prevent opengl from generating errors */ /* prevent opengl from generating errors */
if (x1==x2) x2+=1.0f; if (x1 == x2) x2 += 1.0f;
if (y1==y2) y2+=1.0f; if (y1 == y2) y2 += 1.0f;
wmOrtho(x1, x2, y1, y2, -100, 100); wmOrtho(x1, x2, y1, y2, -100, 100);
} }
@@ -314,25 +314,25 @@ void wmOrtho2(float x1, float x2, float y1, float y2)
unsigned int index_to_framebuffer(int index) unsigned int index_to_framebuffer(int index)
{ {
unsigned int i= index; unsigned int i = index;
switch(GPU_color_depth()) { switch (GPU_color_depth()) {
case 12: case 12:
i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4); i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
/* sometimes dithering subtracts! */ /* sometimes dithering subtracts! */
i |= 0x070707; i |= 0x070707;
break; break;
case 15: case 15:
case 16: case 16:
i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3); i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
i |= 0x030303; i |= 0x030303;
break; break;
case 24: case 24:
break; break;
default: // 18 bits... default: // 18 bits...
i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2); i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
i |= 0x010101; i |= 0x010101;
break; break;
} }
return i; return i;
@@ -344,27 +344,27 @@ unsigned int index_to_framebuffer(int index)
unsigned int index_to_framebuffer(int index) unsigned int index_to_framebuffer(int index)
{ {
unsigned int i= index; unsigned int i = index;
switch(GPU_color_depth()) { switch (GPU_color_depth()) {
case 8: case 8:
i= ((i & 48)<<18) + ((i & 12)<<12) + ((i & 3)<<6); i = ((i & 48) << 18) + ((i & 12) << 12) + ((i & 3) << 6);
i |= 0x3F3F3F; i |= 0x3F3F3F;
break; break;
case 12: case 12:
i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4); i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
/* sometimes dithering subtracts! */ /* sometimes dithering subtracts! */
i |= 0x0F0F0F; i |= 0x0F0F0F;
break; break;
case 15: case 15:
case 16: case 16:
i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3); i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
i |= 0x070707; i |= 0x070707;
break; break;
case 24: case 24:
break; break;
default: // 18 bits... default: // 18 bits...
i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2); i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
i |= 0x030303; i |= 0x030303;
break; break;
} }
@@ -376,26 +376,26 @@ unsigned int index_to_framebuffer(int index)
void WM_set_framebuffer_index_color(int index) void WM_set_framebuffer_index_color(int index)
{ {
const int col= index_to_framebuffer(index); const int col = index_to_framebuffer(index);
cpack(col); cpack(col);
} }
int WM_framebuffer_to_index(unsigned int col) int WM_framebuffer_to_index(unsigned int col)
{ {
if (col==0) return 0; if (col == 0) return 0;
switch(GPU_color_depth()) { switch (GPU_color_depth()) {
case 8: case 8:
return ((col & 0xC00000)>>18) + ((col & 0xC000)>>12) + ((col & 0xC0)>>6); return ((col & 0xC00000) >> 18) + ((col & 0xC000) >> 12) + ((col & 0xC0) >> 6);
case 12: case 12:
return ((col & 0xF00000)>>12) + ((col & 0xF000)>>8) + ((col & 0xF0)>>4); return ((col & 0xF00000) >> 12) + ((col & 0xF000) >> 8) + ((col & 0xF0) >> 4);
case 15: case 15:
case 16: case 16:
return ((col & 0xF80000)>>9) + ((col & 0xF800)>>6) + ((col & 0xF8)>>3); return ((col & 0xF80000) >> 9) + ((col & 0xF800) >> 6) + ((col & 0xF8) >> 3);
case 24: case 24:
return col & 0xFFFFFF; return col & 0xFFFFFF;
default: // 18 bits... default: // 18 bits...
return ((col & 0xFC0000)>>6) + ((col & 0xFC00)>>4) + ((col & 0xFC)>>2); return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2);
} }
} }

View File

@@ -76,7 +76,7 @@
#include "UI_interface.h" #include "UI_interface.h"
/* the global to talk to ghost */ /* the global to talk to ghost */
static GHOST_SystemHandle g_system= NULL; static GHOST_SystemHandle g_system = NULL;
typedef enum WinOverrideFlag { typedef enum WinOverrideFlag {
WIN_OVERRIDE_GEOM = (1 << 0), WIN_OVERRIDE_GEOM = (1 << 0),
@@ -103,8 +103,8 @@ void wm_get_screensize(int *width_r, int *height_r)
unsigned int uiheight; unsigned int uiheight;
GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight); GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight);
*width_r= uiwidth; *width_r = uiwidth;
*height_r= uiheight; *height_r = uiheight;
} }
/* keeps offset and size within monitor bounds */ /* keeps offset and size within monitor bounds */
@@ -128,12 +128,12 @@ static void wm_window_check_position(rcti *rect)
rect->ymin = 0; rect->ymin = 0;
} }
if (rect->xmax > width) { if (rect->xmax > width) {
d= rect->xmax - width; d = rect->xmax - width;
rect->xmax -= d; rect->xmax -= d;
rect->xmin -= d; rect->xmin -= d;
} }
if (rect->ymax > height) { if (rect->ymax > height) {
d= rect->ymax - height; d = rect->ymax - height;
rect->ymax -= d; rect->ymax -= d;
rect->ymin -= d; rect->ymin -= d;
} }
@@ -147,7 +147,7 @@ static void wm_ghostwindow_destroy(wmWindow *win)
{ {
if (win->ghostwin) { if (win->ghostwin) {
GHOST_DisposeWindow(g_system, win->ghostwin); GHOST_DisposeWindow(g_system, win->ghostwin);
win->ghostwin= NULL; win->ghostwin = NULL;
} }
} }
@@ -162,26 +162,26 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers); WM_event_remove_handlers(C, &win->modalhandlers);
if (CTX_wm_window(C)==win) if (CTX_wm_window(C) == win)
CTX_wm_window_set(C, NULL); CTX_wm_window_set(C, NULL);
} }
/* always set drawable and active to NULL, /* always set drawable and active to NULL,
* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
wm->windrawable= NULL; wm->windrawable = NULL;
wm->winactive= NULL; wm->winactive = NULL;
/* end running jobs, a job end also removes its timer */ /* end running jobs, a job end also removes its timer */
for (wt= wm->timers.first; wt; wt= wtnext) { for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext= wt->next; wtnext = wt->next;
if (wt->win==win && wt->event_type==TIMERJOBS) if (wt->win == win && wt->event_type == TIMERJOBS)
wm_jobs_timer_ended(wm, wt); wm_jobs_timer_ended(wm, wt);
} }
/* timer removing, need to call this api function */ /* timer removing, need to call this api function */
for (wt= wm->timers.first; wt; wt=wtnext) { for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext= wt->next; wtnext = wt->next;
if (wt->win==win) if (wt->win == win)
WM_event_remove_timer(wm, win, wt); WM_event_remove_timer(wm, win, wt);
} }
@@ -201,11 +201,11 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
static int find_free_winid(wmWindowManager *wm) static int find_free_winid(wmWindowManager *wm)
{ {
wmWindow *win; wmWindow *win;
int id= 1; int id = 1;
for (win= wm->windows.first; win; win= win->next) for (win = wm->windows.first; win; win = win->next)
if (id <= win->winid) if (id <= win->winid)
id= win->winid+1; id = win->winid + 1;
return id; return id;
} }
@@ -213,11 +213,11 @@ static int find_free_winid(wmWindowManager *wm)
/* don't change context itself */ /* don't change context itself */
wmWindow *wm_window_new(bContext *C) wmWindow *wm_window_new(bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win= MEM_callocN(sizeof(wmWindow), "window"); wmWindow *win = MEM_callocN(sizeof(wmWindow), "window");
BLI_addtail(&wm->windows, win); BLI_addtail(&wm->windows, win);
win->winid= find_free_winid(wm); win->winid = find_free_winid(wm);
return win; return win;
} }
@@ -226,23 +226,23 @@ wmWindow *wm_window_new(bContext *C)
/* part of wm_window.c api */ /* part of wm_window.c api */
wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
{ {
wmWindow *win= wm_window_new(C); wmWindow *win = wm_window_new(C);
win->posx= winorig->posx+10; win->posx = winorig->posx + 10;
win->posy= winorig->posy; win->posy = winorig->posy;
win->sizex= winorig->sizex; win->sizex = winorig->sizex;
win->sizey= winorig->sizey; win->sizey = winorig->sizey;
/* duplicate assigns to window */ /* duplicate assigns to window */
win->screen= ED_screen_duplicate(win, winorig->screen); win->screen = ED_screen_duplicate(win, winorig->screen);
BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname)); BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
win->screen->winid= win->winid; win->screen->winid = win->winid;
win->screen->do_refresh= 1; win->screen->do_refresh = 1;
win->screen->do_draw= 1; win->screen->do_draw = 1;
win->drawmethod= -1; win->drawmethod = -1;
win->drawdata= NULL; win->drawdata = NULL;
return win; return win;
} }
@@ -251,7 +251,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{ {
wmWindow *tmpwin; wmWindow *tmpwin;
bScreen *screen= win->screen; bScreen *screen = win->screen;
/* first check if we have any non-temp remaining windows */ /* first check if we have any non-temp remaining windows */
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) { if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) {
@@ -272,7 +272,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
BLI_remlink(&wm->windows, win); BLI_remlink(&wm->windows, win);
wm_draw_window_clear(win); wm_draw_window_clear(win);
CTX_wm_window_set(C, win); /* needed by handlers */ CTX_wm_window_set(C, win); /* needed by handlers */
WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->handlers);
WM_event_remove_handlers(C, &win->modalhandlers); WM_event_remove_handlers(C, &win->modalhandlers);
ED_screen_exit(C, win, win->screen); ED_screen_exit(C, win, win->screen);
@@ -281,17 +281,17 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
/* if temp screen, delete it after window free (it stops jobs that can access it) */ /* if temp screen, delete it after window free (it stops jobs that can access it) */
if (screen->temp) { if (screen->temp) {
Main *bmain= CTX_data_main(C); Main *bmain = CTX_data_main(C);
free_libblock(&bmain->screen, screen); free_libblock(&bmain->screen, screen);
} }
/* check remaining windows */ /* check remaining windows */
if (wm->windows.first) { if (wm->windows.first) {
for (win= wm->windows.first; win; win= win->next) for (win = wm->windows.first; win; win = win->next)
if (win->screen->temp == 0) if (win->screen->temp == 0)
break; break;
/* in this case we close all */ /* in this case we close all */
if (win==NULL) if (win == NULL)
WM_exit(C); WM_exit(C);
} }
else else
@@ -302,8 +302,8 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
{ {
/* handle the 'temp' window, only set title when not set before */ /* handle the 'temp' window, only set title when not set before */
if (win->screen && win->screen->temp) { if (win->screen && win->screen->temp) {
char *title= GHOST_GetTitle(win->ghostwin); char *title = GHOST_GetTitle(win->ghostwin);
if (title==NULL || title[0]==0) if (title == NULL || title[0] == 0)
GHOST_SetTitle(win->ghostwin, "Blender"); GHOST_SetTitle(win->ghostwin, "Blender");
} }
else { else {
@@ -311,7 +311,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
/* this is set to 1 if you don't have startup.blend open */ /* this is set to 1 if you don't have startup.blend open */
if (G.save_over && G.main->name[0]) { if (G.save_over && G.main->name[0]) {
char str[sizeof(G.main->name) + 12]; char str[sizeof(G.main->name) + 12];
BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "":"*", G.main->name); BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "" : "*", G.main->name);
GHOST_SetTitle(win->ghostwin, str); GHOST_SetTitle(win->ghostwin, str);
} }
else else
@@ -320,7 +320,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
/* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X) /* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X)
* and to give hint of unsaved changes for a user warning mechanism * and to give hint of unsaved changes for a user warning mechanism
* in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */
GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8)!wm->file_saved); GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved);
#if defined(__APPLE__) && !defined(GHOST_COCOA) #if defined(__APPLE__) && !defined(GHOST_COCOA)
if (wm->file_saved) if (wm->file_saved)
@@ -338,7 +338,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
int scr_w, scr_h, posy; int scr_w, scr_h, posy;
wm_get_screensize(&scr_w, &scr_h); wm_get_screensize(&scr_w, &scr_h);
posy= (scr_h - win->posy - win->sizey); posy = (scr_h - win->posy - win->sizey);
#if defined(__APPLE__) && !defined(GHOST_COCOA) #if defined(__APPLE__) && !defined(GHOST_COCOA)
{ {
@@ -348,12 +348,12 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
#endif #endif
/* Disable AA for now, as GL_SELECT (used for border, lasso, ... select) /* Disable AA for now, as GL_SELECT (used for border, lasso, ... select)
* doesn't work well when AA is initialized, even if not used. */ * doesn't work well when AA is initialized, even if not used. */
ghostwin= GHOST_CreateWindow(g_system, title, ghostwin = GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey, win->posx, posy, win->sizex, win->sizey,
(GHOST_TWindowState)win->windowstate, (GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL, GHOST_kDrawingContextTypeOpenGL,
0 /* no stereo */, 0 /* no stereo */,
0 /* no AA */); 0 /* no AA */);
if (ghostwin) { if (ghostwin) {
/* needed so we can detect the graphics card below */ /* needed so we can detect the graphics card below */
@@ -362,11 +362,11 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
/* set the state*/ /* set the state*/
GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
win->ghostwin= ghostwin; win->ghostwin = ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
if (win->eventstate==NULL) if (win->eventstate == NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
/* until screens get drawn, make it nice grey */ /* until screens get drawn, make it nice grey */
glClearColor(.55, .55, .55, 0.0); glClearColor(.55, .55, .55, 0.0);
@@ -404,7 +404,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
#if defined(__APPLE__) && !defined(GHOST_COCOA) #if defined(__APPLE__) && !defined(GHOST_COCOA)
//Cocoa provides functions to get correct max window size //Cocoa provides functions to get correct max window size
{ {
extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */ extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */
wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y); wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y);
} }
@@ -415,8 +415,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
#endif #endif
} }
for (win= wm->windows.first; win; win= win->next) { for (win = wm->windows.first; win; win = win->next) {
if (win->ghostwin==NULL) { if (win->ghostwin == NULL) {
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) { if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
win->posx = wm_init_state.start_x; win->posx = wm_init_state.start_x;
win->posy = wm_init_state.start_y; win->posy = wm_init_state.start_y;
@@ -433,8 +433,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
wm_window_add_ghostwindow("Blender", win); wm_window_add_ghostwindow("Blender", win);
} }
/* happens after fileread */ /* happens after fileread */
if (win->eventstate==NULL) if (win->eventstate == NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
/* add keymap handlers (1 handler for all keys in map!) */ /* add keymap handlers (1 handler for all keys in map!) */
keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0); keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0);
@@ -448,7 +448,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
/* add drop boxes */ /* add drop boxes */
{ {
ListBase *lb= WM_dropboxmap_find("Window", 0, 0); ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
WM_event_add_dropbox_handler(&win->handlers, lb); WM_event_add_dropbox_handler(&win->handlers, lb);
} }
wm_window_title(wm, win); wm_window_title(wm, win);
@@ -460,15 +460,15 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
/* area-rip calls this */ /* area-rip calls this */
wmWindow *WM_window_open(bContext *C, rcti *rect) wmWindow *WM_window_open(bContext *C, rcti *rect)
{ {
wmWindow *win= wm_window_new(C); wmWindow *win = wm_window_new(C);
win->posx= rect->xmin; win->posx = rect->xmin;
win->posy= rect->ymin; win->posy = rect->ymin;
win->sizex= rect->xmax - rect->xmin; win->sizex = rect->xmax - rect->xmin;
win->sizey= rect->ymax - rect->ymin; win->sizey = rect->ymax - rect->ymin;
win->drawmethod= -1; win->drawmethod = -1;
win->drawdata= NULL; win->drawdata = NULL;
WM_check(C); WM_check(C);
@@ -488,20 +488,20 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
wm_window_check_position(position); wm_window_check_position(position);
/* test if we have a temp screen already */ /* test if we have a temp screen already */
for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) for (win = CTX_wm_manager(C)->windows.first; win; win = win->next)
if (win->screen->temp) if (win->screen->temp)
break; break;
/* add new window? */ /* add new window? */
if (win==NULL) { if (win == NULL) {
win= wm_window_new(C); win = wm_window_new(C);
win->posx= position->xmin; win->posx = position->xmin;
win->posy= position->ymin; win->posy = position->ymin;
} }
win->sizex= position->xmax - position->xmin; win->sizex = position->xmax - position->xmin;
win->sizey= position->ymax - position->ymin; win->sizey = position->ymax - position->ymin;
if (win->ghostwin) { if (win->ghostwin) {
wm_window_set_size(win, win->sizex, win->sizey); wm_window_set_size(win, win->sizex, win->sizey);
@@ -509,8 +509,8 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
} }
/* add new screen? */ /* add new screen? */
if (win->screen==NULL) if (win->screen == NULL)
win->screen= ED_screen_add(win, CTX_data_scene(C), "temp"); win->screen = ED_screen_add(win, CTX_data_scene(C), "temp");
win->screen->temp = 1; win->screen->temp = 1;
/* make window active, and validate/resize */ /* make window active, and validate/resize */
@@ -518,10 +518,10 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
WM_check(C); WM_check(C);
/* ensure it shows the right spacetype editor */ /* ensure it shows the right spacetype editor */
sa= win->screen->areabase.first; sa = win->screen->areabase.first;
CTX_wm_area_set(C, sa); CTX_wm_area_set(C, sa);
if (type==WM_WINDOW_RENDER) { if (type == WM_WINDOW_RENDER) {
ED_area_newspace(C, sa, SPACE_IMAGE); ED_area_newspace(C, sa, SPACE_IMAGE);
} }
else { else {
@@ -530,11 +530,11 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
ED_screen_set(C, win->screen); ED_screen_set(C, win->screen);
if (sa->spacetype==SPACE_IMAGE) if (sa->spacetype == SPACE_IMAGE)
GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render")); GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render"));
else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
GHOST_SetTitle(win->ghostwin, IFACE_("Blender User Preferences")); GHOST_SetTitle(win->ghostwin, IFACE_("Blender User Preferences"));
else if (sa->spacetype==SPACE_FILE) else if (sa->spacetype == SPACE_FILE)
GHOST_SetTitle(win->ghostwin, IFACE_("Blender File View")); GHOST_SetTitle(win->ghostwin, IFACE_("Blender File View"));
else else
GHOST_SetTitle(win->ghostwin, "Blender"); GHOST_SetTitle(win->ghostwin, "Blender");
@@ -549,7 +549,7 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
wm_window_copy(C, CTX_wm_window(C)); wm_window_copy(C, CTX_wm_window(C));
WM_check(C); WM_check(C);
WM_event_add_notifier(C, NC_WINDOW|NA_ADDED, NULL); WM_event_add_notifier(C, NC_WINDOW | NA_ADDED, NULL);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@@ -558,14 +558,14 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* fullscreen operator callback */ /* fullscreen operator callback */
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{ {
wmWindow *window= CTX_wm_window(C); wmWindow *window = CTX_wm_window(C);
GHOST_TWindowState state; GHOST_TWindowState state;
if (G.background) if (G.background)
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
state= GHOST_GetWindowState(window->ghostwin); state = GHOST_GetWindowState(window->ghostwin);
if (state!=GHOST_kWindowStateFullScreen) if (state != GHOST_kWindowStateFullScreen)
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen); GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
else else
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal); GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
@@ -589,24 +589,24 @@ typedef enum
static int query_qual(modifierKeyType qual) static int query_qual(modifierKeyType qual)
{ {
GHOST_TModifierKeyMask left, right; GHOST_TModifierKeyMask left, right;
int val= 0; int val = 0;
switch(qual) { switch (qual) {
case SHIFT: case SHIFT:
left= GHOST_kModifierKeyLeftShift; left = GHOST_kModifierKeyLeftShift;
right= GHOST_kModifierKeyRightShift; right = GHOST_kModifierKeyRightShift;
break; break;
case CONTROL: case CONTROL:
left= GHOST_kModifierKeyLeftControl; left = GHOST_kModifierKeyLeftControl;
right= GHOST_kModifierKeyRightControl; right = GHOST_kModifierKeyRightControl;
break; break;
case OS: case OS:
left= right= GHOST_kModifierKeyOS; left = right = GHOST_kModifierKeyOS;
break; break;
case ALT: case ALT:
default: default:
left= GHOST_kModifierKeyLeftAlt; left = GHOST_kModifierKeyLeftAlt;
right= GHOST_kModifierKeyRightAlt; right = GHOST_kModifierKeyRightAlt;
break; break;
} }
@@ -619,12 +619,12 @@ static int query_qual(modifierKeyType qual)
void wm_window_make_drawable(bContext *C, wmWindow *win) void wm_window_make_drawable(bContext *C, wmWindow *win)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
if (win != wm->windrawable && win->ghostwin) { if (win != wm->windrawable && win->ghostwin) {
// win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */ // win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */
wm->windrawable= win; wm->windrawable = win;
if (G.f & G_DEBUG) printf("set drawable %d\n", win->winid); if (G.f & G_DEBUG) printf("set drawable %d\n", win->winid);
GHOST_ActivateWindowDrawingContext(win->ghostwin); GHOST_ActivateWindowDrawingContext(win->ghostwin);
} }
@@ -633,17 +633,17 @@ void wm_window_make_drawable(bContext *C, wmWindow *win)
/* called by ghost, here we handle events for windows themselves or send to event system */ /* called by ghost, here we handle events for windows themselves or send to event system */
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
{ {
bContext *C= private; bContext *C = private;
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
GHOST_TEventType type= GHOST_GetEventType(evt); GHOST_TEventType type = GHOST_GetEventType(evt);
int time= GHOST_GetEventTime(evt); int time = GHOST_GetEventTime(evt);
if (type == GHOST_kEventQuit) { if (type == GHOST_kEventQuit) {
WM_exit(C); WM_exit(C);
} }
else { else {
GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt); GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data= GHOST_GetEventData(evt); GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
wmWindow *win; wmWindow *win;
if (!ghostwin) { if (!ghostwin) {
@@ -659,54 +659,54 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
return 1; return 1;
} }
else { else {
win= GHOST_GetWindowUserData(ghostwin); win = GHOST_GetWindowUserData(ghostwin);
} }
switch(type) { switch (type) {
case GHOST_kEventWindowDeactivate: case GHOST_kEventWindowDeactivate:
wm_event_add_ghostevent(wm, win, type, time, data); wm_event_add_ghostevent(wm, win, type, time, data);
win->active= 0; /* XXX */ win->active = 0; /* XXX */
break; break;
case GHOST_kEventWindowActivate: case GHOST_kEventWindowActivate:
{ {
GHOST_TEventKeyData kdata; GHOST_TEventKeyData kdata;
int cx, cy, wx, wy; int cx, cy, wx, wy;
wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */ wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active= 1; win->active = 1;
// window_handle(win, INPUTCHANGE, win->active); // window_handle(win, INPUTCHANGE, win->active);
/* bad ghost support for modifier keys... so on activate we set the modifiers again */ /* bad ghost support for modifier keys... so on activate we set the modifiers again */
kdata.ascii= '\0'; kdata.ascii = '\0';
kdata.utf8_buf[0]= '\0'; kdata.utf8_buf[0] = '\0';
if (win->eventstate->shift && !query_qual(SHIFT)) { if (win->eventstate->shift && !query_qual(SHIFT)) {
kdata.key= GHOST_kKeyLeftShift; kdata.key = GHOST_kKeyLeftShift;
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
} }
if (win->eventstate->ctrl && !query_qual(CONTROL)) { if (win->eventstate->ctrl && !query_qual(CONTROL)) {
kdata.key= GHOST_kKeyLeftControl; kdata.key = GHOST_kKeyLeftControl;
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
} }
if (win->eventstate->alt && !query_qual(ALT)) { if (win->eventstate->alt && !query_qual(ALT)) {
kdata.key= GHOST_kKeyLeftAlt; kdata.key = GHOST_kKeyLeftAlt;
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
} }
if (win->eventstate->oskey && !query_qual(OS)) { if (win->eventstate->oskey && !query_qual(OS)) {
kdata.key= GHOST_kKeyOS; kdata.key = GHOST_kKeyOS;
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
} }
/* keymodifier zero, it hangs on hotkeys that open windows otherwise */ /* keymodifier zero, it hangs on hotkeys that open windows otherwise */
win->eventstate->keymodifier= 0; win->eventstate->keymodifier = 0;
/* entering window, update mouse pos. but no event */ /* entering window, update mouse pos. but no event */
GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x= cx; win->eventstate->x = cx;
win->eventstate->y= (win->sizey-1) - cy; win->eventstate->y = (win->sizey - 1) - cy;
win->addmousemove= 1; /* enables highlighted buttons */ win->addmousemove = 1; /* enables highlighted buttons */
wm_window_make_drawable(C, win); wm_window_make_drawable(C, win);
break; break;
@@ -729,22 +729,22 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
state = GHOST_GetWindowState(win->ghostwin); state = GHOST_GetWindowState(win->ghostwin);
win->windowstate = state; win->windowstate = state;
/* win32: gives undefined window size when minimized */ /* win32: gives undefined window size when minimized */
if (state!=GHOST_kWindowStateMinimized) { if (state != GHOST_kWindowStateMinimized) {
GHOST_RectangleHandle client_rect; GHOST_RectangleHandle client_rect;
int l, t, r, b, scr_w, scr_h; int l, t, r, b, scr_w, scr_h;
int sizex, sizey, posx, posy; int sizex, sizey, posx, posy;
client_rect= GHOST_GetClientBounds(win->ghostwin); client_rect = GHOST_GetClientBounds(win->ghostwin);
GHOST_GetRectangle(client_rect, &l, &t, &r, &b); GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
GHOST_DisposeRectangle(client_rect); GHOST_DisposeRectangle(client_rect);
wm_get_screensize(&scr_w, &scr_h); wm_get_screensize(&scr_w, &scr_h);
sizex= r-l; sizex = r - l;
sizey= b-t; sizey = b - t;
posx= l; posx = l;
posy= scr_h - t - win->sizey; posy = scr_h - t - win->sizey;
/* /*
* Ghost sometimes send size or move events when the window hasn't changed. * Ghost sometimes send size or move events when the window hasn't changed.
@@ -755,33 +755,33 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
* another time. * another time.
*/ */
if (win->sizex != sizex || if (win->sizex != sizex ||
win->sizey != sizey || win->sizey != sizey ||
win->posx != posx || win->posx != posx ||
win->posy != posy) win->posy != posy)
{ {
win->sizex= sizex; win->sizex = sizex;
win->sizey= sizey; win->sizey = sizey;
win->posx= posx; win->posx = posx;
win->posy= posy; win->posy = posy;
/* debug prints */ /* debug prints */
if (0) { if (0) {
state = GHOST_GetWindowState(win->ghostwin); state = GHOST_GetWindowState(win->ghostwin);
if (state==GHOST_kWindowStateNormal) { if (state == GHOST_kWindowStateNormal) {
if (G.f & G_DEBUG) printf("window state: normal\n"); if (G.f & G_DEBUG) printf("window state: normal\n");
} }
else if (state==GHOST_kWindowStateMinimized) { else if (state == GHOST_kWindowStateMinimized) {
if (G.f & G_DEBUG) printf("window state: minimized\n"); if (G.f & G_DEBUG) printf("window state: minimized\n");
} }
else if (state==GHOST_kWindowStateMaximized) { else if (state == GHOST_kWindowStateMaximized) {
if (G.f & G_DEBUG) printf("window state: maximized\n"); if (G.f & G_DEBUG) printf("window state: maximized\n");
} }
else if (state==GHOST_kWindowStateFullScreen) { else if (state == GHOST_kWindowStateFullScreen) {
if (G.f & G_DEBUG) printf("window state: fullscreen\n"); if (G.f & G_DEBUG) printf("window state: fullscreen\n");
} }
if (type!=GHOST_kEventWindowSize) { if (type != GHOST_kEventWindowSize) {
if (G.f & G_DEBUG) { if (G.f & G_DEBUG) {
printf("win move event pos %d %d size %d %d\n", printf("win move event pos %d %d size %d %d\n",
win->posx, win->posy, win->sizex, win->sizey); win->posx, win->posy, win->sizex, win->sizey);
@@ -792,8 +792,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
wm_window_make_drawable(C, win); wm_window_make_drawable(C, win);
wm_draw_window_clear(win); wm_draw_window_clear(win);
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_WINDOW|NA_EDITED, NULL); WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
} }
} }
break; break;
@@ -823,35 +823,35 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
case GHOST_kEventDraggingDropDone: case GHOST_kEventDraggingDropDone:
{ {
wmEvent event; wmEvent event;
GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
int cx, cy, wx, wy; int cx, cy, wx, wy;
/* entering window, update mouse pos */ /* entering window, update mouse pos */
GHOST_GetCursorPosition(g_system, &wx, &wy); GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x= cx; win->eventstate->x = cx;
win->eventstate->y= (win->sizey-1) - cy; win->eventstate->y = (win->sizey - 1) - cy;
event= *(win->eventstate); /* copy last state, like mouse coords */ event = *(win->eventstate); /* copy last state, like mouse coords */
// activate region // activate region
event.type= MOUSEMOVE; event.type = MOUSEMOVE;
event.prevx= event.x; event.prevx = event.x;
event.prevy= event.y; event.prevy = event.y;
wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */ wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active= 1; win->active = 1;
wm_event_add(win, &event); wm_event_add(win, &event);
/* make blender drop event with custom data pointing to wm drags */ /* make blender drop event with custom data pointing to wm drags */
event.type= EVT_DROP; event.type = EVT_DROP;
event.val= KM_RELEASE; event.val = KM_RELEASE;
event.custom= EVT_DATA_LISTBASE; event.custom = EVT_DATA_LISTBASE;
event.customdata= &wm->drags; event.customdata = &wm->drags;
event.customdatafree= 1; event.customdatafree = 1;
wm_event_add(win, &event); wm_event_add(win, &event);
@@ -860,13 +860,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
/* add drag data to wm for paths: */ /* add drag data to wm for paths: */
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra= ddd->data; GHOST_TStringArray *stra = ddd->data;
int a, icon; int a, icon;
for (a=0; a<stra->count; a++) { for (a = 0; a < stra->count; a++) {
printf("drop file %s\n", stra->strings[a]); printf("drop file %s\n", stra->strings[a]);
/* try to get icon type from extension */ /* try to get icon type from extension */
icon= ED_file_extension_icon((char *)stra->strings[a]); icon = ED_file_extension_icon((char *)stra->strings[a]);
WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0); WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0);
/* void poin should point to string, it makes a copy */ /* void poin should point to string, it makes a copy */
@@ -897,36 +897,36 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
*/ */
static int wm_window_timer(const bContext *C) static int wm_window_timer(const bContext *C)
{ {
wmWindowManager *wm= CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmTimer *wt, *wtnext; wmTimer *wt, *wtnext;
wmWindow *win; wmWindow *win;
double time= PIL_check_seconds_timer(); double time = PIL_check_seconds_timer();
int retval= 0; int retval = 0;
for (wt= wm->timers.first; wt; wt= wtnext) { for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext= wt->next; /* in case timer gets removed */ wtnext = wt->next; /* in case timer gets removed */
win= wt->win; win = wt->win;
if (wt->sleep==0) { if (wt->sleep== 0) {
if (time > wt->ntime) { if (time > wt->ntime) {
wt->delta= time - wt->ltime; wt->delta = time - wt->ltime;
wt->duration += wt->delta; wt->duration += wt->delta;
wt->ltime= time; wt->ltime = time;
wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep); wt->ntime = wt->stime + wt->timestep *ceil(wt->duration / wt->timestep);
if (wt->event_type == TIMERJOBS) if (wt->event_type == TIMERJOBS)
wm_jobs_timer(C, wm, wt); wm_jobs_timer(C, wm, wt);
else if (wt->event_type == TIMERAUTOSAVE) else if (wt->event_type == TIMERAUTOSAVE)
wm_autosave_timer(C, wm, wt); wm_autosave_timer(C, wm, wt);
else if (win) { else if (win) {
wmEvent event= *(win->eventstate); wmEvent event = *(win->eventstate);
event.type= wt->event_type; event.type = wt->event_type;
event.custom= EVT_DATA_TIMER; event.custom = EVT_DATA_TIMER;
event.customdata= wt; event.customdata = wt;
wm_event_add(win, &event); wm_event_add(win, &event);
retval= 1; retval = 1;
} }
} }
} }
@@ -936,7 +936,7 @@ static int wm_window_timer(const bContext *C)
void wm_window_process_events(const bContext *C) void wm_window_process_events(const bContext *C)
{ {
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent) if (hasevent)
GHOST_DispatchEvents(g_system); GHOST_DispatchEvents(g_system);
@@ -944,7 +944,7 @@ void wm_window_process_events(const bContext *C)
hasevent |= wm_window_timer(C); hasevent |= wm_window_timer(C);
/* no event, we sleep 5 milliseconds */ /* no event, we sleep 5 milliseconds */
if (hasevent==0) if (hasevent == 0)
PIL_sleep_ms(5); PIL_sleep_ms(5);
} }
@@ -957,19 +957,19 @@ void wm_window_process_events_nosleep(void)
/* exported as handle callback to bke blender.c */ /* exported as handle callback to bke blender.c */
void wm_window_testbreak(void) void wm_window_testbreak(void)
{ {
static double ltime= 0; static double ltime = 0;
double curtime= PIL_check_seconds_timer(); double curtime = PIL_check_seconds_timer();
/* only check for breaks every 50 milliseconds /* only check for breaks every 50 milliseconds
* if we get called more often. * if we get called more often.
*/ */
if ((curtime-ltime)>.05) { if ((curtime - ltime) > .05) {
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent) if (hasevent)
GHOST_DispatchEvents(g_system); GHOST_DispatchEvents(g_system);
ltime= curtime; ltime = curtime;
} }
} }
@@ -978,9 +978,9 @@ void wm_window_testbreak(void)
void wm_ghost_init(bContext *C) void wm_ghost_init(bContext *C)
{ {
if (!g_system) { if (!g_system) {
GHOST_EventConsumerHandle consumer= GHOST_CreateEventConsumer(ghost_event_proc, C); GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, C);
g_system= GHOST_CreateSystem(); g_system = GHOST_CreateSystem();
GHOST_AddEventConsumer(g_system, consumer); GHOST_AddEventConsumer(g_system, consumer);
} }
} }
@@ -990,7 +990,7 @@ void wm_ghost_exit(void)
if (g_system) if (g_system)
GHOST_DisposeSystem(g_system); GHOST_DisposeSystem(g_system);
g_system= NULL; g_system = NULL;
} }
/* **************** timer ********************** */ /* **************** timer ********************** */
@@ -1000,24 +1000,24 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
{ {
wmTimer *wt; wmTimer *wt;
for (wt= wm->timers.first; wt; wt= wt->next) for (wt = wm->timers.first; wt; wt = wt->next)
if (wt==timer) if (wt == timer)
break; break;
if (wt) if (wt)
wt->sleep= dosleep; wt->sleep = dosleep;
} }
wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep) wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
{ {
wmTimer *wt= MEM_callocN(sizeof(wmTimer), "window timer"); wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer");
wt->event_type= event_type; wt->event_type = event_type;
wt->ltime= PIL_check_seconds_timer(); wt->ltime = PIL_check_seconds_timer();
wt->ntime= wt->ltime + timestep; wt->ntime = wt->ltime + timestep;
wt->stime= wt->ltime; wt->stime = wt->ltime;
wt->timestep= timestep; wt->timestep = timestep;
wt->win= win; wt->win = win;
BLI_addtail(&wm->timers, wt); BLI_addtail(&wm->timers, wt);
@@ -1029,12 +1029,12 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
wmTimer *wt; wmTimer *wt;
/* extra security check */ /* extra security check */
for (wt= wm->timers.first; wt; wt= wt->next) for (wt = wm->timers.first; wt; wt = wt->next)
if (wt==timer) if (wt == timer)
break; break;
if (wt) { if (wt) {
if (wm->reports.reporttimer == wt) if (wm->reports.reporttimer == wt)
wm->reports.reporttimer= NULL; wm->reports.reporttimer = NULL;
BLI_remlink(&wm->timers, wt); BLI_remlink(&wm->timers, wt);
if (wt->customdata) if (wt->customdata)
@@ -1052,18 +1052,18 @@ char *WM_clipboard_text_get(int selection)
if (G.background) if (G.background)
return NULL; return NULL;
buf= (char*)GHOST_getClipboard(selection); buf = (char *)GHOST_getClipboard(selection);
if (!buf) if (!buf)
return NULL; return NULL;
/* always convert from \r\n to \n */ /* always convert from \r\n to \n */
newbuf= MEM_callocN(strlen(buf)+1, "WM_clipboard_text_get"); newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get");
for (p= buf, p2= newbuf; *p; p++) { for (p = buf, p2 = newbuf; *p; p++) {
if (*p != '\r') if (*p != '\r')
*(p2++)= *p; *(p2++) = *p;
} }
*p2= '\0'; *p2 = '\0';
free(buf); /* ghost uses regular malloc */ free(buf); /* ghost uses regular malloc */
@@ -1076,29 +1076,29 @@ void WM_clipboard_text_set(char *buf, int selection)
#ifdef _WIN32 #ifdef _WIN32
/* do conversion from \n to \r\n on Windows */ /* do conversion from \n to \r\n on Windows */
char *p, *p2, *newbuf; char *p, *p2, *newbuf;
int newlen= 0; int newlen = 0;
for (p= buf; *p; p++) { for (p = buf; *p; p++) {
if (*p == '\n') if (*p == '\n')
newlen += 2; newlen += 2;
else else
newlen++; newlen++;
} }
newbuf= MEM_callocN(newlen+1, "WM_clipboard_text_set"); newbuf = MEM_callocN(newlen + 1, "WM_clipboard_text_set");
for (p= buf, p2= newbuf; *p; p++, p2++) { for (p = buf, p2 = newbuf; *p; p++, p2++) {
if (*p == '\n') { if (*p == '\n') {
*(p2++)= '\r'; *p2= '\n'; *(p2++) = '\r'; *p2 = '\n';
} }
else *p2= *p; else *p2 = *p;
} }
*p2= '\0'; *p2 = '\0';
GHOST_putClipboard((GHOST_TInt8*)newbuf, selection); GHOST_putClipboard((GHOST_TInt8 *)newbuf, selection);
MEM_freeN(newbuf); MEM_freeN(newbuf);
#else #else
GHOST_putClipboard((GHOST_TInt8*)buf, selection); GHOST_putClipboard((GHOST_TInt8 *)buf, selection);
#endif #endif
} }
} }
@@ -1119,23 +1119,23 @@ void WM_progress_clear(wmWindow *win)
void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r) void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r)
{ {
*posx_r= win->posx; *posx_r = win->posx;
*posy_r= win->posy; *posy_r = win->posy;
} }
void wm_window_get_size(wmWindow *win, int *width_r, int *height_r) void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
{ {
*width_r= win->sizex; *width_r = win->sizex;
*height_r= win->sizey; *height_r = win->sizey;
} }
/* exceptional case: - splash is called before events are processed /* exceptional case: - splash is called before events are processed
* this means we don't actually know the window size so get this from GHOST */ * this means we don't actually know the window size so get this from GHOST */
void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r) void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r)
{ {
GHOST_RectangleHandle bounds= GHOST_GetClientBounds(win->ghostwin); GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
*width_r= GHOST_GetWidthRectangle(bounds); *width_r = GHOST_GetWidthRectangle(bounds);
*height_r= GHOST_GetHeightRectangle(bounds); *height_r = GHOST_GetHeightRectangle(bounds);
GHOST_DisposeRectangle(bounds); GHOST_DisposeRectangle(bounds);
} }
@@ -1171,7 +1171,7 @@ void wm_get_cursor_position(wmWindow *win, int *x, int *y)
{ {
GHOST_GetCursorPosition(g_system, x, y); GHOST_GetCursorPosition(g_system, x, y);
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
*y = (win->sizey-1) - *y; *y = (win->sizey - 1) - *y;
} }
/* ******************* exported api ***************** */ /* ******************* exported api ***************** */
@@ -1204,15 +1204,15 @@ void WM_setinitialstate_normal(void)
void WM_cursor_warp(wmWindow *win, int x, int y) void WM_cursor_warp(wmWindow *win, int x, int y)
{ {
if (win && win->ghostwin) { if (win && win->ghostwin) {
int oldx=x, oldy=y; int oldx = x, oldy = y;
y= win->sizey -y - 1; y = win->sizey - y - 1;
GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y); GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y);
GHOST_SetCursorPosition(g_system, x, y); GHOST_SetCursorPosition(g_system, x, y);
win->eventstate->prevx= oldx; win->eventstate->prevx = oldx;
win->eventstate->prevy= oldy; win->eventstate->prevy = oldy;
} }
} }