x_window_rep::~x_window_rep () { set_identifier (w, 0); XEvent report; while (XCheckWindowEvent (dpy, win, 0xffffffff, &report)); tm_delete (ren); if (ic_ok) XDestroyIC (ic); Window_to_window->reset (win); nr_windows--; XDestroyWindow (dpy, win); gui->deleted_window (win); }
void x_window_rep::initialize () { SI min_w= Min_w, min_h= Min_h; SI def_w= Def_w, def_h= Def_h; SI max_w= Max_w, max_h= Max_h; dpy= gui->dpy; gc = gui->gc; full_screen_flag= false; // time_t start_1= texmacs_time (); ren->set_origin (0, 0); ren->decode (def_w, def_h); def_h= -def_h; ren->decode (min_w, min_h); min_h= -min_h; ren->decode (max_w, max_h); max_h= -max_h; // cout << "Size computation required " << (texmacs_time ()-start_1) << " ms\n"; // time_t start_2= texmacs_time (); unsigned long valuemask= CWOverrideRedirect | CWSaveUnder; //unsigned long valuemask= CWOverrideRedirect | CWSaveUnder | CWBackingStore; XSetWindowAttributes setattr; setattr.override_redirect= (name==NULL); setattr.save_under = True; // (name==NULL); // setattr.backing_store = Always; // FIXME: backing store does not seem to work correctly if (win_w == 0) win_w= def_w; if (win_h == 0) win_h= def_h; if ((win_x+ win_w) > gui->screen_width) win_x= gui->screen_width- win_w; if (win_x < 0) win_x= 0; if ((win_y+ win_h) > gui->screen_height) win_y= gui->screen_height- win_h; if (win_y < 0) win_y=0; win= XCreateWindow (dpy, gui->root, win_x, win_y, win_w, win_h, 0, gui->depth, InputOutput, CopyFromParent, valuemask, &setattr); ren->win= (Drawable) win; // cout << "XWindow creation required " << (texmacs_time ()-start_2) << " ms\n"; //cout << "Hints: " // << min_w << ", " << min_h << " --- " // << def_w << ", " << def_h << " --- " // << max_w << ", " << max_h << "\n"; if (name == NULL) name= const_cast<char*> ("popup"); if (the_name == "") { the_name= name; mod_name= name; } set_hints (min_w, min_h, max_w, max_h); unsigned long ic_mask= 0; ic_ok= false; if (gui->im_ok) { ic= XCreateIC (gui->im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, NULL); if (ic == NULL) cout << "TeXmacs] Warning: couldn't create input context\n"; else { ic_ok= true; XGetICValues (ic, XNFilterEvents, &ic_mask, NULL); } } XSelectInput (dpy, win, ExposureMask | StructureNotifyMask | SubstructureNotifyMask | FocusChangeMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | ic_mask); Atom wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", 1); Atom wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", 1); XSetWMProtocols (dpy, win, &wm_protocols, 1); XSetWMProtocols (dpy, win, &wm_delete_window, 1); nr_windows++; Window_to_window (win)= (void*) this; set_identifier (w, (int) win); notify_position (w, 0, 0); notify_size (w, Def_w, Def_h); }
enum TOKEN scanner_get_token () { char *pend; if (have_peek) { have_peek = false; return scan_peek; } assert (scan_pos != NULL); /* LCOV_EXCL_LINE */ if (*scan_pos == '\0') return TOK_END; /* White space */ if (c_isspace (*scan_pos)) { while ( c_isspace (*scan_pos) ) ++scan_pos; if (scanner_keep_whitespace) { if (*scan_pos == '\0') return TOK_END; return TOK_WHITESPACE; } } /* special characters */ if (*scan_pos == ',') { ++scan_pos; set_identifier (",", 1); return TOK_COMMA; } if (*scan_pos == '-') { ++scan_pos; set_identifier ("-", 1); return TOK_DASH; } if (*scan_pos == ':') { ++scan_pos; set_identifier (":", 1); return TOK_COLONS; } /* Integer or floating-point value */ if (c_isdigit (*scan_pos)) { enum TOKEN rc = TOK_INTEGER; errno = 0; scan_val_int = strtol (scan_pos, &pend, 10); if (*pend == '.') { /* a floating-point value */ scan_val_float = strtold (scan_pos, &pend); rc = TOK_FLOAT; } if ((c_isalpha (*pend) || *pend=='_') || (errno == ERANGE)) die (EXIT_FAILURE, 0, _("invalid numeric value '%s'"), scan_pos); set_identifier (scan_pos, pend-scan_pos); scan_pos = pend; return rc; } /* a valid identifier ( [a-z_][a-z0-9_]+ ) */ if (c_isalpha (*scan_pos) || *scan_pos == '_') { size_t l=1; char *v=scan_pos+1; while ( c_isalpha (*v) || c_isdigit (*v) || *v=='_' ) ++l, ++v; set_identifier (scan_pos, l); scan_pos += l; return TOK_IDENTIFIER; } die (EXIT_FAILURE, 0, _("invalid operand %s"), quote (scan_pos)); return TOK_END; }