/* op can be NULL */ int WM_read_homefile(bContext *C, wmOperator *op) { ListBase wmbase; char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR]; char *home= BLI_gethome(); int from_memory= op?RNA_boolean_get(op->ptr, "factory"):0; int success; BLI_clean(home); free_ttfont(); /* still weird... what does it here? */ G.relbase_valid = 0; if (!from_memory) { BLI_make_file_string(G.sce, tstr, home, ".B25.blend"); } strcpy(scestr, G.sce); /* temporary store */ /* prevent loading no UI */ G.fileflags &= ~G_FILE_NO_UI; /* put aside screens to match with persistant windows later */ wm_window_match_init(C, &wmbase); if (!from_memory && BLI_exists(tstr)) { success = BKE_read_file(C, tstr, NULL, NULL); } else { success = BKE_read_file_from_memory(C, datatoc_B_blend, datatoc_B_blend_size, NULL, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); } /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); wm_check(C); /* opens window(s), checks keymaps */ strcpy(G.sce, scestr); /* restore */ wm_init_userdef(); /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ GPU_default_lights(); /* XXX */ G.save_over = 0; // start with save preference untitled.blend G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.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 */ WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); CTX_wm_window_set(C, NULL); /* exits queues */ return OPERATOR_FINISHED; }
void WM_read_file(bContext *C, char *name, ReportList *reports) { int retval; /* first try to append data from exotic file formats... */ /* it throws error box when file doesnt exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ retval= BKE_read_exotic(CTX_data_scene(C), name); /* we didn't succeed, now try to read Blender file */ if (retval== 0) { ListBase wmbase; /* put aside screens to match with persistant windows later */ /* also exit screens and editors */ wm_window_match_init(C, &wmbase); retval= BKE_read_file(C, name, NULL, reports); G.save_over = 1; /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); wm_check(C); /* opens window(s), checks keymaps */ // XXX mainwindow_set_filename_to_title(G.main->name); if(retval==2) wm_init_userdef(); // in case a userdef is read from regular .blend if (retval!=0) { G.relbase_valid = 1; writeBlog(); } // XXX undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); // refresh_interface_font(); CTX_wm_window_set(C, NULL); /* exits queues */ } else if(retval==1) BKE_write_undo(C, "Import file"); else if(retval == -1) { if(reports && reports->list.first == NULL) BKE_report(reports, RPT_ERROR, "Cannot read file."); } }
int main(void) { dlist *clients = 0, *config = 0; Display *dpy = XOpenDisplay(NULL); MainWin *mw; Imlib_Context context; KeyCode keycode; KeySym keysym; const char *tmp, *homedir; char cfgpath[8192]; Bool invertShift = False; if(! dpy) { fprintf(stderr, "FATAL: Couldn't connect to display.\n"); return -1; } wm_get_atoms(dpy); if(! wm_check(dpy)) { fprintf(stderr, "FATAL: WM not NETWM or GNOME WM Spec compliant.\n"); return -1; } homedir = getenv("HOME"); if(homedir) { snprintf(cfgpath, 8191, "%s/%s", homedir, ".skippyrc"); config = config_load(cfgpath); } else fprintf(stderr, "WARNING: $HOME not set, not loading config.\n"); wm_use_netwm_fullscreen(strcasecmp("true", config_get(config, "general", "useNETWMFullscreen", "true")) == 0); wm_ignore_skip_taskbar(strcasecmp("true", config_get(config, "general", "ignoreSkipTaskbar", "false")) == 0); mw = mainwin_create(dpy, config); if(! mw) { fprintf(stderr, "FATAL: Couldn't create main window.\n"); config_free(config); XCloseDisplay(mw->dpy); return -1; } invertShift = strcasecmp("true", config_get(config, "xinerama", "showAll", "false")) == 0; context = imlib_context_new(); imlib_context_push(context); imlib_context_set_display(dpy); imlib_context_set_visual(mw->visual); imlib_context_set_colormap(mw->colormap); tmp = config_get(config, "general", "keysym", "F11"); keysym = XStringToKeysym(tmp); if(keysym == NoSymbol) { fprintf(stderr, "FATAL: Couldn't look up keysym for '%s', bailing out.\n", tmp); config_free(config); XCloseDisplay(mw->dpy); return -1; } mainwin_update_background(mw); XSelectInput(mw->dpy, mw->root, PropertyChangeMask); keycode = XKeysymToKeycode(mw->dpy, keysym); XGrabKey(mw->dpy, keycode, AnyModifier, mw->root, False, GrabModeAsync, GrabModeAsync); while(! DIE_NOW) { XEvent ev; XNextEvent(mw->dpy, &ev); if(ev.type == PropertyNotify && (ev.xproperty.atom == ESETROOT_PMAP_ID || ev.xproperty.atom == _XROOTPMAP_ID)) mainwin_update_background(mw); else if(ev.type == KeyRelease && ev.xkey.keycode == keycode) { Window leader = None, focused = wm_get_focused(mw->dpy); Bool shifted = (ev.xkey.state & ShiftMask) ? ! invertShift : invertShift; if(ev.xkey.state & Mod1Mask) { if(focused != None) leader = wm_get_group_leader(mw->dpy, focused); if(! leader) continue; } clients = skippy_run(mw, clients, (ev.xkey.state & ControlMask), focused, leader, shifted); } } dlist_free_with_func(clients, (dlist_free_func)clientwin_destroy); XFlush(mw->dpy); mainwin_destroy(mw); imlib_context_pop(); imlib_context_free(context); XSync(dpy, True); XCloseDisplay(dpy); config_free(config); return 0; }