style cleanup: wm, mosyly adding space around ops

This commit is contained in:
Campbell Barton
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)
{
@@ -83,7 +83,7 @@ void WM_operator_free(wmOperator *op)
#endif
if (op->ptr) {
op->properties= op->ptr->data;
op->properties = op->ptr->data;
MEM_freeN(op->ptr);
}
@@ -99,7 +99,7 @@ void WM_operator_free(wmOperator *op)
if (op->macro.first) {
wmOperator *opm, *opmnext;
for (opm= op->macro.first; opm; opm= opmnext) {
for (opm = op->macro.first; opm; opm = opmnext) {
opmnext = opm->next;
WM_operator_free(opm);
}
@@ -118,22 +118,22 @@ static void wm_reports_free(wmWindowManager *wm)
/* called on event handling by event_system.c */
void wm_operator_register(bContext *C, wmOperator *op)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
int tot;
BLI_addtail(&wm->operators, op);
tot= BLI_countlist(&wm->operators);
tot = BLI_countlist(&wm->operators);
while (tot>MAX_OP_REGISTERED) {
wmOperator *opt= wm->operators.first;
while (tot > MAX_OP_REGISTERED) {
wmOperator *opt = wm->operators.first;
BLI_remlink(&wm->operators, opt);
WM_operator_free(opt);
tot--;
}
/* so the console is redrawn */
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_SPACE | ND_SPACE_INFO_REPORT, NULL);
WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL);
}
@@ -141,24 +141,24 @@ void WM_operator_stack_clear(wmWindowManager *wm)
{
wmOperator *op;
while ((op= wm->operators.first)) {
while ((op = wm->operators.first)) {
BLI_remlink(&wm->operators, 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* mt;
MenuType *mt;
if (idname[0]) {
mt= BLI_ghash_lookup(menutypes_hash, idname);
mt = BLI_ghash_lookup(menutypes_hash, idname);
if (mt)
return mt;
}
@@ -169,13 +169,13 @@ MenuType *WM_menutype_find(const char *idname, int quiet)
return NULL;
}
int WM_menutype_add(MenuType* mt)
int WM_menutype_add(MenuType *mt)
{
BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt);
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);
}
@@ -183,15 +183,15 @@ void WM_menutype_freelink(MenuType* mt)
/* called on initialize WM_init() */
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)
{
GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash);
GHashIterator *iter = BLI_ghashIterator_new(menutypes_hash);
for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
MenuType *mt= BLI_ghashIterator_getValue(iter);
for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
MenuType *mt = BLI_ghashIterator_getValue(iter);
if (mt->ext.free) {
mt->ext.free(mt->ext.data);
}
@@ -199,22 +199,22 @@ void WM_menutype_free(void)
BLI_ghashIterator_free(iter);
BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN);
menutypes_hash= NULL;
menutypes_hash = NULL;
}
/* ****************************************** */
void WM_keymap_init(bContext *C)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
/* create standard key configs */
if (!wm->defaultconf)
wm->defaultconf= WM_keyconfig_new(wm, "Blender");
wm->defaultconf = WM_keyconfig_new(wm, "Blender");
if (!wm->addonconf)
wm->addonconf= WM_keyconfig_new(wm, "Blender Addon");
wm->addonconf = WM_keyconfig_new(wm, "Blender Addon");
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
* use python operators */
@@ -237,15 +237,15 @@ void WM_keymap_init(bContext *C)
void WM_check(bContext *C)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
/* wm context */
if (wm==NULL) {
wm= CTX_data_main(C)->wm.first;
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm);
}
if (wm==NULL) return;
if (wm->windows.first==NULL) return;
if (wm == NULL) return;
if (wm->windows.first == NULL) return;
if (!G.background) {
/* case: fileread */
@@ -268,18 +268,18 @@ void WM_check(bContext *C)
void wm_clear_default_size(bContext *C)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
/* wm context */
if (wm==NULL) {
wm= CTX_data_main(C)->wm.first;
if (wm == NULL) {
wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm);
}
if (wm==NULL) return;
if (wm->windows.first==NULL) return;
if (wm == 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->sizey = 0;
win->posx = 0;
@@ -291,18 +291,18 @@ void wm_clear_default_size(bContext *C)
/* on startup, it adds all data, for matching */
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;
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);
win= wm_window_new(C);
win->screen= screen;
screen->winid= win->winid;
BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname));
win = wm_window_new(C);
win->screen = screen;
screen->winid = win->winid;
BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname));
wm->winactive= win;
wm->file_saved= 1;
wm->winactive = win;
wm->file_saved = 1;
wm_window_make_drawable(C, win);
}
@@ -317,19 +317,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
if (wm->autosavetimer)
wm_autosave_timer_ended(wm);
while ((win= wm->windows.first)) {
while ((win = wm->windows.first)) {
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_window_free(C, wm, win);
}
while ((op= wm->operators.first)) {
while ((op = wm->operators.first)) {
BLI_remlink(&wm->operators, op);
WM_operator_free(op);
}
while ((keyconf=wm->keyconfigs.first)) {
while ((keyconf = wm->keyconfigs.first)) {
BLI_remlink(&wm->keyconfigs, keyconf);
WM_keyconfig_free(keyconf);
}
@@ -341,14 +341,14 @@ void wm_close_and_free(bContext *C, wmWindowManager *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)
{
wmWindowManager *wm;
while ((wm=wmlist->first)) {
while ((wm = wmlist->first)) {
wm_close_and_free(C, wm);
BLI_remlink(wmlist, wm);
MEM_freeN(wm);

View File

@@ -62,23 +62,23 @@ static int checkAppleVideoCard(void)
long value;
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) {
theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend);
theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend);
if (theErr == 0) {
for (j = 0; j < nrend; j++) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value);
theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value);
if (value > maxvram)
maxvram = value;
if ((theErr == 0) && (value >= 20000000)) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value);
theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value);
if ((theErr == 0) && (value != 0)) {
theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value);
theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value);
if ((theErr == 0) && (value != 0)) {
/*fprintf(stderr,"make it big\n");*/
CGLDestroyRendererInfo (rend);
CGLDestroyRendererInfo(rend);
macPrefState = 8;
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;
char inError[] = "* Not enough VRAM ";
char inText[] = "* blender needs at least 8Mb ";
char inError[] = "* Not enough VRAM ";
char inText[] = "* blender needs at least 8Mb ";
inError[0] = 16;
inText[0] = 28;
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();
}
CGLDestroyRendererInfo (rend);
CGLDestroyRendererInfo(rend);
return 0;
}
@@ -106,7 +106,7 @@ static void getMacAvailableBounds(short *top, short *left, short *bottom, short
{
Rect outAvailableRect;
GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
*top = outAvailableRect.top;
*left = outAvailableRect.left;
@@ -124,14 +124,14 @@ void wm_set_apple_prefsize(int scr_x, int scr_y)
short top, left, bottom, right;
getMacAvailableBounds(&top, &left, &bottom, &right);
WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
G.windowstate= 0;
WM_setprefsize(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64);
G.windowstate = 0;
}
else {
/* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
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 */
/* 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;
for (dm= dropboxes.first; dm; dm= dm->next)
if (dm->spaceid==spaceid && dm->regionid==regionid)
if (0==strncmp(idname, dm->idname, KMAP_MAX_NAME))
for (dm = dropboxes.first; dm; dm = dm->next)
if (dm->spaceid == spaceid && dm->regionid == regionid)
if (0 == strncmp(idname, dm->idname, KMAP_MAX_NAME))
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);
dm->spaceid= spaceid;
dm->regionid= regionid;
dm->spaceid = spaceid;
dm->regionid = regionid;
BLI_addtail(&dropboxes, dm);
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 *),
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->copy= copy;
drop->ot= WM_operatortype_find(idname, 0);
drop->opcontext= WM_OP_INVOKE_DEFAULT;
drop->poll = poll;
drop->copy = copy;
drop->ot = WM_operatortype_find(idname, 0);
drop->opcontext = WM_OP_INVOKE_DEFAULT;
if (drop->ot==NULL) {
if (drop->ot == NULL) {
MEM_freeN(drop);
printf("Error: dropbox with unknown operator: %s\n", idname);
return NULL;
@@ -125,10 +125,10 @@ void wm_dropbox_free(void)
{
wmDropBoxMap *dm;
for (dm= dropboxes.first; dm; dm= dm->next) {
for (dm = dropboxes.first; dm; dm = dm->next) {
wmDropBox *drop;
for (drop= dm->dropboxes.first; drop; drop= drop->next) {
for (drop = dm->dropboxes.first; drop; drop = drop->next) {
if (drop->ptr) {
WM_operator_properties_free(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 */
wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmDrag *drag= MEM_callocN(sizeof(struct wmDrag), "new drag");
wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag");
/* keep track of future multitouch drag too, add a mousepointer id or so */
/* if multiple drags are added, they're drawn as list */
BLI_addtail(&wm->drags, drag);
drag->icon= icon;
drag->type= type;
if (type==WM_DRAG_PATH)
drag->icon = icon;
drag->type = type;
if (type == WM_DRAG_PATH)
BLI_strncpy(drag->path, poin, FILE_MAX);
else
drag->poin= poin;
drag->value= value;
drag->poin = poin;
drag->value = value;
return drag;
}
void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy)
{
drag->imb= imb;
drag->scale= scale;
drag->sx= sx;
drag->sy= sy;
drag->imb = imb;
drag->scale = scale;
drag->sx = sx;
drag->sy = sy;
}
static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event)
{
wmEventHandler *handler= handlers->first;
for (; handler; handler= handler->next) {
wmEventHandler *handler = handlers->first;
for (; handler; handler = handler->next) {
if (handler->dropboxes) {
wmDropBox *drop= handler->dropboxes->first;
for (; drop; drop= drop->next) {
wmDropBox *drop = handler->dropboxes->first;
for (; drop; drop = drop->next) {
if (drop->poll(C, drag, event))
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 */
static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
{
wmWindow *win= CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
const char *name;
name= dropbox_active(C, &win->handlers, drag, event);
name = dropbox_active(C, &win->handlers, drag, event);
if (name) return name;
name= dropbox_active(C, &sa->handlers, drag, event);
name = dropbox_active(C, &sa->handlers, drag, event);
if (name) return name;
name= dropbox_active(C, &ar->handlers, drag, event);
name = dropbox_active(C, &ar->handlers, drag, event);
if (name) return name;
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)
{
wmWindow *win= CTX_wm_window(C);
wmWindow *win = CTX_wm_window(C);
/* 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;
drag->opname[0]= 0;
drag->opname[0] = 0;
/* 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");
}
else {
const char *opname= wm_dropbox_active(C, drag, event);
const char *opname = wm_dropbox_active(C, drag, event);
if (opname) {
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 */
void wm_drags_check_ops(bContext *C, wmEvent *event)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
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);
}
}
@@ -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)
{
int width= UI_GetStringWidth(name);
int width = UI_GetStringWidth(name);
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);
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)
{
switch(drag->type) {
switch (drag->type) {
case WM_DRAG_ID:
{
ID *id= (ID *)drag->poin;
return id->name+2;
ID *id = (ID *)drag->poin;
return id->name + 2;
}
case WM_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 */
void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmDrag *drag;
int cursorx, cursory, x, y;
cursorx= win->eventstate->x;
cursory= win->eventstate->y;
cursorx = win->eventstate->x;
cursory = win->eventstate->y;
if (rect) {
rect->xmin = rect->xmax = cursorx;
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 */
glEnable(GL_BLEND);
for (drag= wm->drags.first; drag; drag= drag->next) {
for (drag = wm->drags.first; drag; drag = drag->next) {
/* image or icon */
if (drag->imb) {
x= cursorx - drag->sx/2;
y= cursory - drag->sy/2;
x = cursorx - drag->sx / 2;
y = cursory - drag->sy / 2;
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 {
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);
}
}
else {
x= cursorx - 8;
y= cursory - 2;
x = cursorx - 8;
y = cursory - 2;
/* icons assumed to be 16 pixels */
if (rect)
drag_rect_minmax(rect, x, y, x+16, y+16);
drag_rect_minmax(rect, x, y, x + 16, y + 16);
else
UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8);
}
/* item name */
if (drag->imb) {
x= cursorx - drag->sx/2;
y= cursory - drag->sy/2 - 16;
x = cursorx - drag->sx / 2;
y = cursory - drag->sy / 2 - 16;
}
else {
x= cursorx + 10;
y= cursory + 1;
x = cursorx + 10;
y = cursory + 1;
}
if (rect) {
int w= UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x+w, y+16);
int w = UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x + w, y + 16);
}
else {
glColor4ub(255, 255, 255, 255);
@@ -353,17 +353,17 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
/* operator name with roundbox */
if (drag->opname[0]) {
if (drag->imb) {
x= cursorx - drag->sx/2;
y= cursory + drag->sy/2 + 4;
x = cursorx - drag->sx / 2;
y = cursory + drag->sy / 2 + 4;
}
else {
x= cursorx - 8;
y= cursory + 16;
x = cursorx - 8;
y = cursory + 16;
}
if (rect) {
int w= UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x+w, y+16);
int w = UI_GetStringWidth(wm_drag_name(drag));
drag_rect_minmax(rect, x, y, x + w, y + 16);
}
else
wm_drop_operator_draw(drag->opname, x, y);

View File

@@ -66,27 +66,27 @@
#include "wm_event_system.h"
/* swap */
#define WIN_NONE_OK 0
#define WIN_NONE_OK 0
#define WIN_BACK_OK 1
#define WIN_FRONT_OK 2
#define WIN_BOTH_OK 3
#define WIN_BOTH_OK 3
/* ******************* drawing, overlays *************** */
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) {
wmWindow *win= CTX_wm_window(C);
bScreen *screen= win->screen;
wmWindow *win = CTX_wm_window(C);
bScreen *screen = win->screen;
wmPaintCursor *pc;
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)) {
ARegion *ar_other= CTX_wm_region(C);
ARegion *ar_other = CTX_wm_region(C);
if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
int x = 0, y = 0;
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)
{
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)
{
if (sa->spacetype == SPACE_VIEW3D)
return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
return (((View3D *)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
else
return 1;
}
@@ -127,7 +127,7 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
{
if (sa->spacetype == SPACE_VIEW3D) {
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)) {
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)
{
bScreen *screen= win->screen;
bScreen *screen = win->screen;
ScrArea *sa;
ARegion *ar;
/* 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);
for (ar=sa->regionbase.first; ar; ar= ar->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) {
CTX_wm_region_set(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);
/* draw overlapping regions */
for (ar=screen->regionbase.first; ar; ar= ar->next) {
for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) {
CTX_wm_menu_set(C, ar);
ED_region_do_draw(C, ar);
@@ -191,12 +191,12 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
ScrArea *sa;
ARegion *ar;
for (sa= screen->areabase.first; sa; sa= sa->next) {
for (ar= sa->regionbase.first; ar; ar= ar->next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
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));
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;
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)) {
ar->do_draw= RGN_DRAW;
ar->do_draw = RGN_DRAW;
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)
{
wmWindowManager *wm= CTX_wm_manager(C);
bScreen *screen= win->screen;
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen = win->screen;
ScrArea *sa;
ARegion *ar;
static rcti rect= {0, 0, 0, 0};
static rcti rect = {0, 0, 0, 0};
/* after backbuffer selection draw, we need to redraw */
for (sa= screen->areabase.first; sa; sa= sa->next)
for (ar= sa->regionbase.first; ar; ar= ar->next)
for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->swinid && !wm_area_test_invalid_backbuf(sa))
ED_region_tag_redraw(ar);
/* flush overlapping regions */
if (screen->regionbase.first) {
/* flush redraws of area regions up to overlapping regions */
for (sa= screen->areabase.first; sa; sa= sa->next)
for (ar= sa->regionbase.first; ar; ar= ar->next)
for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar = sa->regionbase.first; ar; ar = ar->next)
if (ar->swinid && ar->do_draw)
wm_flush_regions_up(screen, &ar->winrct);
/* 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)
wm_flush_regions_up(screen, &ar->winrct);
/* 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)
wm_flush_regions_down(screen, &ar->winrct);
}
/* flush drag item */
if (rect.xmin!=rect.xmax) {
if (rect.xmin != rect.xmax) {
wm_flush_regions_down(screen, &rect);
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 */
for (sa= screen->areabase.first; sa; sa= sa->next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
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->do_draw) {
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);
if (exchange)
ar->swap= WIN_FRONT_OK;
ar->swap = WIN_FRONT_OK;
}
else if (exchange) {
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);
CTX_wm_region_set(C, NULL);
ar->swap= WIN_BOTH_OK;
ar->swap = WIN_BOTH_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)
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);
if (exchange)
screen->swap= WIN_FRONT_OK;
screen->swap = WIN_FRONT_OK;
}
else if (exchange) {
if (screen->swap==WIN_FRONT_OK) {
if (screen->swap == WIN_FRONT_OK) {
ED_screen_draw(win);
screen->swap= WIN_BOTH_OK;
screen->swap = WIN_BOTH_OK;
}
else if (screen->swap==WIN_BACK_OK)
screen->swap= WIN_FRONT_OK;
else if (screen->swap==WIN_BOTH_OK)
screen->swap= WIN_BOTH_OK;
else if (screen->swap == WIN_BACK_OK)
screen->swap = WIN_FRONT_OK;
else if (screen->swap == WIN_BOTH_OK)
screen->swap = WIN_BOTH_OK;
}
ED_area_overdraw(C);
/* 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) {
CTX_wm_menu_set(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
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 nx, ny;
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 (is_power_of_2_i(x)) {
splitx[0]= x;
splitx[0] = x;
(*nx)++;
return;
}
if (n == 1) {
/* last part, we have to go larger */
splitx[0]= power_of_2_max_i(x);
splitx[0] = power_of_2_max_i(x);
(*nx)++;
}
else {
/* two or more parts to go, use smaller part */
splitx[0]= power_of_2_min_i(x);
newnx= ++(*nx);
split_width(x-splitx[0], n-1, splitx+1, &newnx);
splitx[0] = power_of_2_min_i(x);
newnx = ++(*nx);
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];
/* if we waste more space or use the same amount,
* revert deeper splits and just use larger */
if (waste >= power_of_2_max_i(x)) {
splitx[0]= power_of_2_max_i(x);
memset(splitx+1, 0, sizeof(int)*(n-1));
splitx[0] = power_of_2_max_i(x);
memset(splitx + 1, 0, sizeof(int) * (n - 1));
}
else
*nx= newnx;
*nx = newnx;
}
}
static void wm_draw_triple_free(wmWindow *win)
{
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);
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);
win->drawfail= 1;
win->drawfail = 1;
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 */
if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) {
triple->target= GL_TEXTURE_RECTANGLE_ARB;
triple->nx= 1;
triple->ny= 1;
triple->x[0]= win->sizex;
triple->y[0]= win->sizey;
triple->target = GL_TEXTURE_RECTANGLE_ARB;
triple->nx = 1;
triple->ny = 1;
triple->x[0] = win->sizex;
triple->y[0] = win->sizey;
}
else if (GPU_non_power_of_two_support()) {
triple->target= GL_TEXTURE_2D;
triple->nx= 1;
triple->ny= 1;
triple->x[0]= win->sizex;
triple->y[0]= win->sizey;
triple->target = GL_TEXTURE_2D;
triple->nx = 1;
triple->ny = 1;
triple->x[0] = win->sizex;
triple->y[0] = win->sizey;
}
else {
triple->target= GL_TEXTURE_2D;
triple->nx= 0;
triple->ny= 0;
triple->target = GL_TEXTURE_2D;
triple->nx = 0;
triple->ny = 0;
split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx);
split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny);
}
/* generate texture names */
glGenTextures(triple->nx*triple->ny, triple->bind);
glGenTextures(triple->nx * triple->ny, triple->bind);
if (!triple->bind[0]) {
/* 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;
}
for (y=0; y<triple->ny; y++) {
for (x=0; x<triple->nx; x++) {
for (y = 0; y < triple->ny; y++) {
for (x = 0; x < triple->nx; x++) {
/* proxy texture is only guaranteed to test for the cases that
* there is only one texture in use, which may not be the case */
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
@@ -471,7 +471,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
}
/* 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);
glTexParameteri(triple->target, GL_TEXTURE_MIN_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);
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++) {
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
sizey= (y == triple->ny-1)? win->sizey-offy: triple->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++) {
sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
/* wmOrtho for the screen has this same offset */
ratiox= sizex;
ratioy= sizey;
halfx= 0.375f;
halfy= 0.375f;
ratiox = sizex;
ratioy = sizey;
halfx = 0.375f;
halfy = 0.375f;
/* texture rectangle has unnormalized coordinates */
if (triple->target == GL_TEXTURE_2D) {
@@ -516,21 +516,21 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
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);
glBegin(GL_QUADS);
glTexCoord2f(halfx, halfy);
glVertex2f(offx, offy);
glTexCoord2f(halfx, halfy);
glVertex2f(offx, offy);
glTexCoord2f(ratiox+halfx, halfy);
glVertex2f(offx+sizex, offy);
glTexCoord2f(ratiox + halfx, halfy);
glVertex2f(offx + sizex, offy);
glTexCoord2f(ratiox+halfx, ratioy+halfy);
glVertex2f(offx+sizex, offy+sizey);
glTexCoord2f(ratiox + halfx, ratioy + halfy);
glVertex2f(offx + sizex, offy + sizey);
glTexCoord2f(halfx, ratioy+halfy);
glVertex2f(offx, offy+sizey);
glTexCoord2f(halfx, ratioy + halfy);
glVertex2f(offx, offy + sizey);
glEnd();
}
}
@@ -543,12 +543,12 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
{
int x, y, sizex, sizey, offx, offy;
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++) {
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
sizey= (y == triple->ny-1)? win->sizey-offy: triple->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++) {
sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
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);
}
}
@@ -558,23 +558,23 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
static void wm_method_draw_triple(bContext *C, wmWindow *win)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmDrawTriple *triple;
bScreen *screen= win->screen;
bScreen *screen = win->screen;
ScrArea *sa;
ARegion *ar;
int copytex= 0, paintcursor= 1;
int copytex = 0, paintcursor = 1;
if (win->drawdata) {
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);
wm_triple_draw_textures(win, win->drawdata);
}
else {
win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
if (!wm_triple_gen_textures(win, win->drawdata)) {
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 */
for (sa= screen->areabase.first; sa; sa= sa->next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
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) {
CTX_wm_region_set(C, ar);
ED_region_do_draw(C, ar);
ED_area_overdraw_flush(sa, ar);
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);
/* draw overlapping regions */
for (ar=screen->regionbase.first; ar; ar= ar->next) {
for (ar = screen->regionbase.first; ar; ar = ar->next) {
if (ar->swinid) {
CTX_wm_menu_set(C, ar);
ED_region_do_draw(C, ar);
CTX_wm_menu_set(C, NULL);
/* 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);
if (paintcursor && wm->paintcursors.first) {
for (sa= screen->areabase.first; sa; sa= sa->next) {
for (ar=sa->regionbase.first; ar; ar= ar->next) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->swinid == screen->subwinactive) {
CTX_wm_area_set(C, sa);
CTX_wm_region_set(C, ar);
@@ -661,19 +661,19 @@ static int wm_draw_update_test_window(wmWindow *win)
{
ScrArea *sa;
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) {
wm_tag_redraw_overlay(win, ar);
ar->do_draw_overlay= 0;
ar->do_draw_overlay = 0;
}
if (ar->swinid && ar->do_draw)
do_draw= 1;
do_draw = 1;
}
for (sa= win->screen->areabase.first; sa; sa= sa->next) {
for (ar=sa->regionbase.first; ar; ar= ar->next) {
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
wm_region_test_render_do_draw(sa, ar);
if (ar->swinid && ar->do_draw)
@@ -737,22 +737,22 @@ void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
if (ar && win) {
if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE)
ED_region_tag_redraw(ar);
win->screen->do_draw_paintcursor= 1;
win->screen->do_draw_paintcursor = 1;
}
}
void wm_draw_update(bContext *C)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
int drawmethod;
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) {
wm_draw_window_clear(win);
win->drawmethod= U.wmdrawmethod;
win->drawmethod = U.wmdrawmethod;
}
if (wm_draw_update_test_window(win)) {
@@ -765,7 +765,7 @@ void wm_draw_update(bContext *C)
if (win->screen->do_refresh)
ED_screen_refresh(wm, win);
drawmethod= wm_automatic_draw_method(win);
drawmethod = wm_automatic_draw_method(win);
if (win->drawfail)
wm_method_draw_overlap_all(C, win, 0);
@@ -778,9 +778,9 @@ void wm_draw_update(bContext *C)
else // if (drawmethod == USER_DRAW_TRIPLE)
wm_method_draw_triple(C, win);
win->screen->do_draw_gesture= 0;
win->screen->do_draw_paintcursor= 0;
win->screen->do_draw_drag= 0;
win->screen->do_draw_gesture = 0;
win->screen->do_draw_paintcursor = 0;
win->screen->do_draw_drag = 0;
wm_window_swap_buffers(win);
@@ -791,39 +791,39 @@ void wm_draw_update(bContext *C)
void wm_draw_window_clear(wmWindow *win)
{
bScreen *screen= win->screen;
bScreen *screen = win->screen;
ScrArea *sa;
ARegion *ar;
int drawmethod= wm_automatic_draw_method(win);
int drawmethod = wm_automatic_draw_method(win);
if (drawmethod == USER_DRAW_TRIPLE)
wm_draw_triple_free(win);
/* clear screen swap flags */
if (screen) {
for (sa= screen->areabase.first; sa; sa= sa->next)
for (ar=sa->regionbase.first; ar; ar= ar->next)
ar->swap= WIN_NONE_OK;
for (sa = screen->areabase.first; sa; sa = sa->next)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ar->swap = WIN_NONE_OK;
screen->swap= WIN_NONE_OK;
screen->swap = WIN_NONE_OK;
}
}
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))
wm_flush_regions_down(win->screen, &ar->winrct);
win->screen->do_draw= 1;
win->screen->do_draw = 1;
}
void WM_redraw_windows(bContext *C)
{
wmWindow *win_prev= CTX_wm_window(C);
ScrArea *area_prev= CTX_wm_area(C);
ARegion *ar_prev= CTX_wm_region(C);
wmWindow *win_prev = CTX_wm_window(C);
ScrArea *area_prev = CTX_wm_area(C);
ARegion *ar_prev = CTX_wm_region(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
* winsock stuff.
*/
/* placed up here because of crappy
* winsock stuff.
*/
#include <stddef.h>
#include <string.h>
#include <errno.h>
@@ -131,20 +131,20 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
wmWindowManager *wm;
wmWindow *win, *active_win;
*wmlist= G.main->wm;
G.main->wm.first= G.main->wm.last= NULL;
*wmlist = G.main->wm;
G.main->wm.first = G.main->wm.last = NULL;
active_win = CTX_wm_window(C);
/* first wrap up running stuff */
/* 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);
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->modalhandlers);
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?*/
#if 0
if (wm==NULL) return;
if (wm == NULL) return;
if (G.fileflags & G_FILE_NO_UI) return;
/* 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);
if (win!=wm->winactive) {
if (win != wm->winactive) {
BLI_remlink(&G.main->screen, win->screen);
//BLI_addtail(screenbase, win->screen);
}
@@ -185,8 +185,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
wmWindow *oldwin, *win;
/* cases 1 and 2 */
if (oldwmlist->first==NULL) {
if (G.main->wm.first); /* nothing todo */
if (oldwmlist->first == NULL) {
if (G.main->wm.first) ; /* nothing todo */
else
wm_add_default(C);
}
@@ -194,29 +194,29 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* cases 3 and 4 */
/* we've read file without wm..., keep current one entirely alive */
if (G.main->wm.first==NULL) {
bScreen *screen= NULL;
if (G.main->wm.first == NULL) {
bScreen *screen = NULL;
/* 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 */
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 */
if (screen->winid==0)
win->screen= screen;
if (screen->winid == 0)
win->screen = screen;
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));
win->screen->winid= win->winid;
BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
win->screen->winid = win->winid;
}
}
}
G.main->wm= *oldwmlist;
G.main->wm = *oldwmlist;
/* screens were read from file! */
ED_screens_initialize(G.main->wm.first);
@@ -224,47 +224,47 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
else {
/* what if old was 3, and loaded 1? */
/* this code could move to setup_appdata */
oldwm= oldwmlist->first;
wm= G.main->wm.first;
oldwm = oldwmlist->first;
wm = G.main->wm.first;
/* preserve key configurations in new wm, to preserve their keymaps */
wm->keyconfigs= oldwm->keyconfigs;
wm->addonconf= oldwm->addonconf;
wm->defaultconf= oldwm->defaultconf;
wm->userconf= oldwm->userconf;
wm->keyconfigs = oldwm->keyconfigs;
wm->addonconf = oldwm->addonconf;
wm->defaultconf = oldwm->defaultconf;
wm->userconf = oldwm->userconf;
oldwm->keyconfigs.first= oldwm->keyconfigs.last= NULL;
oldwm->addonconf= NULL;
oldwm->defaultconf= NULL;
oldwm->userconf= NULL;
oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL;
oldwm->addonconf = NULL;
oldwm->defaultconf = NULL;
oldwm->userconf = NULL;
/* ensure making new keymaps and set space types */
wm->initialized= 0;
wm->winactive= NULL;
wm->initialized = 0;
wm->winactive = NULL;
/* only first wm in list has ghostwins */
for (win= wm->windows.first; win; win= win->next) {
for (oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
for (win = wm->windows.first; win; win = win->next) {
for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
if (oldwin->winid == win->winid ) {
win->ghostwin= oldwin->ghostwin;
win->active= oldwin->active;
if (oldwin->winid == win->winid) {
win->ghostwin = oldwin->ghostwin;
win->active = oldwin->active;
if (win->active)
wm->winactive= win;
wm->winactive = win;
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;
oldwin->eventstate= NULL;
win->eventstate = oldwin->eventstate;
oldwin->eventstate = NULL;
/* ensure proper screen rescaling */
win->sizex= oldwin->sizex;
win->sizey= oldwin->sizey;
win->posx= oldwin->posx;
win->posy= oldwin->posy;
win->sizex = oldwin->sizex;
win->sizey = oldwin->sizey;
win->posx = oldwin->posx;
win->posy = oldwin->posy;
}
}
}
@@ -281,14 +281,14 @@ static void wm_init_userdef(bContext *C)
sound_init(CTX_data_main(C));
/* needed so loading a file from the command line respects user-pref [#26156] */
if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI;
else G.fileflags &= ~G_FILE_NO_UI;
if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI;
else G.fileflags &= ~G_FILE_NO_UI;
/* set the python auto-execute setting from user prefs */
/* enabled by default, unless explicitly enabled in the command line which overrides */
if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
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 */
@@ -298,11 +298,11 @@ static void wm_init_userdef(bContext *C)
/* return codes */
#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_OPEN -1 /* Can't open the file */
#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */
#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */
#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_OPEN -1 /* Can't open the file */
#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */
#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */
/* 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....
len= strlen(name);
if (ELEM(name[len-1], '/', '\\')) {
retval= BKE_READ_EXOTIC_FAIL_PATH;
len = strlen(name);
if (ELEM(name[len - 1], '/', '\\')) {
retval = BKE_READ_EXOTIC_FAIL_PATH;
}
else {
gzfile = BLI_gzopen(name,"rb");
gzfile = BLI_gzopen(name, "rb");
if (gzfile == NULL) {
retval= BKE_READ_EXOTIC_FAIL_OPEN;
retval = BKE_READ_EXOTIC_FAIL_OPEN;
}
else {
len= gzread(gzfile, header, sizeof(header));
len = gzread(gzfile, header, sizeof(header));
gzclose(gzfile);
if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) {
retval= BKE_READ_EXOTIC_OK_BLEND;
retval = BKE_READ_EXOTIC_OK_BLEND;
}
else {
//XXX waitcursor(1);
#if 0 /* historic stuff - no longer used */
#if 0 /* historic stuff - no longer used */
if (is_foo_format(name)) {
read_foo(name);
retval= BKE_READ_EXOTIC_OK_OTHER;
retval = BKE_READ_EXOTIC_OK_OTHER;
}
else
#endif
{
retval= BKE_READ_EXOTIC_FAIL_FORMAT;
retval = BKE_READ_EXOTIC_FAIL_FORMAT;
}
//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... */
/* it throws error box when file doesn't exist and returns -1 */
/* 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 */
if (retval == BKE_READ_EXOTIC_OK_BLEND) {
int G_f= G.f;
int G_f = G.f;
ListBase wmbase;
/* put aside screens to match with persistent windows later */
/* also exit screens and editors */
wm_window_match_init(C, &wmbase);
retval= BKE_read_file(C, filepath, reports);
retval = BKE_read_file(C, filepath, reports);
G.save_over = 1;
/* this flag is initialized by the operator but overwritten on read.
* need to re-enable it here else drivers + registered scripts wont work. */
if (G.f != G_f) {
const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
G.f= (G.f & ~flags_keep) | (G_f & flags_keep);
const int flags_keep = (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
G.f = (G.f & ~flags_keep) | (G_f & flags_keep);
}
/* 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();
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 */
{
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] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
BKE_reportf(reports, RPT_WARNING,
"Engine not available: '%s' for scene: %s, "
"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();
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)
BKE_write_undo(C, "Import file");
else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) {
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) {
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;
char tstr[FILE_MAX];
int success= 0;
int success = 0;
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)) {
success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
if (U.themes.first==NULL) {
printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
if (U.themes.first == NULL) {
printf("\nError: No valid "STRINGIFY (BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
success = 0;
}
}
if (success==0) {
if (success == 0) {
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
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_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. */
if (!G.background) GPU_default_lights();
/* XXX */
G.save_over = 0; // start with save preference untitled.blend
G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */
G.save_over = 0; // start with save preference untitled.blend
G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */
// mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender"
// refresh_interface_font();
// undo_editmode_clear();
BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */
BKE_write_undo(C, "original"); /* save current state */
ED_editors_init(C);
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
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 */
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 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;
}
@@ -591,15 +591,15 @@ void WM_read_history(void)
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;
/* 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;
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);
recent->filepath = BLI_strdup(line);
num++;
@@ -627,21 +627,21 @@ static void write_history(void)
recent = G.recent_files.first;
/* refresh recent-files.txt of recent opened files, when current file was changed */
if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
fp= BLI_fopen(name, "w");
if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) {
fp = BLI_fopen(name, "w");
if (fp) {
/* 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);
BLI_addhead(&(G.recent_files), recent);
/* write current file to recent-files.txt */
fprintf(fp, "%s\n", recent->filepath);
recent = recent->next;
i=1;
i = 1;
/* 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 */
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);
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 */
ImBuf *ibuf;
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 */
if (G.background || scene==NULL || scene->camera==NULL)
if (G.background || scene == NULL || scene->camera == NULL)
return NULL;
/* gets scaled to BLEN_THUMB_SIZE */
ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, OB_SOLID, FALSE, err_out);
ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, OB_SOLID, FALSE, err_out);
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 */
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);
/* 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[1] = BLEN_THUMB_SIZE;
@@ -699,11 +699,11 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
else {
/* '*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);
thumb= NULL;
thumb = NULL;
}
/* must be freed by caller */
*thumb_pt= thumb;
*thumb_pt = thumb;
return ibuf;
}
@@ -732,8 +732,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
int len;
char filepath[FILE_MAX];
int *thumb= NULL;
ImBuf *ibuf_thumb= NULL;
int *thumb = NULL;
ImBuf *ibuf_thumb = NULL;
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 */
/* 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) {
BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.240s'", filepath);
return -1;
@@ -762,7 +762,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* blend file thumbnail */
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
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);
@@ -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 (!copy) {
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 */
}
@@ -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 */
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);
}
@@ -826,8 +826,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* operator entry */
int WM_write_homefile(bContext *C, wmOperator *op)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= CTX_wm_window(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
char filepath[FILE_MAX];
int fileflags;
@@ -851,7 +851,7 @@ int WM_write_homefile(bContext *C, wmOperator *op)
printf("ok\n");
G.save_over= 0;
G.save_over = 0;
return OPERATOR_FINISHED;
}
@@ -891,7 +891,7 @@ void WM_autosave_init(wmWindowManager *wm)
wm_autosave_timer_ended(wm);
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))
@@ -904,10 +904,10 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
/* 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 (handler=win->modalhandlers.first; handler; handler=handler->next) {
for (win = wm->windows.first; win; win = win->next) {
for (handler = win->modalhandlers.first; handler; handler = handler->next) {
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;
}
}
@@ -916,20 +916,20 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
wm_autosave_location(filepath);
/* 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 */
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 */
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)
{
if (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_math.h"
#include "BLI_scanfill.h" /* lasso tessellation */
#include "BLI_scanfill.h" /* lasso tessellation */
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -60,32 +60,32 @@
/* context checked on having screen, window and area */
wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
{
wmGesture *gesture= MEM_callocN(sizeof(wmGesture), "new gesture");
wmWindow *window= CTX_wm_window(C);
ARegion *ar= CTX_wm_region(C);
wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture");
wmWindow *window = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
int sx, sy;
BLI_addtail(&window->gesture, gesture);
gesture->type= type;
gesture->event_type= event->type;
gesture->swinid= ar->swinid; /* means only in area-region context! */
gesture->type = type;
gesture->event_type = event->type;
gesture->swinid = ar->swinid; /* means only in area-region context! */
wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
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->ymin = event->y - sy;
if (type==WM_GESTURE_CIRCLE) {
if (type == WM_GESTURE_CIRCLE) {
#ifdef GESTURE_MEMORY
rect->xmax = circle_select_size;
#else
rect->xmax = 25; // XXX temp
rect->xmax = 25; // XXX temp
#endif
}
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)) {
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[1] = event->y - sy;
gesture->points= 1;
gesture->points = 1;
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)
{
wmWindow *win= CTX_wm_window(C);
wmWindow *win = CTX_wm_window(C);
if (win->tweak==gesture)
win->tweak= NULL;
if (win->tweak == gesture)
win->tweak = NULL;
BLI_remlink(&win->gesture, gesture);
MEM_freeN(gesture->customdata);
MEM_freeN(gesture);
@@ -118,7 +118,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
void WM_gestures_remove(bContext *C)
{
wmWindow *win= CTX_wm_window(C);
wmWindow *win = CTX_wm_window(C);
while (win->gesture.first)
WM_gesture_end(C, win->gesture.first);
@@ -128,32 +128,32 @@ void WM_gestures_remove(bContext *C)
/* tweak and line gestures */
int wm_gesture_evaluate(wmGesture *gesture)
{
if (gesture->type==WM_GESTURE_TWEAK) {
rcti *rect= gesture->customdata;
int dx= rect->xmax - rect->xmin;
int dy= rect->ymax - rect->ymin;
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 val= EVT_GESTURE_W;
if (theta==0) val= EVT_GESTURE_E;
else if (theta==1) val= EVT_GESTURE_NE;
else if (theta==2) val= EVT_GESTURE_N;
else if (theta==3) val= EVT_GESTURE_NW;
else if (theta==-1) val= EVT_GESTURE_SE;
else if (theta==-2) val= EVT_GESTURE_S;
else if (theta==-3) val= EVT_GESTURE_SW;
if (gesture->type == WM_GESTURE_TWEAK) {
rcti *rect = gesture->customdata;
int dx = rect->xmax - rect->xmin;
int dy = rect->ymax - rect->ymin;
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 val = EVT_GESTURE_W;
if (theta == 0) val = EVT_GESTURE_E;
else if (theta == 1) val = EVT_GESTURE_NE;
else if (theta == 2) val = EVT_GESTURE_N;
else if (theta == 3) val = EVT_GESTURE_NW;
else if (theta == -1) val = EVT_GESTURE_SE;
else if (theta == -2) val = EVT_GESTURE_S;
else if (theta == -3) val = EVT_GESTURE_SW;
#if 0
/* debug */
if (val==1) printf("tweak north\n");
if (val==2) printf("tweak north-east\n");
if (val==3) printf("tweak east\n");
if (val==4) printf("tweak south-east\n");
if (val==5) printf("tweak south\n");
if (val==6) printf("tweak south-west\n");
if (val==7) printf("tweak west\n");
if (val==8) printf("tweak north-west\n");
if (val == 1) printf("tweak north\n");
if (val == 2) printf("tweak north-east\n");
if (val == 3) printf("tweak east\n");
if (val == 4) printf("tweak south-east\n");
if (val == 5) printf("tweak south\n");
if (val == 6) printf("tweak south-west\n");
if (val == 7) printf("tweak west\n");
if (val == 8) printf("tweak north-west\n");
#endif
return val;
}
@@ -166,7 +166,7 @@ int wm_gesture_evaluate(wmGesture *gesture)
static void wm_gesture_draw_rect(wmGesture *gt)
{
rcti *rect= (rcti *)gt->customdata;
rcti *rect = (rcti *)gt->customdata;
glEnable(GL_BLEND);
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)
{
rcti *rect= (rcti *)gt->customdata;
rcti *rect = (rcti *)gt->customdata;
glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96);
@@ -206,22 +206,22 @@ static void wm_gesture_draw_line(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);
glEnable(GL_BLEND);
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);
glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96);
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);
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);
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)
{
ScanFillVert *v=NULL, *lastv=NULL, *firstv=NULL;
ScanFillVert *v = NULL, *lastv = NULL, *firstv = NULL;
ScanFillFace *efa;
short *lasso= (short *)gt->customdata;
short *lasso = (short *)gt->customdata;
int i;
BLI_begin_edgefill();
for (i=0; i<gt->points; i++, lasso+=2) {
for (i = 0; i < gt->points; i++, lasso += 2) {
float co[3];
co[0]= (float)lasso[0];
co[1]= (float)lasso[1];
co[2]= 0.0f;
co[0] = (float)lasso[0];
co[1] = (float)lasso[1];
co[2] = 0.0f;
v = BLI_addfillvert(co);
if (lastv)
/* e = */ /* UNUSED */ BLI_addfilledge(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) */
@@ -258,7 +258,7 @@ static void draw_filled_lasso(wmGesture *gt)
glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05);
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->v2->co);
glVertex2fv(efa->v3->co);
@@ -272,7 +272,7 @@ static void draw_filled_lasso(wmGesture *gt)
static void wm_gesture_draw_lasso(wmGesture *gt)
{
short *lasso= (short *)gt->customdata;
short *lasso = (short *)gt->customdata;
int i;
draw_filled_lasso(gt);
@@ -281,19 +281,19 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA);
glBegin(GL_LINE_STRIP);
for (i=0; i<gt->points; i++, lasso+=2)
for (i = 0; i < gt->points; i++, lasso += 2)
glVertex2sv(lasso);
if (gt->type==WM_GESTURE_LASSO)
if (gt->type == WM_GESTURE_LASSO)
glVertex2sv((short *)gt->customdata);
glEnd();
glColor3ub(255, 255, 255);
glLineStipple(1, 0x5555);
glBegin(GL_LINE_STRIP);
lasso= (short *)gt->customdata;
for (i=0; i<gt->points; i++, lasso+=2)
lasso = (short *)gt->customdata;
for (i = 0; i < gt->points; i++, lasso += 2)
glVertex2sv(lasso);
if (gt->type==WM_GESTURE_LASSO)
if (gt->type == WM_GESTURE_LASSO)
glVertex2sv((short *)gt->customdata);
glEnd();
@@ -303,7 +303,7 @@ static void wm_gesture_draw_lasso(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);
glColor3ub(96, 96, 96);
@@ -321,41 +321,41 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
/* called in wm_draw.c */
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 */
wmSubWindowSet(win, gt->swinid);
if (gt->type==WM_GESTURE_RECT)
if (gt->type == WM_GESTURE_RECT)
wm_gesture_draw_rect(gt);
// else if (gt->type==WM_GESTURE_TWEAK)
// wm_gesture_draw_line(gt);
else if (gt->type==WM_GESTURE_CIRCLE)
else if (gt->type == WM_GESTURE_CIRCLE)
wm_gesture_draw_circle(gt);
else if (gt->type==WM_GESTURE_CROSS_RECT) {
if (gt->mode==1)
else if (gt->type == WM_GESTURE_CROSS_RECT) {
if (gt->mode == 1)
wm_gesture_draw_rect(gt);
else
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);
else if (gt->type==WM_GESTURE_LASSO)
else if (gt->type == WM_GESTURE_LASSO)
wm_gesture_draw_lasso(gt);
else if (gt->type==WM_GESTURE_STRAIGHTLINE)
else if (gt->type == WM_GESTURE_STRAIGHTLINE)
wm_gesture_draw_line(gt);
}
}
void wm_gesture_tag_redraw(bContext *C)
{
wmWindow *win= CTX_wm_window(C);
bScreen *screen= CTX_wm_screen(C);
ARegion *ar= CTX_wm_region(C);
wmWindow *win = CTX_wm_window(C);
bScreen *screen = CTX_wm_screen(C);
ARegion *ar = CTX_wm_region(C);
if (screen)
screen->do_draw_gesture= 1;
screen->do_draw_gesture = 1;
wm_tag_redraw_overlay(win, ar);
}

View File

@@ -68,7 +68,7 @@
#include "BLI_utildefines.h"
#include "RE_engine.h"
#include "RE_pipeline.h" /* RE_ free stuff */
#include "RE_pipeline.h" /* RE_ free stuff */
#ifdef WITH_PYTHON
#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)
{
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();
}
GHOST_CreateSystemPaths();
wm_operatortype_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 */
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();
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)
{
if ((U.uiflag & USER_SPLASH_DISABLE) == 0) {
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *prevwin= CTX_wm_window(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *prevwin = CTX_wm_window(C);
if (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)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow* win;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
ScrArea *sa;
ARegion *ar= NULL;
ARegion *ar = NULL;
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
if (!scene) {
// XXX, this should not be needed.
Main *bmain = CTX_data_main(C);
scene= bmain->scene.first;
scene = bmain->scene.first;
}
win = wm->windows.first;
@@ -237,7 +237,7 @@ int WM_init_game(bContext *C)
CTX_wm_window_set(C, win);
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 (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);
/* 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->flag & RGN_FLAG_HIDDEN)) {
ED_region_toggle_hidden(C, arhide);
@@ -308,7 +308,7 @@ static void free_openrecent(void)
{
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);
BLI_freelistN(&(G.recent_files));
@@ -317,7 +317,7 @@ static void free_openrecent(void)
/* bad stuff*/
// XXX copy/paste buffer stuff...
// XXX copy/paste buffer stuff...
extern void free_anim_copybuf(void);
extern void free_anim_drivers_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));
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->modalhandlers);
ED_screen_exit(C, win, win->screen);
@@ -366,15 +366,15 @@ void WM_exit_ext(bContext *C, const short do_python)
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))
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 */
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_anim_copybuf();
free_anim_drivers_copybuf();
@@ -418,7 +418,7 @@ void WM_exit_ext(bContext *C, const short do_python)
GPU_extensions_exit();
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();
@@ -438,7 +438,7 @@ void WM_exit_ext(bContext *C, const short do_python)
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());
MEM_printmemlist();
}
@@ -458,5 +458,5 @@ void WM_exit_ext(bContext *C, const short do_python)
void WM_exit(bContext *C)
{
WM_exit_ext(C, 1);
exit(G.afbreek==1);
exit(G.afbreek == 1);
}

