… | |
… | |
181 | if (!keyboard) |
181 | if (!keyboard) |
182 | rxvt_fatal ("out of memory, aborting.\n"); |
182 | rxvt_fatal ("out of memory, aborting.\n"); |
183 | #endif |
183 | #endif |
184 | } |
184 | } |
185 | |
185 | |
186 | rxvt_term::~rxvt_term () |
186 | // clean up the most important stuff, do *not* call x or free mem etc. |
|
|
187 | // for use before an emergency exit |
|
|
188 | void rxvt_term::emergency_cleanup () |
187 | { |
189 | { |
188 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
189 | |
|
|
190 | if (cmd_pid) |
190 | if (cmd_pid) |
191 | kill (-cmd_pid, SIGHUP); |
191 | kill (-cmd_pid, SIGHUP); |
192 | |
192 | |
193 | #ifdef UTMP_SUPPORT |
193 | #ifdef UTMP_SUPPORT |
194 | privileged_utmp (RESTORE); |
194 | privileged_utmp (RESTORE); |
195 | #endif |
195 | #endif |
196 | |
196 | |
197 | pty.put (); |
197 | pty.put (); |
|
|
198 | } |
|
|
199 | |
|
|
200 | rxvt_term::~rxvt_term () |
|
|
201 | { |
|
|
202 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
203 | |
|
|
204 | emergency_cleanup (); |
198 | |
205 | |
199 | #if ENABLE_STYLES |
206 | #if ENABLE_STYLES |
200 | for (int i = RS_styleCount; --i; ) |
207 | for (int i = RS_styleCount; --i; ) |
201 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
208 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
202 | delete TermWin.fontset[i]; |
209 | delete TermWin.fontset[i]; |
203 | #endif |
210 | #endif |
204 | delete TermWin.fontset[0]; |
211 | delete TermWin.fontset[0]; |
205 | |
212 | |
206 | if (display) |
213 | if (display) |
207 | { |
214 | { |
|
|
215 | dDisp; |
|
|
216 | |
208 | selection_clear (); |
217 | selection_clear (); |
209 | |
218 | |
210 | #ifdef USE_XIM |
219 | #ifdef USE_XIM |
211 | im_destroy (); |
220 | im_destroy (); |
212 | #endif |
221 | #endif |
213 | #ifdef MENUBAR |
222 | #ifdef MENUBAR |
214 | if (menubarGC) XFreeGC (display->display, menubarGC); |
223 | if (menubarGC) XFreeGC (disp, menubarGC); |
215 | #endif |
224 | #endif |
216 | #ifdef XTERM_SCROLLBAR |
225 | #ifdef XTERM_SCROLLBAR |
217 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
226 | if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); |
218 | if (ShadowGC) XFreeGC (display->display, ShadowGC); |
227 | if (ShadowGC) XFreeGC (disp, ShadowGC); |
219 | #endif |
228 | #endif |
220 | #ifdef PLAIN_SCROLLBAR |
229 | #ifdef PLAIN_SCROLLBAR |
221 | if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); |
230 | if (pscrollbarGC) XFreeGC (disp, pscrollbarGC); |
222 | #endif |
231 | #endif |
223 | #ifdef NEXT_SCROLLBAR |
232 | #ifdef NEXT_SCROLLBAR |
224 | if (blackGC) XFreeGC (display->display, blackGC); |
233 | if (blackGC) XFreeGC (disp, blackGC); |
225 | if (whiteGC) XFreeGC (display->display, whiteGC); |
234 | if (whiteGC) XFreeGC (disp, whiteGC); |
226 | if (grayGC) XFreeGC (display->display, grayGC); |
235 | if (grayGC) XFreeGC (disp, grayGC); |
227 | if (darkGC) XFreeGC (display->display, darkGC); |
236 | if (darkGC) XFreeGC (disp, darkGC); |
228 | if (stippleGC) XFreeGC (display->display, stippleGC); |
237 | if (stippleGC) XFreeGC (disp, stippleGC); |
229 | if (dimple) XFreePixmap (display->display, dimple); |
238 | if (dimple) XFreePixmap (disp, dimple); |
230 | if (upArrow) XFreePixmap (display->display, upArrow); |
239 | if (upArrow) XFreePixmap (disp, upArrow); |
231 | if (downArrow) XFreePixmap (display->display, downArrow); |
240 | if (downArrow) XFreePixmap (disp, downArrow); |
232 | if (upArrowHi) XFreePixmap (display->display, upArrowHi); |
241 | if (upArrowHi) XFreePixmap (disp, upArrowHi); |
233 | if (downArrowHi) XFreePixmap (display->display, downArrowHi); |
242 | if (downArrowHi) XFreePixmap (disp, downArrowHi); |
234 | #endif |
243 | #endif |
235 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
244 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
236 | if (topShadowGC) XFreeGC (display->display, topShadowGC); |
245 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
237 | if (botShadowGC) XFreeGC (display->display, botShadowGC); |
246 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
238 | if (scrollbarGC) XFreeGC (display->display, scrollbarGC); |
247 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
239 | #endif |
248 | #endif |
240 | if (TermWin.gc) XFreeGC (display->display, TermWin.gc); |
249 | if (TermWin.gc) XFreeGC (disp, TermWin.gc); |
241 | |
250 | |
242 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
251 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
243 | delete menuBar.drawable; |
252 | delete menuBar.drawable; |
244 | //if (menuBar.win) |
253 | //if (menuBar.win) |
245 | // XDestroyWindow (display->display, menuBar.win); |
254 | // XDestroyWindow (disp, menuBar.win); |
246 | #endif |
255 | #endif |
247 | delete TermWin.drawable; |
256 | delete TermWin.drawable; |
248 | // destroy all windows |
257 | // destroy all windows |
249 | if (TermWin.parent[0]) |
258 | if (TermWin.parent[0]) |
250 | XDestroyWindow (display->display, TermWin.parent[0]); |
259 | XDestroyWindow (disp, TermWin.parent[0]); |
251 | } |
260 | } |
252 | |
261 | |
253 | // TODO: free pixcolours, colours should become part of rxvt_display |
262 | // TODO: free pixcolours, colours should become part of rxvt_display |
254 | |
263 | |
255 | delete pix_colors_focused; |
264 | delete pix_colors_focused; |
… | |
… | |
261 | |
270 | |
262 | scr_release (); |
271 | scr_release (); |
263 | |
272 | |
264 | /* clear all resources */ |
273 | /* clear all resources */ |
265 | for (int i = 0; i < allocated.size (); i++) |
274 | for (int i = 0; i < allocated.size (); i++) |
266 | free (allocated[i]); |
275 | free (allocated [i]); |
267 | |
276 | |
268 | free (selection.text); |
277 | free (selection.text); |
269 | // TODO: manage env vars in child only(!) |
278 | // TODO: manage env vars in child only(!) |
270 | free (env_windowid); |
279 | free (env_windowid); |
271 | free (env_display); |
280 | free (env_display); |
… | |
… | |
277 | |
286 | |
278 | delete envv; |
287 | delete envv; |
279 | delete argv; |
288 | delete argv; |
280 | |
289 | |
281 | #ifdef KEYSYM_RESOURCE |
290 | #ifdef KEYSYM_RESOURCE |
282 | delete keyboard; |
291 | delete keyboard; |
283 | #endif |
292 | #endif |
284 | } |
293 | } |
285 | |
294 | |
286 | void |
295 | void |
287 | rxvt_term::destroy () |
296 | rxvt_term::destroy () |
… | |
… | |
340 | |
349 | |
341 | delete this; |
350 | delete this; |
342 | } |
351 | } |
343 | |
352 | |
344 | /*----------------------------------------------------------------------*/ |
353 | /*----------------------------------------------------------------------*/ |
|
|
354 | /* |
|
|
355 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
|
|
356 | * TODO: if debugging, this should free up any known resources if we can |
|
|
357 | */ |
|
|
358 | static XErrorHandler old_xerror_handler; |
|
|
359 | |
|
|
360 | static void |
|
|
361 | rxvt_emergency_cleanup () |
|
|
362 | { |
|
|
363 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
364 | (*t)->emergency_cleanup (); |
|
|
365 | } |
|
|
366 | |
|
|
367 | #if ENABLE_FRILLS |
|
|
368 | static void |
|
|
369 | print_x_error (Display *dpy, XErrorEvent *event) |
|
|
370 | { |
|
|
371 | char buffer[BUFSIZ]; |
|
|
372 | char mesg[BUFSIZ]; |
|
|
373 | char number[32]; |
|
|
374 | char *mtype = "XlibMessage"; |
|
|
375 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
|
|
376 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
|
|
377 | rxvt_warn ("An X Error occured, trying to continue after report.\n"); |
|
|
378 | rxvt_warn ("%s: %s\n", mesg, buffer); |
|
|
379 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
|
|
380 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
|
|
381 | sprintf(number, "%d", event->request_code); |
|
|
382 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
|
|
383 | rxvt_warn ("(which is %s)\n", buffer); |
|
|
384 | if (event->request_code >= 128) { |
|
|
385 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
|
|
386 | mesg, BUFSIZ); |
|
|
387 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
|
|
388 | } |
|
|
389 | if ((event->error_code == BadWindow) || |
|
|
390 | (event->error_code == BadPixmap) || |
|
|
391 | (event->error_code == BadCursor) || |
|
|
392 | (event->error_code == BadFont) || |
|
|
393 | (event->error_code == BadDrawable) || |
|
|
394 | (event->error_code == BadColor) || |
|
|
395 | (event->error_code == BadGC) || |
|
|
396 | (event->error_code == BadIDChoice) || |
|
|
397 | (event->error_code == BadValue) || |
|
|
398 | (event->error_code == BadAtom)) { |
|
|
399 | if (event->error_code == BadValue) |
|
|
400 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
|
|
401 | mesg, BUFSIZ); |
|
|
402 | else if (event->error_code == BadAtom) |
|
|
403 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
|
|
404 | mesg, BUFSIZ); |
|
|
405 | else |
|
|
406 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
|
|
407 | mesg, BUFSIZ); |
|
|
408 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
|
|
409 | } |
|
|
410 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
|
|
411 | mesg, BUFSIZ); |
|
|
412 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
|
|
413 | } |
|
|
414 | #endif |
|
|
415 | |
|
|
416 | int |
|
|
417 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
|
|
418 | { |
|
|
419 | if (GET_R->allowedxerror == -1) |
|
|
420 | GET_R->allowedxerror = event->error_code; |
|
|
421 | else |
|
|
422 | { |
|
|
423 | //TODO: GET_R is most likely not the terminal which caused the error |
|
|
424 | //TODO: maybe just output the error and continue? |
|
|
425 | #if ENABLE_FRILLS |
|
|
426 | print_x_error (display, event); |
|
|
427 | #else |
|
|
428 | old_xerror_handler (display, event); |
|
|
429 | #endif |
|
|
430 | } |
|
|
431 | |
|
|
432 | return 0; |
|
|
433 | } |
|
|
434 | |
|
|
435 | int |
|
|
436 | rxvt_xioerror_handler (Display *display) |
|
|
437 | { |
|
|
438 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
|
|
439 | DisplayString (display)); |
|
|
440 | rxvt_emergency_cleanup (); |
|
|
441 | _exit (EXIT_FAILURE); |
|
|
442 | } |
|
|
443 | |
|
|
444 | /* |
|
|
445 | * Catch a fatal signal and tidy up before quitting |
|
|
446 | */ |
|
|
447 | void |
|
|
448 | rxvt_term::sig_term (sig_watcher &w) |
|
|
449 | { |
|
|
450 | #ifdef DEBUG_CMD |
|
|
451 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
452 | #endif |
|
|
453 | rxvt_emergency_cleanup (); |
|
|
454 | signal (w.signum, SIG_DFL); |
|
|
455 | kill (getpid (), w.signum); |
|
|
456 | } |
|
|
457 | |
|
|
458 | /*----------------------------------------------------------------------*/ |
345 | /* rxvt_init () */ |
459 | /* rxvt_init () */ |
346 | bool |
460 | bool |
347 | rxvt_term::init (int argc, const char *const *argv) |
461 | rxvt_term::init (int argc, const char *const *argv) |
348 | { |
462 | { |
349 | SET_R (this); |
463 | SET_R (this); |
… | |
… | |
369 | scrollBar.setIdle (); /* set existence for size calculations */ |
483 | scrollBar.setIdle (); /* set existence for size calculations */ |
370 | #endif |
484 | #endif |
371 | |
485 | |
372 | create_windows (argc, argv); |
486 | create_windows (argc, argv); |
373 | |
487 | |
|
|
488 | dDisp; |
|
|
489 | |
374 | init_xlocale (); |
490 | init_xlocale (); |
375 | |
491 | |
376 | scr_reset (); /* initialize screen */ |
492 | scr_reset (); /* initialize screen */ |
377 | |
493 | |
378 | #if 0 |
494 | #if 0 |
379 | XSynchronize (display->display, True); |
495 | XSynchronize (disp, True); |
380 | #endif |
496 | #endif |
381 | |
497 | |
382 | #ifdef HAVE_SCROLLBARS |
498 | #ifdef HAVE_SCROLLBARS |
383 | if (options & Opt_scrollBar) |
499 | if (options & Opt_scrollBar) |
384 | resize_scrollbar (); /* create and map scrollbar */ |
500 | resize_scrollbar (); /* create and map scrollbar */ |
385 | #endif |
501 | #endif |
386 | #if (MENUBAR_MAX) |
502 | #if (MENUBAR_MAX) |
387 | if (menubar_visible ()) |
503 | if (menubar_visible ()) |
388 | XMapWindow (display->display, menuBar.win); |
504 | XMapWindow (disp, menuBar.win); |
389 | #endif |
505 | #endif |
390 | #ifdef TRANSPARENT |
506 | #ifdef TRANSPARENT |
391 | if (options & Opt_transparent) |
507 | if (options & Opt_transparent) |
392 | { |
508 | { |
393 | XSelectInput (display->display, display->root, PropertyChangeMask); |
509 | XSelectInput (disp, display->root, PropertyChangeMask); |
394 | check_our_parents (); |
510 | check_our_parents (); |
395 | rootwin_ev.start (display, display->root); |
511 | rootwin_ev.start (display, display->root); |
396 | } |
512 | } |
397 | #endif |
513 | #endif |
398 | |
514 | |
399 | XMapWindow (display->display, TermWin.vt); |
515 | XMapWindow (disp, TermWin.vt); |
400 | XMapWindow (display->display, TermWin.parent[0]); |
516 | XMapWindow (disp, TermWin.parent[0]); |
401 | |
517 | |
402 | set_colorfgbg (); |
518 | set_colorfgbg (); |
403 | |
519 | |
404 | init_command (cmd_argv); |
520 | init_command (cmd_argv); |
405 | |
521 | |
… | |
… | |
409 | |
525 | |
410 | check_ev.start (); |
526 | check_ev.start (); |
411 | |
527 | |
412 | return true; |
528 | return true; |
413 | } |
529 | } |
414 | |
|
|
415 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
416 | |
530 | |
417 | void |
531 | void |
418 | rxvt_init () |
532 | rxvt_init () |
419 | { |
533 | { |
420 | /* |
534 | /* |
… | |
… | |
433 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
547 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
434 | /* signal (SIGURG, SIG_DFL); */ |
548 | /* signal (SIGURG, SIG_DFL); */ |
435 | |
549 | |
436 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
550 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
437 | // TODO: handle this with exceptions and tolerate the memory loss |
551 | // TODO: handle this with exceptions and tolerate the memory loss |
438 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
552 | XSetIOErrorHandler (rxvt_xioerror_handler); |
439 | } |
553 | } |
440 | |
554 | |
441 | /* ------------------------------------------------------------------------- * |
555 | /* ------------------------------------------------------------------------- * |
442 | * SIGNAL HANDLING & EXIT HANDLER * |
556 | * SIGNAL HANDLING & EXIT HANDLER * |
443 | * ------------------------------------------------------------------------- */ |
557 | * ------------------------------------------------------------------------- */ |
… | |
… | |
456 | if (pid == (*t)->cmd_pid) |
570 | if (pid == (*t)->cmd_pid) |
457 | { |
571 | { |
458 | (*t)->destroy (); |
572 | (*t)->destroy (); |
459 | break; |
573 | break; |
460 | } |
574 | } |
461 | } |
|
|
462 | |
|
|
463 | /*----------------------------------------------------------------------*/ |
|
|
464 | /* |
|
|
465 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
|
|
466 | * TODO: if debugging, this should free up any known resources if we can |
|
|
467 | */ |
|
|
468 | void |
|
|
469 | rxvt_destroy_all () |
|
|
470 | { |
|
|
471 | // TODO: rxvtd should clean up all ressources |
|
|
472 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
473 | (*t)->destroy (); |
|
|
474 | } |
|
|
475 | |
|
|
476 | /* |
|
|
477 | * Catch a fatal signal and tidy up before quitting |
|
|
478 | */ |
|
|
479 | void |
|
|
480 | rxvt_term::sig_term (sig_watcher &w) |
|
|
481 | { |
|
|
482 | #ifdef DEBUG_CMD |
|
|
483 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
484 | #endif |
|
|
485 | rxvt_destroy_all (); |
|
|
486 | signal (w.signum, SIG_DFL); |
|
|
487 | kill (getpid (), w.signum); |
|
|
488 | } |
|
|
489 | |
|
|
490 | /* INTPROTO */ |
|
|
491 | int |
|
|
492 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
|
|
493 | { |
|
|
494 | if (GET_R->allowedxerror == -1) |
|
|
495 | GET_R->allowedxerror = event->error_code; |
|
|
496 | else |
|
|
497 | { |
|
|
498 | old_xerror_handler (display, event); |
|
|
499 | GET_R->destroy (); |
|
|
500 | } |
|
|
501 | |
|
|
502 | return 0; |
|
|
503 | } |
575 | } |
504 | |
576 | |
505 | /* ------------------------------------------------------------------------- * |
577 | /* ------------------------------------------------------------------------- * |
506 | * MEMORY ALLOCATION WRAPPERS * |
578 | * MEMORY ALLOCATION WRAPPERS * |
507 | * ------------------------------------------------------------------------- */ |
579 | * ------------------------------------------------------------------------- */ |
… | |
… | |
620 | * if width/height are non-zero then override calculated width/height |
692 | * if width/height are non-zero then override calculated width/height |
621 | */ |
693 | */ |
622 | void |
694 | void |
623 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
695 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
624 | { |
696 | { |
625 | short recalc_x, recalc_y; |
697 | short recalc_x, recalc_y; |
626 | int x, y, sb_w, mb_h, flags; |
698 | int x, y, sb_w, mb_h, flags; |
627 | unsigned int w, h; |
699 | unsigned int w, h; |
628 | unsigned int max_width, max_height; |
700 | unsigned int max_width, max_height; |
|
|
701 | dDisp; |
629 | |
702 | |
630 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
703 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
631 | TermWin.ncol, TermWin.nrow, szHint.width, |
704 | TermWin.ncol, TermWin.nrow, szHint.width, |
632 | szHint.height)); |
705 | szHint.height)); |
633 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
706 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
… | |
… | |
731 | |
804 | |
732 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
805 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
733 | window_sb_x = szHint.width - sb_w; |
806 | window_sb_x = szHint.width - sb_w; |
734 | |
807 | |
735 | if (recalc_x) |
808 | if (recalc_x) |
736 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
809 | szHint.x += (DisplayWidth (disp, display->screen) |
737 | - szHint.width - 2 * TermWin.ext_bwidth); |
810 | - szHint.width - 2 * TermWin.ext_bwidth); |
738 | if (recalc_y) |
811 | if (recalc_y) |
739 | szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) |
812 | szHint.y += (DisplayHeight (disp, display->screen) |
740 | - szHint.height - 2 * TermWin.ext_bwidth); |
813 | - szHint.height - 2 * TermWin.ext_bwidth); |
741 | |
814 | |
742 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
815 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
743 | TermWin.nrow = TermWin.height / TermWin.fheight; |
816 | TermWin.nrow = TermWin.height / TermWin.fheight; |
744 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
817 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
… | |
… | |
909 | |
982 | |
910 | /* handle color aliases */ |
983 | /* handle color aliases */ |
911 | if (isdigit (*color)) |
984 | if (isdigit (*color)) |
912 | { |
985 | { |
913 | i = atoi (color); |
986 | i = atoi (color); |
|
|
987 | |
914 | if (i >= 8 && i <= 15) |
988 | if (i >= 8 && i <= 15) |
915 | { /* bright colors */ |
989 | { /* bright colors */ |
916 | i -= 8; |
990 | i -= 8; |
917 | # ifndef NO_BRIGHTCOLOR |
991 | # ifndef NO_BRIGHTCOLOR |
918 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
992 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
919 | SET_PIXCOLOR (idx); |
993 | SET_PIXCOLOR (idx); |
920 | goto Done; |
994 | goto Done; |
921 | # endif |
995 | # endif |
922 | |
|
|
923 | } |
996 | } |
|
|
997 | |
924 | if (i >= 0 && i <= 7) |
998 | if (i >= 0 && i <= 7) |
925 | { /* normal colors */ |
999 | { /* normal colors */ |
926 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
1000 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
927 | SET_PIXCOLOR (idx); |
1001 | SET_PIXCOLOR (idx); |
928 | goto Done; |
1002 | goto Done; |
929 | } |
1003 | } |
930 | } |
1004 | } |
931 | |
1005 | |
932 | if (!rXParseAllocColor (& xcol, color)) |
1006 | if (!rXParseAllocColor (&xcol, color)) |
933 | return; |
1007 | return; |
934 | |
1008 | |
935 | /* XStoreColor (display->display, display->cmap, XColor*); */ |
1009 | /* XStoreColor (display->display, display->cmap, XColor*); */ |
936 | |
1010 | |
937 | /* |
1011 | /* |
… | |
… | |
1040 | * -------------------------------------------------------------------- */ |
1114 | * -------------------------------------------------------------------- */ |
1041 | void |
1115 | void |
1042 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1116 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1043 | { |
1117 | { |
1044 | int fix_screen; |
1118 | int fix_screen; |
1045 | |
|
|
1046 | #ifdef SMART_RESIZE |
1119 | #ifdef SMART_RESIZE |
1047 | int old_width = szHint.width, old_height = szHint.height; |
1120 | int old_width = szHint.width, old_height = szHint.height; |
1048 | #endif |
1121 | #endif |
|
|
1122 | dDisp; |
1049 | |
1123 | |
1050 | window_calc (width, height); |
1124 | window_calc (width, height); |
1051 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1125 | XSetWMNormalHints (disp, TermWin.parent[0], &szHint); |
1052 | |
1126 | |
1053 | if (!ignoreparent) |
1127 | if (!ignoreparent) |
1054 | { |
1128 | { |
1055 | #ifdef SMART_RESIZE |
1129 | #ifdef SMART_RESIZE |
1056 | /* |
1130 | /* |
… | |
… | |
1060 | int x, y, x1, y1; |
1134 | int x, y, x1, y1; |
1061 | int dx, dy; |
1135 | int dx, dy; |
1062 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1136 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1063 | Window unused_cr; |
1137 | Window unused_cr; |
1064 | |
1138 | |
1065 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1139 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
1066 | 0, 0, &x, &y, &unused_cr); |
1140 | 0, 0, &x, &y, &unused_cr); |
1067 | XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, |
1141 | XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1, |
1068 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1142 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1069 | /* |
1143 | /* |
1070 | * if display->root isn't the parent window, a WM will probably have offset |
1144 | * if display->root isn't the parent window, a WM will probably have offset |
1071 | * our position for handles and decorations. Counter it |
1145 | * our position for handles and decorations. Counter it |
1072 | */ |
1146 | */ |
… | |
… | |
1074 | { |
1148 | { |
1075 | x -= x1; |
1149 | x -= x1; |
1076 | y -= y1; |
1150 | y -= y1; |
1077 | } |
1151 | } |
1078 | |
1152 | |
1079 | x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; |
1153 | x1 = (DisplayWidth (disp, display->screen) - old_width) / 2; |
1080 | y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; |
1154 | y1 = (DisplayHeight (disp, display->screen) - old_height) / 2; |
1081 | dx = old_width - szHint.width; |
1155 | dx = old_width - szHint.width; |
1082 | dy = old_height - szHint.height; |
1156 | dy = old_height - szHint.height; |
1083 | |
1157 | |
1084 | /* Check position of the center of the window */ |
1158 | /* Check position of the center of the window */ |
1085 | if (x < x1) /* left half */ |
1159 | if (x < x1) /* left half */ |
… | |
… | |
1089 | if (y < y1) /* top half */ |
1163 | if (y < y1) /* top half */ |
1090 | dy = 0; |
1164 | dy = 0; |
1091 | else if (y == y1) /* exact center */ |
1165 | else if (y == y1) /* exact center */ |
1092 | dy /= 2; |
1166 | dy /= 2; |
1093 | |
1167 | |
1094 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1168 | XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy, |
1095 | szHint.width, szHint.height); |
1169 | szHint.width, szHint.height); |
1096 | #else |
1170 | #else |
1097 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
1171 | XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height); |
1098 | #endif |
1172 | #endif |
1099 | } |
1173 | } |
1100 | |
1174 | |
1101 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1175 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1102 | |
1176 | |
1103 | if (fix_screen || width != old_width || height != old_height) |
1177 | if (fix_screen || width != old_width || height != old_height) |
1104 | { |
1178 | { |
1105 | if (scrollbar_visible ()) |
1179 | if (scrollbar_visible ()) |
1106 | { |
1180 | { |
1107 | XMoveResizeWindow (display->display, scrollBar.win, |
1181 | XMoveResizeWindow (disp, scrollBar.win, |
1108 | window_sb_x, 0, |
1182 | window_sb_x, 0, |
1109 | scrollbar_TotalWidth (), szHint.height); |
1183 | scrollbar_TotalWidth (), szHint.height); |
1110 | resize_scrollbar (); |
1184 | resize_scrollbar (); |
1111 | } |
1185 | } |
1112 | |
1186 | |
1113 | if (menubar_visible ()) |
1187 | if (menubar_visible ()) |
1114 | XMoveResizeWindow (display->display, menuBar.win, |
1188 | XMoveResizeWindow (disp, menuBar.win, |
1115 | window_vt_x, 0, |
1189 | window_vt_x, 0, |
1116 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1190 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1117 | |
1191 | |
1118 | XMoveResizeWindow (display->display, TermWin.vt, |
1192 | XMoveResizeWindow (disp, TermWin.vt, |
1119 | window_vt_x, window_vt_y, |
1193 | window_vt_x, window_vt_y, |
1120 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1194 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1121 | |
1195 | |
1122 | scr_clear (); |
1196 | scr_clear (); |
1123 | #ifdef XPM_BACKGROUND |
1197 | #ifdef XPM_BACKGROUND |
… | |
… | |
1478 | { |
1552 | { |
1479 | int i, found, had_im; |
1553 | int i, found, had_im; |
1480 | const char *p; |
1554 | const char *p; |
1481 | char **s; |
1555 | char **s; |
1482 | char buf[IMBUFSIZ]; |
1556 | char buf[IMBUFSIZ]; |
|
|
1557 | |
|
|
1558 | SET_R (this); |
1483 | |
1559 | |
1484 | im_destroy (); |
1560 | im_destroy (); |
1485 | |
1561 | |
1486 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1562 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1487 | if (Input_Context) |
1563 | if (Input_Context) |