Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/windowmanager/intern/wm.c15
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c5
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c7
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c8
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c11
-rw-r--r--source/blender/windowmanager/intern/wm_menu_type.c10
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c32
-rw-r--r--source/blender/windowmanager/intern/wm_splash_screen.c13
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c7
-rw-r--r--source/blender/windowmanager/intern/wm_uilist_type.c10
-rw-r--r--source/blender/windowmanager/intern/wm_window.c247
11 files changed, 147 insertions, 218 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index f25044b5df7..e7010461c68 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -188,7 +188,6 @@ void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
/* Ensure compatible properties. */
if (op->properties) {
PointerRNA ptr;
-
WM_operator_properties_create_ptr(&ptr, ot);
WM_operator_properties_default(&ptr, false);
@@ -251,8 +250,7 @@ void WM_operator_stack_clear(wmWindowManager *wm)
*/
void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
{
- wmWindow *win;
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
ListBase *lb[2] = {&win->handlers, &win->modalhandlers};
for (int i = 0; i < ARRAY_SIZE(lb); i++) {
LISTBASE_FOREACH (wmEventHandler *, handler_base, lb[i]) {
@@ -360,7 +358,6 @@ void WM_check(bContext *C)
void wm_clear_default_size(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
/* WM context. */
if (wm == NULL) {
@@ -372,7 +369,7 @@ void wm_clear_default_size(bContext *C)
return;
}
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
win->sizex = 0;
win->sizey = 0;
win->posx = 0;
@@ -405,10 +402,6 @@ void wm_add_default(Main *bmain, bContext *C)
/* Context is allowed to be NULL, do not free wm itself (lib_id.c). */
void wm_close_and_free(bContext *C, wmWindowManager *wm)
{
- wmWindow *win;
- wmOperator *op;
- wmKeyConfig *keyconf;
-
if (wm->autosavetimer) {
wm_autosave_timer_ended(wm);
}
@@ -418,16 +411,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_xr_exit(wm);
#endif
+ wmWindow *win;
while ((win = BLI_pophead(&wm->windows))) {
/* Prevent draw clear to use screen. */
BKE_workspace_active_set(win->workspace_hook, NULL);
wm_window_free(C, wm, win);
}
+ wmOperator *op;
while ((op = BLI_pophead(&wm->operators))) {
WM_operator_free(op);
}
+ wmKeyConfig *keyconf;
while ((keyconf = BLI_pophead(&wm->keyconfigs))) {
WM_keyconfig_free(keyconf);
}
@@ -457,7 +453,6 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
void wm_close_and_free_all(bContext *C, ListBase *wmlist)
{
wmWindowManager *wm;
-
while ((wm = wmlist->first)) {
wm_close_and_free(C, wm);
BLI_remlink(wmlist, wm);
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index b3185f57577..0f39e6ccf80 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -353,7 +353,6 @@ void WM_cursor_time(wmWindow *win, int nr)
};
uchar mask[16][2];
uchar bitmap[16][2] = {{0}};
- int i, idx;
if (win->lastcursor == 0) {
win->lastcursor = win->cursor;
@@ -362,12 +361,12 @@ void WM_cursor_time(wmWindow *win, int nr)
memset(&mask, 0xFF, sizeof(mask));
/* print number bottom right justified */
- for (idx = 3; nr && idx >= 0; idx--) {
+ for (int idx = 3; nr && idx >= 0; idx--) {
const char *digit = number_bitmaps[nr % 10];
int x = idx % 2;
int y = idx / 2;
- for (i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
bitmap[i + y * 8][x] = digit[i];
}
nr /= 10;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index de47234695e..ac9d3848f3a 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -203,7 +203,7 @@ static void sound_jack_sync_callback(Main *bmain, int mode, double time)
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *window = wm->windows.first; window != NULL; window = window->next) {
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
Scene *scene = WM_window_get_active_scene(window);
if ((scene->audio.flag & AUDIO_SYNC) == 0) {
continue;
@@ -479,8 +479,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
if (C && wm) {
- wmWindow *win;
-
if (!G.background) {
struct MemFile *undo_memfile = wm->undo_stack ?
ED_undosys_stack_memfile_get_active(wm->undo_stack) :
@@ -507,8 +505,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
WM_jobs_kill_all(wm);
- for (win = wm->windows.first; win; win = win->next) {
-
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
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);
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 189657f7aa3..361b3ed3d7f 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -159,24 +159,22 @@ static void wm_job_main_thread_yield(wmJob *wm_job)
*/
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
- wmJob *wm_job;
-
if (owner && job_type) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner == owner && wm_job->job_type == job_type) {
return wm_job;
}
}
}
else if (owner) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->owner == owner) {
return wm_job;
}
}
}
else if (job_type) {
- for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->job_type == job_type) {
return wm_job;
}
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 3d9ca281897..3b792744d40 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -147,17 +147,12 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
static void wm_keymap_item_properties_update_ot_from_list(ListBase *km_lb)
{
- wmKeyMap *km;
- wmKeyMapItem *kmi;
-
- for (km = km_lb->first; km; km = km->next) {
- wmKeyMapDiffItem *kmdi;
-
- for (kmi = km->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMap *, km, km_lb) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) {
wm_keymap_item_properties_update_ot(kmi);
}
- for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) {
if (kmdi->add_item) {
wm_keymap_item_properties_update_ot(kmdi->add_item);
}
diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c
index dc4efe79433..0c52e636e4d 100644
--- a/source/blender/windowmanager/intern/wm_menu_type.c
+++ b/source/blender/windowmanager/intern/wm_menu_type.c
@@ -41,10 +41,8 @@ static GHash *menutypes_hash = NULL;
MenuType *WM_menutype_find(const char *idname, bool quiet)
{
- MenuType *mt;
-
if (idname[0]) {
- mt = BLI_ghash_lookup(menutypes_hash, idname);
+ MenuType *mt = BLI_ghash_lookup(menutypes_hash, idname);
if (mt) {
return mt;
}
@@ -71,12 +69,10 @@ bool WM_menutype_add(MenuType *mt)
void WM_menutype_freelink(MenuType *mt)
{
- bool ok;
-
- ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
+ bool ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
BLI_assert(ok);
- (void)ok;
+ UNUSED_VARS_NDEBUG(ok);
}
/* called on initialize WM_init() */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index e3c763930c0..5d1607fe506 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -270,9 +270,8 @@ static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
static int pupdate_time(void)
{
static double ltime;
- double time;
- time = PIL_check_seconds_timer();
+ double time = PIL_check_seconds_timer();
ptottime += (time - ltime);
ltime = time;
@@ -282,9 +281,6 @@ static int pupdate_time(void)
static void playanim_toscreen(
PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
{
- float offs_x, offs_y;
- float span_x, span_y;
-
if (ibuf == NULL) {
printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : "<NIL>");
return;
@@ -300,12 +296,12 @@ static void playanim_toscreen(
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* size within window */
- span_x = (ps->zoom * ibuf->x) / (float)ps->win_x;
- span_y = (ps->zoom * ibuf->y) / (float)ps->win_y;
+ float span_x = (ps->zoom * ibuf->x) / (float)ps->win_x;
+ float span_y = (ps->zoom * ibuf->y) / (float)ps->win_y;
/* offset within window */
- offs_x = 0.5f * (1.0f - span_x);
- offs_y = 0.5f * (1.0f - span_y);
+ float offs_x = 0.5f * (1.0f - span_x);
+ float offs_y = 0.5f * (1.0f - span_y);
CLAMP(offs_x, 0.0f, 1.0f);
CLAMP(offs_y, 0.0f, 1.0f);
@@ -392,26 +388,19 @@ static void playanim_toscreen(
static void build_pict_list_ex(
PlayState *ps, const char *first, int totframes, int fstep, int fontid)
{
- char filepath[FILE_MAX];
- uchar *mem;
- // short val;
- PlayAnimPict *picture = NULL;
- struct ImBuf *ibuf = NULL;
- struct anim *anim;
-
if (IMB_isanim(first)) {
/* OCIO_TODO: support different input color space */
- anim = IMB_open_anim(first, IB_rect, 0, NULL);
+ struct anim *anim = IMB_open_anim(first, IB_rect, 0, NULL);
if (anim) {
int pic;
- ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
+ struct ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
playanim_toscreen(ps, NULL, ibuf, fontid, fstep);
IMB_freeImBuf(ibuf);
}
for (pic = 0; pic < IMB_anim_get_duration(anim, IMB_TC_NONE); pic++) {
- picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "Pict");
+ PlayAnimPict *picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "Pict");
picture->anim = anim;
picture->frame = pic;
picture->IB_flags = IB_rect;
@@ -432,6 +421,7 @@ static void build_pict_list_ex(
unsigned short digits;
} fp_decoded;
+ char filepath[FILE_MAX];
BLI_strncpy(filepath, first, sizeof(filepath));
fp_framenr = BLI_path_sequence_decode(
filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
@@ -461,7 +451,7 @@ static void build_pict_list_ex(
return;
}
- picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
+ PlayAnimPict *picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
if (picture == NULL) {
printf("Not enough memory for pict struct '%s'\n", filepath);
close(file);
@@ -478,6 +468,7 @@ static void build_pict_list_ex(
picture->size = size;
picture->IB_flags = IB_rect;
+ uchar *mem;
if (fromdisk == false) {
mem = MEM_mallocN(size, "build pic list");
if (mem == NULL) {
@@ -510,6 +501,7 @@ static void build_pict_list_ex(
if (ptottime > 1.0) {
/* OCIO_TODO: support different input color space */
+ struct ImBuf *ibuf;
if (picture->mem) {
ibuf = IMB_ibImageFromMemory(
picture->mem, picture->size, picture->IB_flags, NULL, picture->name);
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c
index e9be0c33735..eda94f16b25 100644
--- a/source/blender/windowmanager/intern/wm_splash_screen.c
+++ b/source/blender/windowmanager/intern/wm_splash_screen.c
@@ -156,8 +156,6 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
extern int datatoc_splash_png_size;
ImBuf *ibuf = NULL;
- int height = 0;
-
if (U.app_template[0] != '\0') {
char splash_filepath[FILE_MAX];
char template_directory[FILE_MAX];
@@ -174,6 +172,7 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
ibuf = IMB_ibImageFromMemory(splash_data, splash_data_size, IB_rect, NULL, "<splash screen>");
}
+ int height = 0;
if (ibuf) {
height = (width * ibuf->y) / ibuf->x;
if (width != ibuf->x || height != ibuf->y) {
@@ -195,11 +194,9 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSED(arg))
{
- uiBlock *block;
- uiBut *but;
const uiStyle *style = UI_style_get_dpi();
- block = UI_block_begin(C, region, "splash", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "splash", UI_EMBOSS);
/* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized
* with the OS when the splash shows, window clipping in this case gives
@@ -214,7 +211,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
* first draw or if the image changed. */
ImBuf *ibuf = wm_block_splash_image(splash_width, &splash_height);
- but = uiDefButImage(block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
+ uiBut *but = uiDefButImage(
+ block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
UI_but_func_set(but, wm_block_close, block, NULL);
UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
@@ -262,7 +260,6 @@ void WM_OT_splash(wmOperatorType *ot)
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED(arg))
{
- uiBlock *block;
const uiStyle *style = UI_style_get_dpi();
const int dialog_width = U.widget_unit * 24;
const short logo_size = 128 * U.dpi_fac;
@@ -270,7 +267,7 @@ static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED
/* Calculate icon column factor. */
const float split_factor = (float)logo_size / (float)(dialog_width - style->columnspace);
- block = UI_block_begin(C, region, "about", UI_EMBOSS);
+ uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS);
UI_block_flag_enable(
block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT);
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index be6f1079279..fb9c71163c8 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -262,10 +262,10 @@ static bool wm_stereo3d_set_properties(bContext *UNUSED(C), wmOperator *op)
static void wm_stereo3d_set_init(bContext *C, wmOperator *op)
{
- Stereo3dData *s3dd;
wmWindow *win = CTX_wm_window(C);
- op->customdata = s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
+ Stereo3dData *s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
+ op->customdata = s3dd;
/* store the original win stereo 3d settings in case of cancel */
s3dd->stereo3d_format = *win->stereo3d_format;
@@ -278,7 +278,6 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
wmWindow *win_dst = NULL;
const bool is_fullscreen = WM_window_is_fullscreen(win_src);
char prev_display_mode = win_src->stereo3d_format->display_mode;
- Stereo3dData *s3dd;
bool ok = true;
if (G.background) {
@@ -291,7 +290,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
wm_stereo3d_set_properties(C, op);
}
- s3dd = op->customdata;
+ Stereo3dData *s3dd = op->customdata;
*win_src->stereo3d_format = s3dd->stereo3d_format;
if (prev_display_mode == S3D_DISPLAY_PAGEFLIP &&
diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c
index 801043a56d1..ef6d855cb36 100644
--- a/source/blender/windowmanager/intern/wm_uilist_type.c
+++ b/source/blender/windowmanager/intern/wm_uilist_type.c
@@ -38,10 +38,8 @@ static GHash *uilisttypes_hash = NULL;
uiListType *WM_uilisttype_find(const char *idname, bool quiet)
{
- uiListType *ult;
-
if (idname[0]) {
- ult = BLI_ghash_lookup(uilisttypes_hash, idname);
+ uiListType *ult = BLI_ghash_lookup(uilisttypes_hash, idname);
if (ult) {
return ult;
}
@@ -62,12 +60,11 @@ bool WM_uilisttype_add(uiListType *ult)
void WM_uilisttype_freelink(uiListType *ult)
{
- bool ok;
- ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
+ bool ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
BLI_assert(ok);
- (void)ok;
+ UNUSED_VARS_NDEBUG(ok);
}
/* called on initialize WM_init() */
@@ -79,7 +76,6 @@ void WM_uilisttype_init(void)
void WM_uilisttype_free(void)
{
GHashIterator gh_iter;
-
GHASH_ITER (gh_iter, uilisttypes_hash) {
uiListType *ult = BLI_ghashIterator_getValue(&gh_iter);
if (ult->rna_ext.free) {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 8db8694e8a6..6782d8ea484 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -162,8 +162,7 @@ void wm_get_desktopsize(int *r_width, int *r_height)
/* XXX solve dual screen... */
static void wm_window_check_position(rcti *rect)
{
- int width, height, d;
-
+ int width, height;
wm_get_screensize(&width, &height);
if (rect->xmin < 0) {
@@ -175,12 +174,12 @@ static void wm_window_check_position(rcti *rect)
rect->ymin = 0;
}
if (rect->xmax > width) {
- d = rect->xmax - width;
+ int d = rect->xmax - width;
rect->xmax -= d;
rect->xmin -= d;
}
if (rect->ymax > height) {
- d = rect->ymax - height;
+ int d = rect->ymax - height;
rect->ymax -= d;
rect->ymin -= d;
}
@@ -223,8 +222,6 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
* ED_screen_exit should have been called */
void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
{
- wmTimer *wt, *wtnext;
-
/* update context */
if (C) {
WM_event_remove_handlers(C, &win->handlers);
@@ -238,16 +235,14 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
BKE_screen_area_map_free(&win->global_areas);
/* end running jobs, a job end also removes its timer */
- for (wt = wm->timers.first; wt; wt = wtnext) {
- wtnext = wt->next;
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
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;
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
if (wt->win == win) {
WM_event_remove_timer(wm, win, wt);
}
@@ -275,10 +270,9 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
static int find_free_winid(wmWindowManager *wm)
{
- wmWindow *win;
int id = 1;
- for (win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (id <= win->winid) {
id = win->winid + 1;
}
@@ -314,7 +308,6 @@ wmWindow *wm_window_copy(Main *bmain,
wmWindow *win_dst = wm_window_new(bmain, wm, win_parent, is_dialog);
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win_src);
- WorkSpaceLayout *layout_new;
win_dst->posx = win_src->posx + 10;
win_dst->posy = win_src->posy;
@@ -324,9 +317,9 @@ wmWindow *wm_window_copy(Main *bmain,
win_dst->scene = win_src->scene;
STRNCPY(win_dst->view_layer_name, win_src->view_layer_name);
BKE_workspace_active_set(win_dst->workspace_hook, workspace);
- layout_new = duplicate_layout ?
- ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) :
- layout_old;
+ WorkSpaceLayout *layout_new = duplicate_layout ? ED_workspace_layout_duplicate(
+ bmain, workspace, layout_old, win_dst) :
+ layout_old;
BKE_workspace_active_layout_set(win_dst->workspace_hook, win_dst->winid, workspace, layout_new);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -345,9 +338,8 @@ wmWindow *wm_window_copy_test(bContext *C,
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win_dst;
- win_dst = wm_window_copy(bmain, wm, win_src, duplicate_layout, child);
+ wmWindow *win_dst = wm_window_copy(bmain, wm, win_src, duplicate_layout, child);
WM_check(C);
@@ -568,11 +560,9 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wmWindow *win,
bool is_dialog)
{
- GHOST_WindowHandle ghostwin;
- GHOST_GLSettings glSettings = {0};
- int scr_w, scr_h, posy;
/* a new window is created when pageflip mode is required for a window */
+ GHOST_GLSettings glSettings = {0};
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
glSettings.flags |= GHOST_glStereoVisual;
}
@@ -581,13 +571,15 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
glSettings.flags |= GHOST_glDebugContext;
}
+ int scr_w, scr_h;
wm_get_screensize(&scr_w, &scr_h);
- posy = (scr_h - win->posy - win->sizey);
+ int posy = (scr_h - win->posy - win->sizey);
/* Clear drawable so we can set the new window. */
wmWindow *prev_windrawable = wm->windrawable;
wm_window_clear_drawable(wm);
+ GHOST_WindowHandle ghostwin;
if (is_dialog && win->parent) {
ghostwin = GHOST_CreateDialogWindow(g_system,
win->parent->ghostwin,
@@ -613,8 +605,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
}
if (ghostwin) {
- GHOST_RectangleHandle bounds;
-
win->gpuctx = GPU_context_create(ghostwin);
/* needed so we can detect the graphics card below */
@@ -630,7 +620,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wm_window_ensure_eventstate(win);
/* store actual window size in blender window */
- bounds = GHOST_GetClientBounds(win->ghostwin);
+ GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
/* win32: gives undefined window size when minimized */
if (GHOST_GetWindowState(win->ghostwin) != GHOST_kWindowStateMinimized) {
@@ -662,8 +652,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, bool is_dialog)
{
- wmKeyMap *keymap;
-
if (win->ghostwin == NULL) {
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
win->posx = wm_init_state.start_x;
@@ -704,7 +692,7 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo
}
/* add keymap handlers (1 handler for all keys in map!) */
- keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0);
WM_event_add_keymap_handler(&win->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0);
@@ -766,12 +754,9 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
*/
void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
{
- wmWindow *win, *win_next;
-
BLI_assert(G.background == false);
- for (win = wm->windows.first; win; win = win_next) {
- win_next = win->next;
+ LISTBASE_FOREACH_MUTABLE (wmWindow *, win, &wm->windows) {
if (win->ghostwin == NULL) {
wm_window_close(C, wm, win);
}
@@ -781,20 +766,18 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
/* Update window size and position based on data from GHOST window. */
static bool wm_window_update_size_position(wmWindow *win)
{
- GHOST_RectangleHandle client_rect;
- int l, t, r, b, scr_w, scr_h;
- int sizex, sizey, posx, posy;
-
- client_rect = GHOST_GetClientBounds(win->ghostwin);
+ GHOST_RectangleHandle client_rect = GHOST_GetClientBounds(win->ghostwin);
+ int l, t, r, b;
GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
GHOST_DisposeRectangle(client_rect);
+ int scr_w, scr_h;
wm_get_desktopsize(&scr_w, &scr_h);
- sizex = r - l;
- sizey = b - t;
- posx = l;
- posy = scr_h - t - win->sizey;
+ int sizex = r - l;
+ int sizey = b - t;
+ int posx = l;
+ int posy = scr_h - t - win->sizey;
if (win->sizex != sizex || win->sizey != sizey || win->posx != posx || win->posy != posy) {
win->sizex = sizex;
@@ -853,9 +836,6 @@ wmWindow *WM_window_open_temp(bContext *C,
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win_prev = CTX_wm_window(C);
- wmWindow *win;
- bScreen *screen;
- ScrArea *area;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -878,9 +858,11 @@ wmWindow *WM_window_open_temp(bContext *C,
/* Reuse temporary or dialog window if one is open (but don't use a dialog for a regular
* temporary window, or vice versa). */
- for (win = wm->windows.first; win; win = win->next) {
- if (WM_window_is_temp_screen(win) && (dialog == GHOST_IsDialogWindow(win->ghostwin))) {
- break;
+ wmWindow *win = NULL;
+ LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
+ if (WM_window_is_temp_screen(win_iter) &&
+ (dialog == GHOST_IsDialogWindow(win_iter->ghostwin))) {
+ win = win_iter;
}
}
@@ -892,7 +874,7 @@ wmWindow *WM_window_open_temp(bContext *C,
win->posy = rect.ymin;
}
- screen = WM_window_get_active_screen(win);
+ bScreen *screen = WM_window_get_active_screen(win);
win->sizex = BLI_rcti_size_x(&rect);
win->sizey = BLI_rcti_size_y(&rect);
@@ -934,7 +916,7 @@ wmWindow *WM_window_open_temp(bContext *C,
*/
/* ensure it shows the right spacetype editor */
- area = screen->areabase.first;
+ ScrArea *area = screen->areabase.first;
CTX_wm_area_set(C, area);
ED_area_newspace(C, area, space_type, false);
@@ -977,9 +959,8 @@ int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win_src = CTX_wm_window(C);
- bool ok;
- ok = (wm_window_copy_test(C, win_src, true, true) != NULL);
+ bool ok = (wm_window_copy_test(C, win_src, true, true) != NULL);
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -987,9 +968,8 @@ int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win_src = CTX_wm_window(C);
- bool ok;
- ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
+ bool ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -998,13 +978,12 @@ int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *window = CTX_wm_window(C);
- GHOST_TWindowState state;
if (G.background) {
return OPERATOR_CANCELLED;
}
- state = GHOST_GetWindowState(window->ghostwin);
+ GHOST_TWindowState state = GHOST_GetWindowState(window->ghostwin);
if (state != GHOST_kWindowStateFullScreen) {
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
}
@@ -1061,8 +1040,6 @@ typedef enum {
static int query_qual(modifierKeyType qual)
{
GHOST_TModifierKeyMask left, right;
- int val = 0;
-
switch (qual) {
case SHIFT:
left = GHOST_kModifierKeyLeftShift;
@@ -1082,6 +1059,7 @@ static int query_qual(modifierKeyType qual)
break;
}
+ int val = 0;
GHOST_GetModifierKeyState(g_system, left, &val);
if (!val) {
GHOST_GetModifierKeyState(g_system, right, &val);
@@ -1163,8 +1141,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
if (type == GHOST_kEventQuitRequest) {
/* Find an active window to display quit dialog in. */
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
- wmWindow *win;
+ wmWindow *win;
if (ghostwin && GHOST_ValidWindow(g_system, ghostwin)) {
win = GHOST_GetWindowUserData(ghostwin);
}
@@ -1183,7 +1161,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
else {
GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt);
GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
- wmWindow *win;
/* Ghost now can call this function for life resizes,
* but it should return if WM didn't initialize yet.
@@ -1203,7 +1180,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
puts("<!> event has invalid window");
return 1;
}
- win = GHOST_GetWindowUserData(ghostwin);
+ wmWindow *win = GHOST_GetWindowUserData(ghostwin);
switch (type) {
case GHOST_kEventWindowDeactivate:
@@ -1220,7 +1197,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
case GHOST_kEventWindowActivate: {
GHOST_TEventKeyData kdata;
- wmEvent event;
const int keymodifier = ((query_qual(SHIFT) ? KM_SHIFT : 0) |
(query_qual(CONTROL) ? KM_CTRL : 0) |
(query_qual(ALT) ? KM_ALT : 0) | (query_qual(OS) ? KM_OSKEY : 0));
@@ -1320,6 +1296,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* currently it seems to be common practice to generate new event for, but probably
* we'll need utility function for this? (sergey)
*/
+ wmEvent event;
wm_event_init_from_window(win, &event);
event.type = MOUSEMOVE;
event.prevx = event.x;
@@ -1345,8 +1322,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
case GHOST_kEventWindowSize:
case GHOST_kEventWindowMove: {
- GHOST_TWindowState state;
- state = GHOST_GetWindowState(win->ghostwin);
+ GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
win->windowstate = state;
WM_window_set_dpi(win);
@@ -1424,7 +1400,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
}
case GHOST_kEventOpenMainFile: {
- PointerRNA props_ptr;
const char *path = GHOST_GetEventData(evt);
if (path) {
@@ -1433,6 +1408,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* it is correctly set */
CTX_wm_window_set(C, win);
+ PointerRNA props_ptr;
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "filepath", path);
RNA_boolean_set(&props_ptr, "display_file_selector", false);
@@ -1444,12 +1420,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
break;
}
case GHOST_kEventDraggingDropDone: {
- wmEvent event;
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
/* entering window, update mouse pos */
wm_window_update_eventstate(win);
+ wmEvent event;
wm_event_init_from_window(win, &event); /* copy last state, like mouse coords */
/* activate region */
@@ -1479,12 +1455,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
GHOST_TStringArray *stra = ddd->data;
- int a, icon;
- for (a = 0; a < stra->count; a++) {
+ for (int 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]);
+ int icon = ED_file_extension_icon((char *)stra->strings[a]);
WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP);
/* void poin should point to string, it makes a copy */
@@ -1560,44 +1535,44 @@ static int wm_window_timer(const bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
- wmTimer *wt, *wtnext;
- wmWindow *win;
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;
+ /* Mutable in case the timer gets removed. */
+ LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
+ wmWindow *win = wt->win;
- if (wt->sleep == 0) {
- if (time > wt->ntime) {
- wt->delta = time - wt->ltime;
- wt->duration += wt->delta;
- wt->ltime = time;
- wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep);
+ if (wt->sleep != 0) {
+ continue;
+ }
- if (wt->event_type == TIMERJOBS) {
- wm_jobs_timer(wm, wt);
- }
- else if (wt->event_type == TIMERAUTOSAVE) {
- wm_autosave_timer(bmain, wm, wt);
- }
- else if (wt->event_type == TIMERNOTIFIER) {
- WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
- }
- else if (win) {
- wmEvent event;
- wm_event_init_from_window(win, &event);
-
- event.type = wt->event_type;
- event.val = KM_NOTHING;
- event.keymodifier = 0;
- event.custom = EVT_DATA_TIMER;
- event.customdata = wt;
- wm_event_add(win, &event);
-
- retval = 1;
- }
+ if (time > wt->ntime) {
+ wt->delta = time - wt->ltime;
+ wt->duration += wt->delta;
+ wt->ltime = time;
+ wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep);
+
+ if (wt->event_type == TIMERJOBS) {
+ wm_jobs_timer(wm, wt);
+ }
+ else if (wt->event_type == TIMERAUTOSAVE) {
+ wm_autosave_timer(bmain, wm, wt);
+ }
+ else if (wt->event_type == TIMERNOTIFIER) {
+ WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
+ }
+ else if (win) {
+ wmEvent event;
+ wm_event_init_from_window(win, &event);
+
+ event.type = wt->event_type;
+ event.val = KM_NOTHING;
+ event.keymodifier = 0;
+ event.custom = EVT_DATA_TIMER;
+ event.customdata = wt;
+ wm_event_add(win, &event);
+
+ retval = 1;
}
}
}
@@ -1606,11 +1581,9 @@ static int wm_window_timer(const bContext *C)
void wm_window_process_events(const bContext *C)
{
- int hasevent;
-
BLI_assert(BLI_thread_is_main());
- 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);
@@ -1680,17 +1653,12 @@ void WM_event_timer_sleep(wmWindowManager *wm,
wmTimer *timer,
bool do_sleep)
{
- wmTimer *wt;
-
- for (wt = wm->timers.first; wt; wt = wt->next) {
+ LISTBASE_FOREACH (wmTimer *, wt, &wm->timers) {
if (wt == timer) {
+ wt->sleep = do_sleep;
break;
}
}
-
- if (wt) {
- wt->sleep = do_sleep;
- }
}
wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
@@ -1732,35 +1700,33 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm,
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
{
- wmTimer *wt;
-
/* extra security check */
- for (wt = wm->timers.first; wt; wt = wt->next) {
- if (wt == timer) {
- break;
+ wmTimer *wt = NULL;
+ LISTBASE_FOREACH (wmTimer *, timer_iter, &wm->timers) {
+ if (timer_iter == timer) {
+ wt = timer_iter;
}
}
- if (wt) {
- wmWindow *win;
+ if (wt == NULL) {
+ return;
+ }
- if (wm->reports.reporttimer == wt) {
- wm->reports.reporttimer = NULL;
- }
+ if (wm->reports.reporttimer == wt) {
+ wm->reports.reporttimer = NULL;
+ }
- BLI_remlink(&wm->timers, wt);
- if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
- MEM_freeN(wt->customdata);
- }
- MEM_freeN(wt);
-
- /* there might be events in queue with this timer as customdata */
- for (win = wm->windows.first; win; win = win->next) {
- wmEvent *event;
- for (event = win->queue.first; event; event = event->next) {
- if (event->customdata == wt) {
- event->customdata = NULL;
- event->type = EVENT_NONE; /* timer users customdata, dont want NULL == NULL */
- }
+ BLI_remlink(&wm->timers, wt);
+ if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
+ MEM_freeN(wt->customdata);
+ }
+ MEM_freeN(wt);
+
+ /* there might be events in queue with this timer as customdata */
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ LISTBASE_FOREACH (wmEvent *, event, &win->queue) {
+ if (event->customdata == wt) {
+ event->customdata = NULL;
+ event->type = EVENT_NONE; /* timer users customdata, dont want NULL == NULL */
}
}
}
@@ -1780,25 +1746,24 @@ void WM_event_remove_timer_notifier(wmWindowManager *wm, wmWindow *win, wmTimer
static char *wm_clipboard_text_get_ex(bool selection, int *r_len, bool firstline)
{
- char *p, *p2, *buf, *newbuf;
-
if (G.background) {
*r_len = 0;
return NULL;
}
- buf = (char *)GHOST_getClipboard(selection);
+ char *buf = (char *)GHOST_getClipboard(selection);
if (!buf) {
*r_len = 0;
return NULL;
}
/* always convert from \r\n to \n */
- p2 = newbuf = MEM_mallocN(strlen(buf) + 1, __func__);
+ char *newbuf = MEM_mallocN(strlen(buf) + 1, __func__);
+ char *p2 = newbuf;
if (firstline) {
/* will return an over-alloc'ed value in the case there are newlines */
- for (p = buf; *p; p++) {
+ for (char *p = buf; *p; p++) {
if ((*p != '\n') && (*p != '\r')) {
*(p2++) = *p;
}
@@ -1808,7 +1773,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len, bool firstline
}
}
else {
- for (p = buf; *p; p++) {
+ for (char *p = buf; *p; p++) {
if (*p != '\r') {
*(p2++) = *p;
}