View File

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

View File

@@ -61,21 +61,21 @@
#include "wm_event_types.h"
/******************************* 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)
{
wmKeyMapItem *kmin = MEM_dupallocN(kmi);
kmin->prev= kmin->next= NULL;
kmin->prev = kmin->next = NULL;
kmin->flag &= ~KMI_UPDATE;
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);
kmin->properties= IDP_CopyProperty(kmin->properties);
kmin->ptr->data= kmin->properties;
kmin->properties = IDP_CopyProperty(kmin->properties);
kmin->ptr->data = kmin->properties;
}
return kmin;
@@ -101,8 +101,8 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b)
if (strcmp(a->idname, b->idname) != 0)
return 0;
if (!((a->ptr==NULL && b->ptr==NULL) ||
(a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data))))
if (!((a->ptr == NULL && b->ptr == NULL) ||
(a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data))))
return 0;
if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
@@ -172,7 +172,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname)
{
wmKeyConfig *keyconf;
keyconf= MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname));
BLI_addtail(&wm->keyconfigs, keyconf);
@@ -205,7 +205,7 @@ void WM_keyconfig_free(wmKeyConfig *keyconf)
{
wmKeyMap *km;
while ((km= keyconf->keymaps.first)) {
while ((km = keyconf->keymaps.first)) {
WM_keymap_free(km);
BLI_freelinkN(&keyconf->keymaps, km);
}
@@ -217,8 +217,8 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
{
wmKeyConfig *kc;
for (kc= lb->first; kc; kc= kc->next)
if (0==strncmp(idname, kc->idname, KMAP_MAX_NAME))
for (kc = lb->first; kc; kc = kc->next)
if (0 == strncmp(idname, kc->idname, KMAP_MAX_NAME))
return kc;
return NULL;
@@ -229,7 +229,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
wmKeyConfig *keyconf;
/* first try from preset */
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
keyconf = wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
if (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)
{
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);
km->spaceid= spaceid;
km->regionid= regionid;
km->spaceid = spaceid;
km->regionid = regionid;
return km;
}
@@ -270,18 +270,18 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
wmKeyMapItem *kmi, *kmin;
wmKeyMapDiffItem *kmdi, *kmdin;
keymapn->modal_items= keymap->modal_items;
keymapn->poll= keymap->poll;
keymapn->items.first= keymapn->items.last= NULL;
keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED);
keymapn->modal_items = keymap->modal_items;
keymapn->poll = keymap->poll;
keymapn->items.first = keymapn->items.last = NULL;
keymapn->flag &= ~(KEYMAP_UPDATE | KEYMAP_EXPANDED);
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
kmdin= wm_keymap_diff_item_copy(kmdi);
for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
kmdin = wm_keymap_diff_item_copy(kmdi);
BLI_addtail(&keymapn->items, kmdin);
}
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
kmin= wm_keymap_item_copy(kmi);
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
kmin = wm_keymap_item_copy(kmi);
BLI_addtail(&keymapn->items, kmin);
}
@@ -293,10 +293,10 @@ void WM_keymap_free(wmKeyMap *keymap)
wmKeyMapItem *kmi;
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);
for (kmi=keymap->items.first; kmi; kmi=kmi->next)
for (kmi = keymap->items.first; kmi; kmi = kmi->next)
wm_keymap_item_free(kmi);
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)
{
kmi->type= type;
kmi->val= val;
kmi->keymodifier= keymodifier;
kmi->type = type;
kmi->val = val;
kmi->keymodifier = keymodifier;
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 {
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->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->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->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);
}
}
@@ -337,9 +337,9 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty
wmKeyMapItem *kmi;
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;
if (kmi==NULL) {
if (kmi == NULL) {
kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
BLI_addtail(&keymap->items, kmi);
@@ -402,7 +402,7 @@ static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
{
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);
keymap_item_set_id(keymap, kmin);
BLI_addhead(&keymap->items, kmin);
@@ -413,7 +413,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need
{
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))
return kmi;
@@ -424,7 +424,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte
{
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))
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;
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);
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) {
/* add item */
kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
@@ -482,7 +482,7 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
wmKeyMapDiffItem *kmdi;
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 */
kmi_remove = NULL;
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 */
km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid);
if (km) {
expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED));
expanded = (km->flag & (KEYMAP_EXPANDED | KEYMAP_CHILDREN_EXPANDED));
WM_keymap_free(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);
/* 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);
if (!orig_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 */
if (usermap)
km->flag |= KEYMAP_USER_MODIFIED;
km->flag |= KEYMAP_USER|expanded;
km->flag |= KEYMAP_USER | expanded;
/* apply user changes of diff keymap */
if (usermap && (usermap->flag & KEYMAP_DIFF))
@@ -596,7 +596,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
}
/* 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;
if (defaultmap->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;
for (km= lb->first; km; km= km->next)
if (km->spaceid==spaceid && km->regionid==regionid)
if (0==strncmp(idname, km->idname, KMAP_MAX_NAME))
for (km = lb->first; km; km = km->next)
if (km->spaceid == spaceid && km->regionid == regionid)
if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME))
return km;
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 *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
if (km==NULL) {
km= wm_keymap_new(idname, spaceid, regionid);
if (km == NULL) {
km = wm_keymap_new(idname, spaceid, regionid);
BLI_addtail(&keyconf->keymaps, km);
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)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
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 *km= WM_keymap_find(keyconf, idname, 0, 0);
wmKeyMap *km = WM_keymap_find(keyconf, idname, 0, 0);
km->flag |= KEYMAP_MODAL;
km->modal_items= items;
km->modal_items = items;
if (!items) {
/* init modal items from default config */
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) {
km->modal_items = defaultkm->modal_items;
@@ -685,9 +685,9 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
{
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 (0==strncmp(idname, km->idname, KMAP_MAX_NAME))
if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME))
break;
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");
BLI_addtail(&km->items, kmi);
kmi->propvalue= value;
kmi->propvalue = value;
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)
{
wmOperatorType *ot= WM_operatortype_find(opname, 0);
wmOperatorType *ot = WM_operatortype_find(opname, 0);
if (ot)
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 *name= NULL;
const char *name = NULL;
if (RNA_enum_name(event_type_items, (int)type, &name))
return name;
@@ -735,12 +735,12 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
{
char buf[128];
buf[0]= 0;
buf[0] = 0;
if (kmi->shift == KM_ANY &&
kmi->ctrl == KM_ANY &&
kmi->alt == KM_ANY &&
kmi->oskey == KM_ANY) {
kmi->ctrl == KM_ANY &&
kmi->alt == KM_ANY &&
kmi->oskey == KM_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(
const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler;
wmKeyMap *keymap;
wmKeyMapItem *kmi;
/* find keymap item in handlers */
for (handler=handlers->first; handler; handler=handler->next) {
keymap= WM_keymap_active(wm, handler->keymap);
for (handler = handlers->first; handler; handler = handler->next) {
keymap = WM_keymap_active(wm, handler->keymap);
if (keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
if (keymap && (!keymap->poll || keymap->poll((bContext *)C))) {
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
if (hotkey)
@@ -792,12 +792,12 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (compare_props) {
if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
if (keymap_r) *keymap_r= keymap;
if (keymap_r) *keymap_r = keymap;
return kmi;
}
}
else {
if (keymap_r) *keymap_r= keymap;
if (keymap_r) *keymap_r = keymap;
return kmi;
}
}
@@ -806,54 +806,54 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
}
/* ensure un-initialized keymap is never used */
if (keymap_r) *keymap_r= NULL;
if (keymap_r) *keymap_r = NULL;
return NULL;
}
static wmKeyMapItem *wm_keymap_item_find_props(
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{
wmWindow *win= CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
wmKeyMapItem *found= NULL;
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
wmKeyMapItem *found = NULL;
/* look into multiple handler lists to find the item */
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)
found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
if (sa && found == NULL)
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 (sa) {
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)
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)) {
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)
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)) {
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)
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 (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(
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r)
const bContext *C, const char *opname, int opcontext,
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)
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;
}
char *WM_key_event_operator_string(
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, const short sloppy, char *str, int len)
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, const short sloppy, char *str, int len)
{
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(
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
const bContext *C, const char *opname, int opcontext,
IDProperty *properties, int hotkey, wmKeyMap **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;
}
int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
{
int k1type, k2type;
@@ -950,7 +950,7 @@ static int WM_KEYMAP_UPDATE = 0;
void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi)
{
/* quick tag to do delayed keymap updates */
WM_KEYMAP_UPDATE= 1;
WM_KEYMAP_UPDATE = 1;
if (km)
km->flag |= KEYMAP_UPDATE;
@@ -963,11 +963,11 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km)
wmKeyMapItem *kmi;
int update;
update= (km->flag & KEYMAP_UPDATE);
update = (km->flag & KEYMAP_UPDATE);
km->flag &= ~KEYMAP_UPDATE;
for (kmi=km->items.first; kmi; kmi=kmi->next) {
update= update || (kmi->flag & KMI_UPDATE);
for (kmi = km->items.first; kmi; kmi = kmi->next) {
update = 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)
{
wmKeyConfig *keyconf= WM_keyconfig_active(wm);
wmKeyConfig *keyconf = WM_keyconfig_active(wm);
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)
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;
}
@@ -999,27 +999,27 @@ void WM_keyconfig_update(wmWindowManager *wm)
return;
/* 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) {
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
if (kmdi->add_item)
wm_keymap_item_properties_set(kmdi->add_item);
if (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);
}
}
/* 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 */
if (wm_keymap_test_and_clear_update(km)) {
/* find keymaps */
defaultmap= wm_keymap_preset(wm, km);
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
defaultmap = wm_keymap_preset(wm, km);
addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
/* diff */
if (defaultmap)
@@ -1028,25 +1028,25 @@ void WM_keyconfig_update(wmWindowManager *wm)
}
/* 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 */
defaultmap= wm_keymap_preset(wm, km);
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);
defaultmap = wm_keymap_preset(wm, km);
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);
/* 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) {
kmn->modal_items= km->modal_items;
kmn->poll= km->poll;
kmn->modal_items = km->modal_items;
kmn->poll = km->poll;
}
/* in case of old non-diff keymaps, force extra update to create diffs */
compat_update = compat_update || (usermap && !(usermap->flag & KEYMAP_DIFF));
}
WM_KEYMAP_UPDATE= 0;
WM_KEYMAP_UPDATE = 0;
if (compat_update) {
WM_keyconfig_update_tag(NULL, NULL);
@@ -1067,7 +1067,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
return NULL;
/* 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)
return km;
@@ -1088,8 +1088,8 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
return;
/* construct default keymap from preset + addons */
defaultmap= wm_keymap_preset(wm, keymap);
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
defaultmap = wm_keymap_preset(wm, keymap);
addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if (addonmap) {
defaultmap = wm_keymap_copy(defaultmap);
@@ -1110,11 +1110,11 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
if (kmi->properties) {
IDP_FreeProperty(kmi->properties);
MEM_freeN(kmi->properties);
kmi->properties= NULL;
kmi->properties = NULL;
}
kmi->properties= IDP_CopyProperty(orig->properties);
kmi->ptr->data= kmi->properties;
kmi->properties = IDP_CopyProperty(orig->properties);
kmi->ptr->data = kmi->properties;
}
kmi->propvalue = orig->propvalue;
@@ -1143,7 +1143,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C)
wmKeyMap *usermap;
/* 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) {
WM_keymap_free(usermap);
@@ -1158,7 +1158,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
{
wmKeyMapItem *kmi;
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (kmi->id == id) {
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 */
wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
{
wmKeyMap *km=NULL;
wmKeyMap *km = NULL;
SpaceLink *sl = CTX_wm_space_data(C);
/* 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);
/* 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);
}
}
@@ -1214,7 +1214,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Curve", 0, 0);
/* 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);
}
}
@@ -1225,7 +1225,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
km = WM_keymap_find_all(C, "Pose", 0, 0);
}
else if (strstr(opname, "SCULPT_OT")) {
switch(CTX_data_mode_enum(C)) {
switch (CTX_data_mode_enum(C)) {
case OB_MODE_SCULPT:
km = WM_keymap_find_all(C, "Sculpt", 0, 0);
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);
/* 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);
}
}
@@ -1254,7 +1254,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (strstr(opname, "PAINT_OT")) {
/* check for relevant mode */
switch(CTX_data_mode_enum(C)) {
switch (CTX_data_mode_enum(C)) {
case OB_MODE_WEIGHT_PAINT:
km = WM_keymap_find_all(C, "Weight Paint", 0, 0);
break;
@@ -1331,7 +1331,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (strstr(opname, "TRANSFORM_OT")) {
/* check for relevant editor */
switch(sl->spacetype) {
switch (sl->spacetype) {
case SPACE_VIEW3D:
km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
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;
for (swin= win->subwindows.first; swin; swin= swin->next)
for (swin = win->subwindows.first; swin; swin = swin->next)
wm_subwindow_free(swin);
BLI_freelistN(&win->subwindows);
@@ -105,35 +105,35 @@ static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
{
wmSubWindow *swin;
for (swin= win->subwindows.first; swin; swin= swin->next)
if (swin->swinid==swinid)
for (swin = win->subwindows.first; swin; swin = swin->next)
if (swin->swinid == swinid)
break;
return swin;
}
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) {
*x= swin->winrct.xmax - swin->winrct.xmin + 1;
*y= swin->winrct.ymax - swin->winrct.ymin + 1;
*x = swin->winrct.xmax - swin->winrct.xmin + 1;
*y = swin->winrct.ymax - swin->winrct.ymin + 1;
}
}
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) {
*x= swin->winrct.xmin;
*y= swin->winrct.ymin;
*x = swin->winrct.xmin;
*y = swin->winrct.ymin;
}
}
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) {
/* 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;
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
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;
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)
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);
if (G.f & G_DEBUG) printf("swin %d added\n", freewinid);
swin->swinid= freewinid;
swin->winrct= *winrct;
swin->swinid = freewinid;
swin->winrct = *winrct;
/* and we appy it all right away */
wmSubWindowSet(win, swin->swinid);
/* extra service */
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();
return swin->swinid;
@@ -181,11 +181,11 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
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==win->curswin)
win->curswin= NULL;
if (swin == win->curswin)
win->curswin = NULL;
wm_subwindow_free(swin);
BLI_remlink(&win->subwindows, 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 */
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) {
int width, height;
swin->winrct= *winrct;
swin->winrct = *winrct;
/* CRITICAL, this clamping ensures that
* the viewport never goes outside the screen
@@ -227,7 +227,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
/* extra service */
wmSubWindowSet(win, swinid);
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 {
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 ------------------------------------------------------ */
/* internal state, no threaded opengl! XXX */
static wmWindow *_curwindow= NULL;
static wmSubWindow *_curswin= NULL;
static wmWindow *_curwindow = NULL;
static wmSubWindow *_curswin = NULL;
void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
{
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);
return;
}
win->curswin= _curswin;
_curwindow= win;
win->curswin = _curswin;
_curwindow = win;
width= _curswin->winrct.xmax - _curswin->winrct.xmin + 1;
height= _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1;
height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) {
width= srct->xmax - srct->xmin + 1;
height= srct->ymax - srct->ymin + 1;
width = srct->xmax - srct->xmin + 1;
height = srct->ymax - srct->ymin + 1;
glScissor(srct->xmin, srct->ymin, width, height);
}
else
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();
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)
{
/* prevent opengl from generating errors */
if (x1==x2) x2+=1.0f;
if (y1==y2) y2+=1.0f;
if (x1 == x2) x2 += 1.0f;
if (y1 == y2) y2 += 1.0f;
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 i= index;
unsigned int i = index;
switch(GPU_color_depth()) {
case 12:
i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4);
/* sometimes dithering subtracts! */
i |= 0x070707;
break;
case 15:
case 16:
i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3);
i |= 0x030303;
break;
case 24:
break;
default: // 18 bits...
i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2);
i |= 0x010101;
break;
switch (GPU_color_depth()) {
case 12:
i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
/* sometimes dithering subtracts! */
i |= 0x070707;
break;
case 15:
case 16:
i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
i |= 0x030303;
break;
case 24:
break;
default: // 18 bits...
i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
i |= 0x010101;
break;
}
return i;
@@ -344,27 +344,27 @@ 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:
i= ((i & 48)<<18) + ((i & 12)<<12) + ((i & 3)<<6);
i = ((i & 48) << 18) + ((i & 12) << 12) + ((i & 3) << 6);
i |= 0x3F3F3F;
break;
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! */
i |= 0x0F0F0F;
break;
case 15:
case 16:
i= ((i & 0x7C00)<<9) + ((i & 0x3E0)<<6) + ((i & 0x1F)<<3);
i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
i |= 0x070707;
break;
case 24:
break;
default: // 18 bits...
i= ((i & 0x3F000)<<6) + ((i & 0xFC0)<<4) + ((i & 0x3F)<<2);
default: // 18 bits...
i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
i |= 0x030303;
break;
}
@@ -376,26 +376,26 @@ unsigned int index_to_framebuffer(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);
}
int WM_framebuffer_to_index(unsigned int col)
{
if (col==0) return 0;
if (col == 0) return 0;
switch(GPU_color_depth()) {
case 8:
return ((col & 0xC00000)>>18) + ((col & 0xC000)>>12) + ((col & 0xC0)>>6);
case 12:
return ((col & 0xF00000)>>12) + ((col & 0xF000)>>8) + ((col & 0xF0)>>4);
case 15:
case 16:
return ((col & 0xF80000)>>9) + ((col & 0xF800)>>6) + ((col & 0xF8)>>3);
case 24:
return col & 0xFFFFFF;
default: // 18 bits...
return ((col & 0xFC0000)>>6) + ((col & 0xFC00)>>4) + ((col & 0xFC)>>2);
switch (GPU_color_depth()) {
case 8:
return ((col & 0xC00000) >> 18) + ((col & 0xC000) >> 12) + ((col & 0xC0) >> 6);
case 12:
return ((col & 0xF00000) >> 12) + ((col & 0xF000) >> 8) + ((col & 0xF0) >> 4);
case 15:
case 16:
return ((col & 0xF80000) >> 9) + ((col & 0xF800) >> 6) + ((col & 0xF8) >> 3);
case 24:
return col & 0xFFFFFF;
default: // 18 bits...
return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2);
}
}

