void ui_close_window( UI_WINDOW * wnd ) { ui_mouse_hide(); ui_gadget_delete_all( wnd ); if (W_BACKGROUND) { gr_bm_ubitblt(W_WIDTH, W_HEIGHT, W_X, W_Y, 0, 0, W_BACKGROUND, &(grd_curscreen->sc_canvas.cv_bitmap)); gr_free_bitmap( W_BACKGROUND ); } else { gr_set_current_canvas( NULL ); gr_setcolor( CBLACK ); gr_rect( W_X, W_Y, W_X+W_WIDTH-1, W_Y+W_HEIGHT-1 ); } gr_free_sub_canvas( W_CANVAS ); gr_set_current_canvas( W_OLDCANVAS ); selected_gadget = NULL; remove_window( wnd ); if (CurWindow==wnd) CurWindow = NULL; d_free( wnd ); ui_mouse_show(); }
static void remove_window_from_screen(WINDOW *win) { SCREEN *sp; for (each_screen(sp)) { if (window_is(curscr)) { remove_window(curscr); break; } else if (window_is(stdscr)) { remove_window(stdscr); break; } else if (window_is(newscr)) { remove_window(newscr); break; } } }
static void remove_window_from_screen(WINDOW *win) { SCREEN *sp; #ifdef USE_SP_WINDOWLIST if ((sp = _nc_screen_of(win)) != 0) { if (window_is(curscr)) { remove_window(curscr); } else if (window_is(stdscr)) { remove_window(stdscr); } else if (window_is(newscr)) { remove_window(newscr); } } #else for (each_screen(sp)) { if (window_is(curscr)) { remove_window(curscr); break; } else if (window_is(stdscr)) { remove_window(stdscr); break; } else if (window_is(newscr)) { remove_window(newscr); break; } } #endif }
void Ganash::Application::on_activate() { g_print("on_activate\n"); m_bootstrap = new Ganash::Bootstrap(loc_argc, loc_argv); /* gimp_init_malloc (); gimp_env_init (FALSE); gimp_log_init (); gimp_init_i18n (); */ //m_bootstrap->load_theme(); add_window(*m_bootstrap->m_splash); m_bootstrap->signal_progress().connect(sigc::mem_fun(*this, &Ganash::Application::bootstrap_progress)); //m_bootstrap->signal_complete().connect(sigc::mem_fun(*this, &Ganash::Application::bootstrap_complete)); m_bootstrap->load_plugin(); Ganash::ApplicationWindow *window = new Ganash::ApplicationWindow(); add_window(*window); window->set_default_size(900, 600); window->set_position(Gtk::WIN_POS_CENTER); window->show_all(); bootstrap_progress("", "", 0.0); m_bootstrap->init_plugin(); remove_window(*m_bootstrap->m_splash); m_bootstrap->m_splash->shutdown(); Ganash::Ui::ActionManager *actionManager = Ganash::Ui::ActionManager::instance(); //actionManager->setAction("/menubar/menu", "Edit"); //actionManager->setAction("/menubar/menu/menu", "Insert"); //actionManager->setAction("/menubar/menu/menu/menuitem", "Path"); //actionManager->setAction("/menubar/menu/menu/menuitem", "Shape"); //actionManager->setAction("/menubar/menu/menu/menuitem[@action=rectangle]", "Rect"); // Control/Launch/Player char * xmlbuff = actionManager->toString(); printf("%s\n", xmlbuff); xmlFree(xmlbuff); }
/* * Remove an entry and all it's children from the windowlist. * Returns -1 on failure or 0 on success. */ int remove_window_and_children(win * window) { win *t, *w = windows; GR_WINDOW_ID pid = window->wid; Dprintf("Removing window %d and children\n", window->wid); while (w) { Dprintf("Examining window %d (pid %d)\n", w->wid, w->pid); if ((w->pid == pid) || (w == window)) { Dprintf("Removing window %d (pid %d)\n", w->wid, w->pid); t = w->next; remove_window (w); w = t; continue; } w = w->next; } return 0; }
static void event_process (XEvent *ev) { MdmWindow *gw; Window w; XWindowChanges wchanges; trap_push (); switch (ev->type) { case MapRequest: w = ev->xmaprequest.window; gw = find_window (w, FALSE); if (gw == NULL) { if (ev->xmaprequest.parent == wm_root) { XGrabServer (wm_disp); gw = add_window (w, TRUE /* center */, FALSE /* is_mapped */); XUngrabServer (wm_disp); } } XMapWindow (wm_disp, w); break; case ConfigureRequest: XGrabServer (wm_disp); w = ev->xconfigurerequest.window; gw = find_window (w, FALSE); wchanges.border_width = ev->xconfigurerequest.border_width; wchanges.sibling = ev->xconfigurerequest.above; wchanges.stack_mode = ev->xconfigurerequest.detail; if (gw == NULL || gw->deco == None) { wchanges.x = ev->xconfigurerequest.x; wchanges.y = ev->xconfigurerequest.y; } else { wchanges.x = 1; wchanges.y = 1; } wchanges.width = ev->xconfigurerequest.width; wchanges.height = ev->xconfigurerequest.height; XConfigureWindow (wm_disp, w, ev->xconfigurerequest.value_mask, &wchanges); if (gw != NULL) { gw->x = ev->xconfigurerequest.x; gw->y = ev->xconfigurerequest.y; if (gw->deco != None) { wchanges.x = ev->xconfigurerequest.x - 1; wchanges.y = ev->xconfigurerequest.y - 1; wchanges.width = ev->xconfigurerequest.width + 2 + 2*ev->xconfigurerequest.border_width;; wchanges.height = ev->xconfigurerequest.height + 2 + 2*ev->xconfigurerequest.border_width;; wchanges.border_width = 0; XConfigureWindow (wm_disp, gw->deco, ev->xconfigurerequest.value_mask, &wchanges); center_x_window (gw, gw->deco, gw->win); } else { center_x_window (gw, gw->win, gw->win); } shadow_follow (gw); } XUngrabServer (wm_disp); break; case CirculateRequest: w = ev->xcirculaterequest.window; gw = find_window (w, FALSE); if (gw == NULL) { if (ev->xcirculaterequest.place == PlaceOnTop) XRaiseWindow (wm_disp, w); else XLowerWindow (wm_disp, w); } else { if (ev->xcirculaterequest.place == PlaceOnTop) { if (gw->shadow != None) XRaiseWindow (wm_disp, gw->shadow); if (gw->deco != None) XRaiseWindow (wm_disp, gw->deco); else XRaiseWindow (wm_disp, gw->win); } else { if (gw->deco != None) XLowerWindow (wm_disp, gw->deco); else XLowerWindow (wm_disp, gw->win); if (gw->shadow != None) XLowerWindow (wm_disp, gw->shadow); } } break; case MapNotify: w = ev->xmap.window; gw = find_window (w, FALSE); if (gw != NULL) { if (gw->ignore_next_map > 0) { gw->ignore_next_map --; break; } if ( ! ev->xmap.override_redirect && focus_new_windows) { mdm_wm_focus_window (w); } } break; case UnmapNotify: w = ev->xunmap.window; gw = find_window (w, FALSE); if (gw != NULL) { if (gw->ignore_next_unmap > 0) { gw->ignore_next_unmap --; break; } XGrabServer (wm_disp); if (gw->deco != None) XUnmapWindow (wm_disp, gw->deco); if (gw->shadow != None) XUnmapWindow (wm_disp, gw->shadow); reparent_to_root (gw); remove_window (w); XDeleteProperty (wm_disp, w, XA_WM_STATE); if (w != wm_login_window) revert_focus_to_login (); XUngrabServer (wm_disp); } break; case DestroyNotify: w = ev->xdestroywindow.window; gw = find_window (w, FALSE); if (gw != NULL) { XGrabServer (wm_disp); remove_window (w); if (w != wm_login_window) revert_focus_to_login (); XUngrabServer (wm_disp); } break; case EnterNotify: w = ev->xcrossing.window; gw = find_window (w, TRUE); if (gw != NULL) mdm_wm_focus_window (gw->win); break; case PropertyNotify: if (ev->xproperty.atom == XA_NET_WM_STRUT) { mdm_wm_update_struts (ev->xproperty.display, ev->xproperty.window); constrain_all_windows (); } break; default: break; } trap_pop (); }
void gTox::on_activate() { utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); Glib::Dir dir(m_config_path); std::vector<std::string> accounts(dir.begin(), dir.end()); accounts.resize(std::distance( accounts.begin(), std::remove_if( accounts.begin(), accounts.end(), [](const std::string& name) { utils::debug::scope_log log(DBG_LVL_3("gtox"), { name }); std::string state_ext = ".tox"; bool f_tox = !(name.size() > state_ext.size() && name.substr(name.size() - state_ext.size(), state_ext.size()) == state_ext); bool f_old_tox = (name != "tox_save"); return f_tox && f_old_tox; }))); //filter files with same name .tox //1. remove extension std::transform(accounts.begin(), accounts.end(), accounts.begin(), [](std::string a) { utils::debug::scope_log log(DBG_LVL_3("gtox"), { a }); auto a_p = a.find_last_of("."); if (a_p != std::string::npos) { a.resize(a_p); } return a; }); //2. sort std::sort(accounts.begin(), accounts.end()); //3. remove duplicates accounts.erase(std::unique(accounts.begin(), accounts.end()), accounts.end()); //4. make the full paths std::transform(accounts.begin(), accounts.end(), accounts.begin(), [this](const std::string& name) { utils::debug::scope_log log(DBG_LVL_3("gtox"), { name }); return Glib::build_filename(m_config_path, name + ".tox"); }); // start profile select mark_busy(); auto profile = dialog::profile_selection::create(accounts); unmark_busy(); add_window(*profile); profile->present(); auto profile_ptr = profile.raw(); if (profile->get_path().empty()) { profile->signal_hide().connect_notify([this, profile_ptr]() { utils::debug::scope_log log(DBG_LVL_2("gtox"), {}); if (!profile_ptr->get_path().empty()) { open(Gio::File::create_for_path(profile_ptr->get_path())); } else if (!profile_ptr->is_aborted()) { mark_busy(); auto assistant = dialog::profile_create::create(m_config_path); unmark_busy(); add_window(*assistant); assistant->present(); auto assistant_ptr = assistant.raw(); assistant->signal_hide().connect_notify([this, assistant_ptr]() { utils::debug::scope_log log(DBG_LVL_2("gtox"), {}); Glib::ustring path = assistant_ptr->get_path(); remove_window(*assistant_ptr); delete assistant_ptr; if (!path.empty()) { open(Gio::File::create_for_path(path)); } else { activate(); } }, true); } remove_window(*profile_ptr); delete profile_ptr; }, true); profile->show(); } else { if (!profile->is_aborted()) { activate(); } } Gtk::Application::on_activate(); }
int main(int argc, char **argv) { int num_queued; time_t start_time; double t; long num_frames, fast_skip = 200, fast_rewind = 200; unsigned int width, height; XEvent xevent; const char *prgname = argv[0]; const char *classname = "XLndmovie"; char *pixel_file_name = NULL; FILE *pixel_file; unsigned char *buffer = NULL, *huff = NULL; XImage *shm_image; XShmSegmentInfo shminfo; int shm_major, shm_minor; Bool shm_pixmaps; int ShmCompletionType; int shmtransfer_completed; int i, count, step_key = 0; char xkey[32]; KeySym keysym; XComposeStatus compose; int oc; extern int optind; extern char *optarg; init_signal_handling(); display = xwin_init(NULL, prgname, classname, argc, argv, &screen_no, &width, &height); fixed_font = XLoadQueryFont(display, "fixed"); mit_shm = XShmQueryVersion(display, &shm_major, &shm_minor, &shm_pixmaps); mit_shm = XShmQueryExtension(display); if (mit_shm == True) { /* printf("Shared memory extension used (found V %d.%d)\n", shm_major, shm_minor); */ ShmCompletionType = XShmGetEventBase(display) + ShmCompletion; } /* else printf("Standard Xlib used, no shared memory\n"); */ while ((oc = getopt(argc, argv, "c:f:r:h")) != -1) { switch (oc) { case 'c': cell_boxsize = strtol(optarg, NULL, 10); break; case 'f': fast_skip = strtol(optarg, NULL, 10); if (fast_skip < 1) fast_skip = 200; break; case 'r': fast_rewind = strtol(optarg, NULL, 10); if (fast_rewind < 1) fast_rewind = 200; break; default: fprintf(stderr, "Unknown option \'-%c\' -- ignored\n", oc); break; } } if (optind < argc) pixel_file_name = argv[optind++]; else { fprintf(stderr, "No pixel file specified -- exit\n"); exit (EXIT_FAILURE); } pixel_file = fopen(pixel_file_name, "rb"); if (pixel_file == NULL) { fprintf(stderr, "Failed to open pixel file \"%s\" -- exit\n", pixel_file_name); exit (EXIT_FAILURE); } read_pixheader(pixel_file); if ((cell_boxsize <= 0) || ((width / world_width) < cell_boxsize)) cell_boxsize = width / world_width; if ((height / world_height) < cell_boxsize) cell_boxsize = height / world_height; if (cell_boxsize <= 0) cell_boxsize = 1; if ((height / world_height) < cell_boxsize) cell_boxsize = height / world_height; window_width = world_width * cell_boxsize; pixmap_height = world_height * cell_boxsize; if (fixed_font) window_height = pixmap_height + fixed_font->ascent + fixed_font->descent + 5; else window_height = pixmap_height; buffer = (unsigned char *) malloc(world_width * world_height * sizeof(char)); if (buffer == NULL) { fprintf(stderr, "Failed to allocate internal buffer\n"); exit (EXIT_FAILURE); } huff = (unsigned char *) malloc(world_width * world_height * sizeof(char)); if (buffer == NULL) { fprintf(stderr, "Failed to allocate internal buffer\n"); free(buffer); exit (EXIT_FAILURE); } window = create_window(MOVER | FULLER | CLOSER | RTARROW | LFARROW | UPARROW | DNARROW, window_width, window_height, redraw_pixworld, close_pixwindow, 100, 100, window_width, window_height); XSelectInput(display, window, WH_EVENTMASK | WH_SELECTMASK); map_window(window); if (create_lndgcs(lnd_gc, lndx_gc, background_gc, &text_gc)) { fprintf(stderr, "Failed to create necessary GCs (insufficient colors?)\n"); free(buffer); free(huff); exit (EXIT_FAILURE); } if (mit_shm) { shm_image = XShmCreateImage(display, DefaultVisual(display, screen_no), DefaultDepth(display, screen_no), ZPixmap, NULL, &shminfo, window_width, pixmap_height); /* printf("XImage Structure:\n"); printf("width = %d, height = %d, depth = %d\n", shm_image->width, shm_image->height, shm_image->depth); printf("format: "); switch (shm_image->format) { case XYBitmap: printf("XYBitmap\n"); break; case XYPixmap: printf("XYPixmap\n"); break; case ZPixmap: printf("ZPixmap\n"); break; default: printf("UNKNOWN (%d)\n", shm_image->format); break; } printf("%d bytes per line, %d bits per pixel\n", shm_image->bytes_per_line, shm_image->bits_per_pixel); switch (shm_image->byte_order) { case MSBFirst: printf("byte order: MSBFirst\n"); break; case LSBFirst: printf("byte order: LSBFirst\n"); break; default: printf("byte order UNKNOWN (%d)\n", shm_image->byte_order); break; } switch (shm_image->bitmap_bit_order) { case MSBFirst: printf("bitmap bit order: MSBFirst\n"); break; case LSBFirst: printf("bitmap bit order: LSBFirst\n"); break; default: printf("bitmap bit order UNKNOWN (%d)\n", shm_image->bitmap_bit_order); break; } */ shminfo.shmid = shmget(IPC_PRIVATE, shm_image->bytes_per_line * shm_image->height, IPC_CREAT | 0777); if (shminfo.shmid == -1) { fprintf(stderr, "Failed to get shared memory segment, falling back to standard Xlib\n"); mit_shm = 0; } else { shminfo.shmaddr = shmat(shminfo.shmid, 0, 0); shm_image->data = shminfo.shmaddr; shminfo.readOnly = False; if (XShmAttach(display, &shminfo)) ; /* printf("Shared mem successfully attached to server\n"); */ else { mit_shm = 0; XDestroyImage(shm_image); shmdt(shminfo.shmaddr); shmctl(shminfo.shmid, IPC_RMID, 0); printf("Shared memory released\n"); } } } if (!mit_shm) { paint_pixmap = XCreatePixmap(display, window, window_width, pixmap_height, DefaultDepth(display, screen_no)); XFillRectangle(display, paint_pixmap, background_gc[15], 0, 0, window_width, pixmap_height); } redraw_pixmap = XCreatePixmap(display, window, window_width, pixmap_height, DefaultDepth(display, screen_no)); XFillRectangle(display, redraw_pixmap, background_gc[15], 0, 0, window_width, pixmap_height); /* for (i = 0; i < 6; i++) { XPutPixel(shm_image, 0, 0, lnd_pixel[i]); printf("lnd_pixel[%d]=%08lx -> data=%02x\n", i, lnd_pixel[i], shm_image->data[0]); XPutPixel(shm_image, 0, 0, lndx_pixel[i]); printf("lndx_pixel[%d]=%08lx -> data=%02x\n", i, lndx_pixel[i], shm_image->data[0]); } XPutPixel(shm_image, 0, 0, back_pixel); printf("back_pixel=%08lx -> data=%02x\n", back_pixel, shm_image->data[0]); */ do { XNextEvent(display, &xevent); num_queued = XEventsQueued(display, QueuedAfterFlush); process_xevent(&xevent); } while (!((xevent.type == Expose) && (xevent.xexpose.window == window))); shmtransfer_completed = 1; start_time = time(NULL); num_frames = 0; while (!game_over) { if(feof(pixel_file) || ferror(pixel_file)) { if (resume_fpos != -1) { mode = SINGLE_STEP; /* printf("switched to single step due to feof / ferror\n"); */ step_key = 0; /* printf("rewinding to resume pos %ld\n", resume_fpos); fseek(pixel_file, resume_fpos, SEEK_SET); */ } else { fprintf(stderr, "Encountered EOF without finding any entry point -- quitting\n"); game_over = 1; } } num_queued = XEventsQueued(display, QueuedAfterFlush); while ((num_queued) || ((mode == SINGLE_STEP) && !step_key)) { XNextEvent(display, &xevent); num_queued = XEventsQueued(display, QueuedAfterFlush); /* printf("received event: %s, window: %d\n", event_name[xevent.type], (int) xevent.xany.window); */ if (process_xevent(&xevent)) continue; if (xevent.type == ShmCompletionType) { /* printf("shm transfer completed\n"); */ shmtransfer_completed = 1; } if (xevent.type == KeyPress) { count = XLookupString(&(xevent.xkey), xkey, 32, &keysym, &compose); if (count) { switch(xkey[0]) { case 'f': /* printf("fast forward\n"); */ /* printf("rewind position: %ld\n", resume_fpos); */ mode = FAST_FORWARD; break; case 'r': /* printf("fast rewind\n"); */ /* printf("rewind position: %ld\n", resume_fpos); */ mode = FAST_REWIND; break; case 'b': /* printf("backward play\n"); */ /* printf("rewind position: %ld\n", resume_fpos); */ mode = BACKWARD_PLAY; rewind_generation(pixel_file); break; case 's': /* printf("single step\n"); */ mode = SINGLE_STEP; step_key = 0; break; case 'n': /* printf("normal play\n"); */ /* printf("rewind position: %ld\n", resume_fpos); */ mode = NORMAL_PLAY; break; case 'q': case 'Q': /* printf("game over, bye bye\n"); */ mode = NORMAL_PLAY; step_key = 1; game_over = 1; break; default: step_key = 1; break; } } } } if ((mode == NORMAL_PLAY) || (mode == BACKWARD_PLAY) || ((mode == SINGLE_STEP) && step_key) || ((mode == FAST_FORWARD) && ((generation % fast_skip) == (fast_skip - 1))) || ((mode == FAST_REWIND) && ((generation % fast_rewind) == 1))) { if (mit_shm && shmtransfer_completed) { if (shm_draw_generation(pixel_file, shm_image, buffer, huff)) { mode = SINGLE_STEP; /* printf("switched to single step after shm_draw_generation\n"); */ step_key = 0; } else { if (window != BadValue) XShmPutImage(display, window, background_gc[15], shm_image, 0, 0, 0, window_height - pixmap_height, window_width, pixmap_height, True); if (redraw_pixmap != BadValue) XShmPutImage(display, redraw_pixmap, background_gc[15], shm_image, 0, 0, 0, 0, window_width, pixmap_height, True); shmtransfer_completed = 0; num_frames++; } } else { if (draw_generation(pixel_file, paint_pixmap, buffer, huff)) { mode = SINGLE_STEP; /* printf("switched to single step after draw_generation\n"); */ step_key = 0; } else { if (window != BadValue) XCopyArea(display, paint_pixmap, window, background_gc[15], 0, 0, window_width, pixmap_height, 0, window_height - pixmap_height); if (redraw_pixmap != BadValue) XCopyArea(display, paint_pixmap, redraw_pixmap, background_gc[15], 0, 0, window_width, pixmap_height, 0, 0); num_frames++; } } redraw_text(); if (mode == FAST_REWIND) { if (rewind_generation(pixel_file)) { mode = SINGLE_STEP; /* printf("switched to single step after rewind_generation\n"); */ step_key = 0; } } step_key = 0; } switch (mode) { case BACKWARD_PLAY: if (rewind_generation(pixel_file)) { mode = SINGLE_STEP; /* printf("switched to single step after rewind_generation\n"); */ step_key = 0; } /* fall through */ case FAST_REWIND: if (rewind_generation(pixel_file)) { mode = SINGLE_STEP; /* printf("switched to single step after rewind_generation\n"); */ step_key = 0; } redraw_text(); break; case FAST_FORWARD: if (skip_frame(pixel_file)) { mode = SINGLE_STEP; /* printf("switched to single step after skip_frame\n"); */ step_key = 0; } redraw_text(); break; } } t = difftime(time(NULL), start_time); /* printf("%ld frames in %f seconds (%f frames/sec)\n", num_frames, t, num_frames / t); */ if (mit_shm) { XShmDetach(display, &shminfo); XDestroyImage(shm_image); shmdt(shminfo.shmaddr); shmctl(shminfo.shmid, IPC_RMID, 0); printf("Shared memory released\n"); } free_lndgcs(); if (window != BadValue) remove_window(window); if (redraw_pixmap != BadValue) XFreePixmap(display, redraw_pixmap); if (paint_pixmap != BadValue) XFreePixmap(display, paint_pixmap); free(buffer); free(huff); return (EXIT_SUCCESS); }