View File

@@ -76,7 +76,7 @@
#include "UI_interface.h"
/* the global to talk to ghost */
static GHOST_SystemHandle g_system= NULL;
static GHOST_SystemHandle g_system = NULL;
typedef enum WinOverrideFlag {
WIN_OVERRIDE_GEOM = (1 << 0),
@@ -103,8 +103,8 @@ void wm_get_screensize(int *width_r, int *height_r)
unsigned int uiheight;
GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight);
*width_r= uiwidth;
*height_r= uiheight;
*width_r = uiwidth;
*height_r = uiheight;
}
/* keeps offset and size within monitor bounds */
@@ -128,12 +128,12 @@ static void wm_window_check_position(rcti *rect)
rect->ymin = 0;
}
if (rect->xmax > width) {
d= rect->xmax - width;
d = rect->xmax - width;
rect->xmax -= d;
rect->xmin -= d;
}
if (rect->ymax > height) {
d= rect->ymax - height;
d = rect->ymax - height;
rect->ymax -= d;
rect->ymin -= d;
}
@@ -147,7 +147,7 @@ static void wm_ghostwindow_destroy(wmWindow *win)
{
if (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->modalhandlers);
if (CTX_wm_window(C)==win)
if (CTX_wm_window(C) == win)
CTX_wm_window_set(C, NULL);
}
/* always set drawable and active to NULL,
* prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
wm->windrawable= NULL;
wm->winactive= NULL;
wm->windrawable = NULL;
wm->winactive = NULL;
/* end running jobs, a job end also removes its timer */
for (wt= wm->timers.first; wt; wt= wtnext) {
wtnext= wt->next;
if (wt->win==win && wt->event_type==TIMERJOBS)
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next;
if (wt->win == win && wt->event_type == TIMERJOBS)
wm_jobs_timer_ended(wm, wt);
}
/* timer removing, need to call this api function */
for (wt= wm->timers.first; wt; wt=wtnext) {
wtnext= wt->next;
if (wt->win==win)
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next;
if (wt->win == win)
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)
{
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)
id= win->winid+1;
id = win->winid + 1;
return id;
}
@@ -213,11 +213,11 @@ static int find_free_winid(wmWindowManager *wm)
/* don't change context itself */
wmWindow *wm_window_new(bContext *C)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindow *win= MEM_callocN(sizeof(wmWindow), "window");
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = MEM_callocN(sizeof(wmWindow), "window");
BLI_addtail(&wm->windows, win);
win->winid= find_free_winid(wm);
win->winid = find_free_winid(wm);
return win;
}
@@ -226,23 +226,23 @@ wmWindow *wm_window_new(bContext *C)
/* part of wm_window.c api */
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->posy= winorig->posy;
win->sizex= winorig->sizex;
win->sizey= winorig->sizey;
win->posx = winorig->posx + 10;
win->posy = winorig->posy;
win->sizex = winorig->sizex;
win->sizey = winorig->sizey;
/* duplicate assigns to window */
win->screen= ED_screen_duplicate(win, winorig->screen);
BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname));
win->screen->winid= win->winid;
win->screen = ED_screen_duplicate(win, winorig->screen);
BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
win->screen->winid = win->winid;
win->screen->do_refresh= 1;
win->screen->do_draw= 1;
win->screen->do_refresh = 1;
win->screen->do_draw = 1;
win->drawmethod= -1;
win->drawdata= NULL;
win->drawmethod = -1;
win->drawdata = NULL;
return win;
}
@@ -251,7 +251,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig)
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
{
wmWindow *tmpwin;
bScreen *screen= win->screen;
bScreen *screen = win->screen;
/* first check if we have any non-temp remaining windows */
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);
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->modalhandlers);
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 (screen->temp) {
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
free_libblock(&bmain->screen, screen);
}
/* check remaining windows */
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)
break;
/* in this case we close all */
if (win==NULL)
if (win == NULL)
WM_exit(C);
}
else
@@ -302,8 +302,8 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
{
/* handle the 'temp' window, only set title when not set before */
if (win->screen && win->screen->temp) {
char *title= GHOST_GetTitle(win->ghostwin);
if (title==NULL || title[0]==0)
char *title = GHOST_GetTitle(win->ghostwin);
if (title == NULL || title[0] == 0)
GHOST_SetTitle(win->ghostwin, "Blender");
}
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 */
if (G.save_over && G.main->name[0]) {
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);
}
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)
* 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) */
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 (wm->file_saved)
@@ -338,7 +338,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
int scr_w, scr_h, posy;
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)
{
@@ -348,12 +348,12 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
#endif
/* Disable AA for now, as GL_SELECT (used for border, lasso, ... select)
* doesn't work well when AA is initialized, even if not used. */
ghostwin= GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey,
(GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL,
0 /* no stereo */,
0 /* no AA */);
ghostwin = GHOST_CreateWindow(g_system, title,
win->posx, posy, win->sizex, win->sizey,
(GHOST_TWindowState)win->windowstate,
GHOST_kDrawingContextTypeOpenGL,
0 /* no stereo */,
0 /* no AA */);
if (ghostwin) {
/* 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*/
GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
win->ghostwin= ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
win->ghostwin = ghostwin;
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
if (win->eventstate==NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
if (win->eventstate == NULL)
win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
/* until screens get drawn, make it nice grey */
glClearColor(.55, .55, .55, 0.0);
@@ -404,7 +404,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
#if defined(__APPLE__) && !defined(GHOST_COCOA)
//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);
}
@@ -415,8 +415,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
#endif
}
for (win= wm->windows.first; win; win= win->next) {
if (win->ghostwin==NULL) {
for (win = wm->windows.first; win; win = win->next) {
if (win->ghostwin == NULL) {
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
win->posx = wm_init_state.start_x;
win->posy = wm_init_state.start_y;
@@ -433,8 +433,8 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
wm_window_add_ghostwindow("Blender", win);
}
/* happens after fileread */
if (win->eventstate==NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
if (win->eventstate == NULL)
win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
/* add keymap handlers (1 handler for all keys in map!) */
keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0);
@@ -448,7 +448,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
/* 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_window_title(wm, win);
@@ -460,15 +460,15 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
/* area-rip calls this */
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->posy= rect->ymin;
win->sizex= rect->xmax - rect->xmin;
win->sizey= rect->ymax - rect->ymin;
win->posx = rect->xmin;
win->posy = rect->ymin;
win->sizex = rect->xmax - rect->xmin;
win->sizey = rect->ymax - rect->ymin;
win->drawmethod= -1;
win->drawdata= NULL;
win->drawmethod = -1;
win->drawdata = NULL;
WM_check(C);
@@ -488,20 +488,20 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
wm_window_check_position(position);
/* 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)
break;
/* add new window? */
if (win==NULL) {
win= wm_window_new(C);
if (win == NULL) {
win = wm_window_new(C);
win->posx= position->xmin;
win->posy= position->ymin;
win->posx = position->xmin;
win->posy = position->ymin;
}
win->sizex= position->xmax - position->xmin;
win->sizey= position->ymax - position->ymin;
win->sizex = position->xmax - position->xmin;
win->sizey = position->ymax - position->ymin;
if (win->ghostwin) {
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? */
if (win->screen==NULL)
win->screen= ED_screen_add(win, CTX_data_scene(C), "temp");
if (win->screen == NULL)
win->screen = ED_screen_add(win, CTX_data_scene(C), "temp");
win->screen->temp = 1;
/* make window active, and validate/resize */
@@ -518,10 +518,10 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
WM_check(C);
/* ensure it shows the right spacetype editor */
sa= win->screen->areabase.first;
sa = win->screen->areabase.first;
CTX_wm_area_set(C, sa);
if (type==WM_WINDOW_RENDER) {
if (type == WM_WINDOW_RENDER) {
ED_area_newspace(C, sa, SPACE_IMAGE);
}
else {
@@ -530,11 +530,11 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
ED_screen_set(C, win->screen);
if (sa->spacetype==SPACE_IMAGE)
if (sa->spacetype == SPACE_IMAGE)
GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render"));
else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
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"));
else
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_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;
}
@@ -558,14 +558,14 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* fullscreen operator callback */
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;
if (G.background)
return OPERATOR_CANCELLED;
state= GHOST_GetWindowState(window->ghostwin);
if (state!=GHOST_kWindowStateFullScreen)
state = GHOST_GetWindowState(window->ghostwin);
if (state != GHOST_kWindowStateFullScreen)
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
else
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
@@ -589,24 +589,24 @@ typedef enum
static int query_qual(modifierKeyType qual)
{
GHOST_TModifierKeyMask left, right;
int val= 0;
int val = 0;
switch(qual) {
switch (qual) {
case SHIFT:
left= GHOST_kModifierKeyLeftShift;
right= GHOST_kModifierKeyRightShift;
left = GHOST_kModifierKeyLeftShift;
right = GHOST_kModifierKeyRightShift;
break;
case CONTROL:
left= GHOST_kModifierKeyLeftControl;
right= GHOST_kModifierKeyRightControl;
left = GHOST_kModifierKeyLeftControl;
right = GHOST_kModifierKeyRightControl;
break;
case OS:
left= right= GHOST_kModifierKeyOS;
left = right = GHOST_kModifierKeyOS;
break;
case ALT:
default:
left= GHOST_kModifierKeyLeftAlt;
right= GHOST_kModifierKeyRightAlt;
left = GHOST_kModifierKeyLeftAlt;
right = GHOST_kModifierKeyRightAlt;
break;
}
@@ -619,12 +619,12 @@ static int query_qual(modifierKeyType qual)
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) {
// 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);
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 */
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
{
bContext *C= private;
wmWindowManager *wm= CTX_wm_manager(C);
GHOST_TEventType type= GHOST_GetEventType(evt);
int time= GHOST_GetEventTime(evt);
bContext *C = private;
wmWindowManager *wm = CTX_wm_manager(C);
GHOST_TEventType type = GHOST_GetEventType(evt);
int time = GHOST_GetEventTime(evt);
if (type == GHOST_kEventQuit) {
WM_exit(C);
}
else {
GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data= GHOST_GetEventData(evt);
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
wmWindow *win;
if (!ghostwin) {
@@ -659,54 +659,54 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
return 1;
}
else {
win= GHOST_GetWindowUserData(ghostwin);
win = GHOST_GetWindowUserData(ghostwin);
}
switch(type) {
switch (type) {
case GHOST_kEventWindowDeactivate:
wm_event_add_ghostevent(wm, win, type, time, data);
win->active= 0; /* XXX */
win->active = 0; /* XXX */
break;
case GHOST_kEventWindowActivate:
{
GHOST_TEventKeyData kdata;
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);
/* bad ghost support for modifier keys... so on activate we set the modifiers again */
kdata.ascii= '\0';
kdata.utf8_buf[0]= '\0';
kdata.ascii = '\0';
kdata.utf8_buf[0] = '\0';
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);
}
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);
}
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);
}
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);
}
/* 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 */
GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x= cx;
win->eventstate->y= (win->sizey-1) - cy;
win->eventstate->x = cx;
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);
break;
@@ -729,22 +729,22 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
state = GHOST_GetWindowState(win->ghostwin);
win->windowstate = state;
/* win32: gives undefined window size when minimized */
if (state!=GHOST_kWindowStateMinimized) {
/* win32: gives undefined window size when minimized */
if (state != GHOST_kWindowStateMinimized) {
GHOST_RectangleHandle client_rect;
int l, t, r, b, scr_w, scr_h;
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_DisposeRectangle(client_rect);
wm_get_screensize(&scr_w, &scr_h);
sizex= r-l;
sizey= b-t;
posx= l;
posy= scr_h - t - win->sizey;
sizex = r - l;
sizey = b - t;
posx = l;
posy = scr_h - t - win->sizey;
/*
* 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.
*/
if (win->sizex != sizex ||
win->sizey != sizey ||
win->posx != posx ||
win->posy != posy)
win->sizey != sizey ||
win->posx != posx ||
win->posy != posy)
{
win->sizex= sizex;
win->sizey= sizey;
win->posx= posx;
win->posy= posy;
win->sizex = sizex;
win->sizey = sizey;
win->posx = posx;
win->posy = posy;
/* debug prints */
if (0) {
state = GHOST_GetWindowState(win->ghostwin);
if (state==GHOST_kWindowStateNormal) {
if (state == GHOST_kWindowStateNormal) {
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");
}
else if (state==GHOST_kWindowStateMaximized) {
else if (state == GHOST_kWindowStateMaximized) {
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 (type!=GHOST_kEventWindowSize) {
if (type != GHOST_kEventWindowSize) {
if (G.f & G_DEBUG) {
printf("win move event pos %d %d size %d %d\n",
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_draw_window_clear(win);
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_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
}
}
break;
@@ -823,35 +823,35 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
case GHOST_kEventDraggingDropDone:
{
wmEvent event;
GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt);
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
int cx, cy, wx, wy;
/* entering window, update mouse pos */
GHOST_GetCursorPosition(g_system, &wx, &wy);
GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
win->eventstate->x= cx;
win->eventstate->y= (win->sizey-1) - cy;
win->eventstate->x = cx;
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
event.type= MOUSEMOVE;
event.prevx= event.x;
event.prevy= event.y;
event.type = MOUSEMOVE;
event.prevx = event.x;
event.prevy = event.y;
wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active= 1;
wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
win->active = 1;
wm_event_add(win, &event);
/* make blender drop event with custom data pointing to wm drags */
event.type= EVT_DROP;
event.val= KM_RELEASE;
event.custom= EVT_DATA_LISTBASE;
event.customdata= &wm->drags;
event.customdatafree= 1;
event.type = EVT_DROP;
event.val = KM_RELEASE;
event.custom = EVT_DATA_LISTBASE;
event.customdata = &wm->drags;
event.customdatafree = 1;
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: */
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra= ddd->data;
GHOST_TStringArray *stra = ddd->data;
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]);
/* 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);
/* 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)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmTimer *wt, *wtnext;
wmWindow *win;
double time= PIL_check_seconds_timer();
int retval= 0;
double time = PIL_check_seconds_timer();
int retval = 0;
for (wt= wm->timers.first; wt; wt= wtnext) {
wtnext= wt->next; /* in case timer gets removed */
win= wt->win;
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next; /* in case timer gets removed */
win = wt->win;
if (wt->sleep==0) {
if (wt->sleep== 0) {
if (time > wt->ntime) {
wt->delta= time - wt->ltime;
wt->delta = time - wt->ltime;
wt->duration += wt->delta;
wt->ltime= time;
wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep);
wt->ltime = time;
wt->ntime = wt->stime + wt->timestep *ceil(wt->duration / wt->timestep);
if (wt->event_type == TIMERJOBS)
wm_jobs_timer(C, wm, wt);
else if (wt->event_type == TIMERAUTOSAVE)
wm_autosave_timer(C, wm, wt);
else if (win) {
wmEvent event= *(win->eventstate);
wmEvent event = *(win->eventstate);
event.type= wt->event_type;
event.custom= EVT_DATA_TIMER;
event.customdata= wt;
event.type = wt->event_type;
event.custom = EVT_DATA_TIMER;
event.customdata = wt;
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)
{
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent)
GHOST_DispatchEvents(g_system);
@@ -944,7 +944,7 @@ void wm_window_process_events(const bContext *C)
hasevent |= wm_window_timer(C);
/* no event, we sleep 5 milliseconds */
if (hasevent==0)
if (hasevent == 0)
PIL_sleep_ms(5);
}
@@ -957,19 +957,19 @@ void wm_window_process_events_nosleep(void)
/* exported as handle callback to bke blender.c */
void wm_window_testbreak(void)
{
static double ltime= 0;
double curtime= PIL_check_seconds_timer();
static double ltime = 0;
double curtime = PIL_check_seconds_timer();
/* only check for breaks every 50 milliseconds
* if we get called more often.
*/
if ((curtime-ltime)>.05) {
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if ((curtime - ltime) > .05) {
int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
if (hasevent)
GHOST_DispatchEvents(g_system);
ltime= curtime;
ltime = curtime;
}
}
@@ -978,9 +978,9 @@ void wm_window_testbreak(void)
void wm_ghost_init(bContext *C)
{
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);
}
}
@@ -990,7 +990,7 @@ void wm_ghost_exit(void)
if (g_system)
GHOST_DisposeSystem(g_system);
g_system= NULL;
g_system = NULL;
}
/* **************** timer ********************** */
@@ -1000,24 +1000,24 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
{
wmTimer *wt;
for (wt= wm->timers.first; wt; wt= wt->next)
if (wt==timer)
for (wt = wm->timers.first; wt; wt = wt->next)
if (wt == timer)
break;
if (wt)
wt->sleep= dosleep;
wt->sleep = dosleep;
}
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->ltime= PIL_check_seconds_timer();
wt->ntime= wt->ltime + timestep;
wt->stime= wt->ltime;
wt->timestep= timestep;
wt->win= win;
wt->event_type = event_type;
wt->ltime = PIL_check_seconds_timer();
wt->ntime = wt->ltime + timestep;
wt->stime = wt->ltime;
wt->timestep = timestep;
wt->win = win;
BLI_addtail(&wm->timers, wt);
@@ -1029,12 +1029,12 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
wmTimer *wt;
/* extra security check */
for (wt= wm->timers.first; wt; wt= wt->next)
if (wt==timer)
for (wt = wm->timers.first; wt; wt = wt->next)
if (wt == timer)
break;
if (wt) {
if (wm->reports.reporttimer == wt)
wm->reports.reporttimer= NULL;
wm->reports.reporttimer = NULL;
BLI_remlink(&wm->timers, wt);
if (wt->customdata)
@@ -1052,18 +1052,18 @@ char *WM_clipboard_text_get(int selection)
if (G.background)
return NULL;
buf= (char*)GHOST_getClipboard(selection);
buf = (char *)GHOST_getClipboard(selection);
if (!buf)
return NULL;
/* always convert from \r\n to \n */
newbuf= MEM_callocN(strlen(buf)+1, "WM_clipboard_text_get");
newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get");
for (p= buf, p2= newbuf; *p; p++) {
for (p = buf, p2 = newbuf; *p; p++) {
if (*p != '\r')
*(p2++)= *p;
*(p2++) = *p;
}
*p2= '\0';
*p2 = '\0';
free(buf); /* ghost uses regular malloc */
@@ -1076,29 +1076,29 @@ void WM_clipboard_text_set(char *buf, int selection)
#ifdef _WIN32
/* do conversion from \n to \r\n on Windows */
char *p, *p2, *newbuf;
int newlen= 0;
int newlen = 0;
for (p= buf; *p; p++) {
for (p = buf; *p; p++) {
if (*p == '\n')
newlen += 2;
else
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') {
*(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);
#else
GHOST_putClipboard((GHOST_TInt8*)buf, selection);
GHOST_putClipboard((GHOST_TInt8 *)buf, selection);
#endif
}
}
@@ -1119,23 +1119,23 @@ void WM_progress_clear(wmWindow *win)
void wm_window_get_position(wmWindow *win, int *posx_r, int *posy_r)
{
*posx_r= win->posx;
*posy_r= win->posy;
*posx_r = win->posx;
*posy_r = win->posy;
}
void wm_window_get_size(wmWindow *win, int *width_r, int *height_r)
{
*width_r= win->sizex;
*height_r= win->sizey;
*width_r = win->sizex;
*height_r = win->sizey;
}
/* exceptional case: - splash is called before events are processed
* 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)
{
GHOST_RectangleHandle bounds= GHOST_GetClientBounds(win->ghostwin);
*width_r= GHOST_GetWidthRectangle(bounds);
*height_r= GHOST_GetHeightRectangle(bounds);
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
*width_r = GHOST_GetWidthRectangle(bounds);
*height_r = GHOST_GetHeightRectangle(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_ScreenToClient(win->ghostwin, *x, *y, x, y);
*y = (win->sizey-1) - *y;
*y = (win->sizey - 1) - *y;
}
/* ******************* exported api ***************** */
@@ -1204,15 +1204,15 @@ void WM_setinitialstate_normal(void)
void WM_cursor_warp(wmWindow *win, int x, int y)
{
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_SetCursorPosition(g_system, x, y);
win->eventstate->prevx= oldx;
win->eventstate->prevy= oldy;
win->eventstate->prevx = oldx;
win->eventstate->prevy = oldy;
}
}