… | |
… | |
159 | #endif |
159 | #endif |
160 | #ifdef USE_XIM |
160 | #ifdef USE_XIM |
161 | im_ev (this, &rxvt_term::im_cb), |
161 | im_ev (this, &rxvt_term::im_cb), |
162 | #endif |
162 | #endif |
163 | sw_term (this, &rxvt_term::sig_term), |
163 | sw_term (this, &rxvt_term::sig_term), |
|
|
164 | sw_int (this, &rxvt_term::sig_term), |
164 | sw_chld (this, &rxvt_term::sig_chld), |
165 | sw_chld (this, &rxvt_term::sig_chld), |
165 | termwin_ev (this, &rxvt_term::x_cb), |
166 | termwin_ev (this, &rxvt_term::x_cb), |
166 | vt_ev (this, &rxvt_term::x_cb), |
167 | vt_ev (this, &rxvt_term::x_cb), |
167 | check_ev (this, &rxvt_term::check_cb), |
168 | check_ev (this, &rxvt_term::check_cb), |
168 | flush_ev (this, &rxvt_term::flush_cb), |
169 | flush_ev (this, &rxvt_term::flush_cb), |
… | |
… | |
180 | if (!keyboard) |
181 | if (!keyboard) |
181 | rxvt_fatal ("out of memory, aborting.\n"); |
182 | rxvt_fatal ("out of memory, aborting.\n"); |
182 | #endif |
183 | #endif |
183 | } |
184 | } |
184 | |
185 | |
185 | 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 () |
186 | { |
189 | { |
187 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
188 | |
|
|
189 | if (cmd_pid) |
190 | if (cmd_pid) |
190 | kill (-cmd_pid, SIGHUP); |
191 | kill (-cmd_pid, SIGHUP); |
191 | |
192 | |
192 | pty.put (); |
|
|
193 | |
|
|
194 | #ifdef UTMP_SUPPORT |
193 | #ifdef UTMP_SUPPORT |
195 | privileged_utmp (RESTORE); |
194 | privileged_utmp (RESTORE); |
196 | #endif |
195 | #endif |
|
|
196 | |
|
|
197 | pty.put (); |
|
|
198 | } |
|
|
199 | |
|
|
200 | rxvt_term::~rxvt_term () |
|
|
201 | { |
|
|
202 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
203 | |
|
|
204 | emergency_cleanup (); |
197 | |
205 | |
198 | #if ENABLE_STYLES |
206 | #if ENABLE_STYLES |
199 | for (int i = RS_styleCount; --i; ) |
207 | for (int i = RS_styleCount; --i; ) |
200 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
208 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
201 | delete TermWin.fontset[i]; |
209 | delete TermWin.fontset[i]; |
202 | #endif |
210 | #endif |
203 | delete TermWin.fontset[0]; |
211 | delete TermWin.fontset[0]; |
204 | |
212 | |
205 | if (display) |
213 | if (display) |
206 | { |
214 | { |
|
|
215 | dDisp; |
|
|
216 | |
207 | selection_clear (); |
217 | selection_clear (); |
208 | |
218 | |
209 | #ifdef USE_XIM |
219 | #ifdef USE_XIM |
210 | im_destroy (); |
220 | im_destroy (); |
211 | #endif |
221 | #endif |
212 | #ifdef MENUBAR |
222 | #ifdef MENUBAR |
213 | if (menubarGC) XFreeGC (display->display, menubarGC); |
223 | if (menubarGC) XFreeGC (disp, menubarGC); |
214 | #endif |
224 | #endif |
215 | #ifdef XTERM_SCROLLBAR |
225 | #ifdef XTERM_SCROLLBAR |
216 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
226 | if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); |
217 | if (ShadowGC) XFreeGC (display->display, ShadowGC); |
227 | if (ShadowGC) XFreeGC (disp, ShadowGC); |
218 | #endif |
228 | #endif |
219 | #ifdef PLAIN_SCROLLBAR |
229 | #ifdef PLAIN_SCROLLBAR |
220 | if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); |
230 | if (pscrollbarGC) XFreeGC (disp, pscrollbarGC); |
221 | #endif |
231 | #endif |
222 | #ifdef NEXT_SCROLLBAR |
232 | #ifdef NEXT_SCROLLBAR |
223 | if (blackGC) XFreeGC (display->display, blackGC); |
233 | if (blackGC) XFreeGC (disp, blackGC); |
224 | if (whiteGC) XFreeGC (display->display, whiteGC); |
234 | if (whiteGC) XFreeGC (disp, whiteGC); |
225 | if (grayGC) XFreeGC (display->display, grayGC); |
235 | if (grayGC) XFreeGC (disp, grayGC); |
226 | if (darkGC) XFreeGC (display->display, darkGC); |
236 | if (darkGC) XFreeGC (disp, darkGC); |
227 | if (stippleGC) XFreeGC (display->display, stippleGC); |
237 | if (stippleGC) XFreeGC (disp, stippleGC); |
228 | if (dimple) XFreePixmap (display->display, dimple); |
238 | if (dimple) XFreePixmap (disp, dimple); |
229 | if (upArrow) XFreePixmap (display->display, upArrow); |
239 | if (upArrow) XFreePixmap (disp, upArrow); |
230 | if (downArrow) XFreePixmap (display->display, downArrow); |
240 | if (downArrow) XFreePixmap (disp, downArrow); |
231 | if (upArrowHi) XFreePixmap (display->display, upArrowHi); |
241 | if (upArrowHi) XFreePixmap (disp, upArrowHi); |
232 | if (downArrowHi) XFreePixmap (display->display, downArrowHi); |
242 | if (downArrowHi) XFreePixmap (disp, downArrowHi); |
233 | #endif |
243 | #endif |
234 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
244 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
235 | if (topShadowGC) XFreeGC (display->display, topShadowGC); |
245 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
236 | if (botShadowGC) XFreeGC (display->display, botShadowGC); |
246 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
237 | if (scrollbarGC) XFreeGC (display->display, scrollbarGC); |
247 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
238 | #endif |
248 | #endif |
239 | if (TermWin.gc) XFreeGC (display->display, TermWin.gc); |
249 | if (TermWin.gc) XFreeGC (disp, TermWin.gc); |
240 | |
250 | |
241 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
251 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
242 | delete menuBar.drawable; |
252 | delete menuBar.drawable; |
243 | //if (menuBar.win) |
253 | //if (menuBar.win) |
244 | // XDestroyWindow (display->display, menuBar.win); |
254 | // XDestroyWindow (disp, menuBar.win); |
245 | #endif |
255 | #endif |
246 | delete TermWin.drawable; |
256 | delete TermWin.drawable; |
247 | // destroy all windows |
257 | // destroy all windows |
248 | if (TermWin.parent[0]) |
258 | if (TermWin.parent[0]) |
249 | XDestroyWindow (display->display, TermWin.parent[0]); |
259 | XDestroyWindow (disp, TermWin.parent[0]); |
250 | } |
260 | } |
251 | |
261 | |
252 | // TODO: free pixcolours, colours should become part of rxvt_display |
262 | // TODO: free pixcolours, colours should become part of rxvt_display |
253 | |
263 | |
254 | delete pix_colors_focused; |
264 | delete pix_colors_focused; |
… | |
… | |
260 | |
270 | |
261 | scr_release (); |
271 | scr_release (); |
262 | |
272 | |
263 | /* clear all resources */ |
273 | /* clear all resources */ |
264 | for (int i = 0; i < allocated.size (); i++) |
274 | for (int i = 0; i < allocated.size (); i++) |
265 | free (allocated[i]); |
275 | free (allocated [i]); |
266 | |
276 | |
267 | free (selection.text); |
277 | free (selection.text); |
268 | // TODO: manage env vars in child only(!) |
278 | // TODO: manage env vars in child only(!) |
269 | free (env_windowid); |
279 | free (env_windowid); |
270 | free (env_display); |
280 | free (env_display); |
… | |
… | |
276 | |
286 | |
277 | delete envv; |
287 | delete envv; |
278 | delete argv; |
288 | delete argv; |
279 | |
289 | |
280 | #ifdef KEYSYM_RESOURCE |
290 | #ifdef KEYSYM_RESOURCE |
281 | delete keyboard; |
291 | delete keyboard; |
282 | #endif |
292 | #endif |
283 | } |
293 | } |
284 | |
294 | |
285 | void |
295 | void |
286 | rxvt_term::destroy () |
296 | rxvt_term::destroy () |
… | |
… | |
339 | |
349 | |
340 | delete this; |
350 | delete this; |
341 | } |
351 | } |
342 | |
352 | |
343 | /*----------------------------------------------------------------------*/ |
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 | int |
|
|
368 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
|
|
369 | { |
|
|
370 | if (GET_R->allowedxerror == -1) |
|
|
371 | GET_R->allowedxerror = event->error_code; |
|
|
372 | else |
|
|
373 | { |
|
|
374 | //TODO: GET_R is most likely not the terminal which caused the error |
|
|
375 | //TODO: maybe just output the error and continue? |
|
|
376 | old_xerror_handler (display, event); |
|
|
377 | GET_R->destroy (); |
|
|
378 | } |
|
|
379 | |
|
|
380 | return 0; |
|
|
381 | } |
|
|
382 | |
|
|
383 | int |
|
|
384 | rxvt_xioerror_handler (Display *display) |
|
|
385 | { |
|
|
386 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
|
|
387 | DisplayString (display)); |
|
|
388 | rxvt_emergency_cleanup (); |
|
|
389 | _exit (EXIT_FAILURE); |
|
|
390 | } |
|
|
391 | |
|
|
392 | /* |
|
|
393 | * Catch a fatal signal and tidy up before quitting |
|
|
394 | */ |
|
|
395 | void |
|
|
396 | rxvt_term::sig_term (sig_watcher &w) |
|
|
397 | { |
|
|
398 | #ifdef DEBUG_CMD |
|
|
399 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
400 | #endif |
|
|
401 | rxvt_emergency_cleanup (); |
|
|
402 | signal (w.signum, SIG_DFL); |
|
|
403 | kill (getpid (), w.signum); |
|
|
404 | } |
|
|
405 | |
|
|
406 | /*----------------------------------------------------------------------*/ |
344 | /* rxvt_init () */ |
407 | /* rxvt_init () */ |
345 | bool |
408 | bool |
346 | rxvt_term::init (int argc, const char *const *argv) |
409 | rxvt_term::init (int argc, const char *const *argv) |
347 | { |
410 | { |
348 | SET_R (this); |
411 | SET_R (this); |
… | |
… | |
368 | scrollBar.setIdle (); /* set existence for size calculations */ |
431 | scrollBar.setIdle (); /* set existence for size calculations */ |
369 | #endif |
432 | #endif |
370 | |
433 | |
371 | create_windows (argc, argv); |
434 | create_windows (argc, argv); |
372 | |
435 | |
|
|
436 | dDisp; |
|
|
437 | |
373 | init_xlocale (); |
438 | init_xlocale (); |
374 | |
439 | |
375 | scr_reset (); /* initialize screen */ |
440 | scr_reset (); /* initialize screen */ |
376 | |
441 | |
377 | #if 0 |
442 | #if 0 |
378 | XSynchronize (display->display, True); |
443 | XSynchronize (disp, True); |
379 | #endif |
444 | #endif |
380 | |
445 | |
381 | #ifdef HAVE_SCROLLBARS |
446 | #ifdef HAVE_SCROLLBARS |
382 | if (options & Opt_scrollBar) |
447 | if (options & Opt_scrollBar) |
383 | resize_scrollbar (); /* create and map scrollbar */ |
448 | resize_scrollbar (); /* create and map scrollbar */ |
384 | #endif |
449 | #endif |
385 | #if (MENUBAR_MAX) |
450 | #if (MENUBAR_MAX) |
386 | if (menubar_visible ()) |
451 | if (menubar_visible ()) |
387 | XMapWindow (display->display, menuBar.win); |
452 | XMapWindow (disp, menuBar.win); |
388 | #endif |
453 | #endif |
389 | #ifdef TRANSPARENT |
454 | #ifdef TRANSPARENT |
390 | if (options & Opt_transparent) |
455 | if (options & Opt_transparent) |
391 | { |
456 | { |
392 | XSelectInput (display->display, display->root, PropertyChangeMask); |
457 | XSelectInput (disp, display->root, PropertyChangeMask); |
393 | check_our_parents (); |
458 | check_our_parents (); |
394 | rootwin_ev.start (display, display->root); |
459 | rootwin_ev.start (display, display->root); |
395 | } |
460 | } |
396 | #endif |
461 | #endif |
397 | |
462 | |
398 | XMapWindow (display->display, TermWin.vt); |
463 | XMapWindow (disp, TermWin.vt); |
399 | XMapWindow (display->display, TermWin.parent[0]); |
464 | XMapWindow (disp, TermWin.parent[0]); |
400 | |
465 | |
401 | set_colorfgbg (); |
466 | set_colorfgbg (); |
402 | |
467 | |
403 | init_command (cmd_argv); |
468 | init_command (cmd_argv); |
404 | |
469 | |
… | |
… | |
408 | |
473 | |
409 | check_ev.start (); |
474 | check_ev.start (); |
410 | |
475 | |
411 | return true; |
476 | return true; |
412 | } |
477 | } |
413 | |
|
|
414 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
415 | |
478 | |
416 | void |
479 | void |
417 | rxvt_init () |
480 | rxvt_init () |
418 | { |
481 | { |
419 | /* |
482 | /* |
… | |
… | |
432 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
495 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
433 | /* signal (SIGURG, SIG_DFL); */ |
496 | /* signal (SIGURG, SIG_DFL); */ |
434 | |
497 | |
435 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
498 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
436 | // TODO: handle this with exceptions and tolerate the memory loss |
499 | // TODO: handle this with exceptions and tolerate the memory loss |
437 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
500 | XSetIOErrorHandler (rxvt_xioerror_handler); |
438 | } |
501 | } |
439 | |
502 | |
440 | /* ------------------------------------------------------------------------- * |
503 | /* ------------------------------------------------------------------------- * |
441 | * SIGNAL HANDLING & EXIT HANDLER * |
504 | * SIGNAL HANDLING & EXIT HANDLER * |
442 | * ------------------------------------------------------------------------- */ |
505 | * ------------------------------------------------------------------------- */ |
… | |
… | |
455 | if (pid == (*t)->cmd_pid) |
518 | if (pid == (*t)->cmd_pid) |
456 | { |
519 | { |
457 | (*t)->destroy (); |
520 | (*t)->destroy (); |
458 | break; |
521 | break; |
459 | } |
522 | } |
460 | } |
|
|
461 | |
|
|
462 | /*----------------------------------------------------------------------*/ |
|
|
463 | /* |
|
|
464 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
|
|
465 | * TODO: if debugging, this should free up any known resources if we can |
|
|
466 | */ |
|
|
467 | void |
|
|
468 | rxvt_destroy_all () |
|
|
469 | { |
|
|
470 | // TODO: rxvtd should clean up all ressources |
|
|
471 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
472 | (*t)->destroy (); |
|
|
473 | } |
|
|
474 | |
|
|
475 | /* |
|
|
476 | * Catch a fatal signal and tidy up before quitting |
|
|
477 | */ |
|
|
478 | void |
|
|
479 | rxvt_term::sig_term (sig_watcher &w) |
|
|
480 | { |
|
|
481 | #ifdef DEBUG_CMD |
|
|
482 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
483 | #endif |
|
|
484 | rxvt_destroy_all (); |
|
|
485 | signal (w.signum, SIG_DFL); |
|
|
486 | kill (getpid (), w.signum); |
|
|
487 | } |
|
|
488 | |
|
|
489 | /* INTPROTO */ |
|
|
490 | int |
|
|
491 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
|
|
492 | { |
|
|
493 | if (GET_R->allowedxerror == -1) |
|
|
494 | GET_R->allowedxerror = event->error_code; |
|
|
495 | else |
|
|
496 | { |
|
|
497 | old_xerror_handler (display, event); |
|
|
498 | GET_R->destroy (); |
|
|
499 | } |
|
|
500 | |
|
|
501 | return 0; |
|
|
502 | } |
523 | } |
503 | |
524 | |
504 | /* ------------------------------------------------------------------------- * |
525 | /* ------------------------------------------------------------------------- * |
505 | * MEMORY ALLOCATION WRAPPERS * |
526 | * MEMORY ALLOCATION WRAPPERS * |
506 | * ------------------------------------------------------------------------- */ |
527 | * ------------------------------------------------------------------------- */ |
… | |
… | |
619 | * if width/height are non-zero then override calculated width/height |
640 | * if width/height are non-zero then override calculated width/height |
620 | */ |
641 | */ |
621 | void |
642 | void |
622 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
643 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
623 | { |
644 | { |
624 | short recalc_x, recalc_y; |
645 | short recalc_x, recalc_y; |
625 | int x, y, sb_w, mb_h, flags; |
646 | int x, y, sb_w, mb_h, flags; |
626 | unsigned int w, h; |
647 | unsigned int w, h; |
627 | unsigned int max_width, max_height; |
648 | unsigned int max_width, max_height; |
|
|
649 | dDisp; |
628 | |
650 | |
629 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
651 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
630 | TermWin.ncol, TermWin.nrow, szHint.width, |
652 | TermWin.ncol, TermWin.nrow, szHint.width, |
631 | szHint.height)); |
653 | szHint.height)); |
632 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
654 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
… | |
… | |
730 | |
752 | |
731 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
753 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
732 | window_sb_x = szHint.width - sb_w; |
754 | window_sb_x = szHint.width - sb_w; |
733 | |
755 | |
734 | if (recalc_x) |
756 | if (recalc_x) |
735 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
757 | szHint.x += (DisplayWidth (disp, display->screen) |
736 | - szHint.width - 2 * TermWin.ext_bwidth); |
758 | - szHint.width - 2 * TermWin.ext_bwidth); |
737 | if (recalc_y) |
759 | if (recalc_y) |
738 | szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) |
760 | szHint.y += (DisplayHeight (disp, display->screen) |
739 | - szHint.height - 2 * TermWin.ext_bwidth); |
761 | - szHint.height - 2 * TermWin.ext_bwidth); |
740 | |
762 | |
741 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
763 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
742 | TermWin.nrow = TermWin.height / TermWin.fheight; |
764 | TermWin.nrow = TermWin.height / TermWin.fheight; |
743 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
765 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
… | |
… | |
908 | |
930 | |
909 | /* handle color aliases */ |
931 | /* handle color aliases */ |
910 | if (isdigit (*color)) |
932 | if (isdigit (*color)) |
911 | { |
933 | { |
912 | i = atoi (color); |
934 | i = atoi (color); |
|
|
935 | |
913 | if (i >= 8 && i <= 15) |
936 | if (i >= 8 && i <= 15) |
914 | { /* bright colors */ |
937 | { /* bright colors */ |
915 | i -= 8; |
938 | i -= 8; |
916 | # ifndef NO_BRIGHTCOLOR |
939 | # ifndef NO_BRIGHTCOLOR |
917 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
940 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
918 | SET_PIXCOLOR (idx); |
941 | SET_PIXCOLOR (idx); |
919 | goto Done; |
942 | goto Done; |
920 | # endif |
943 | # endif |
921 | |
|
|
922 | } |
944 | } |
|
|
945 | |
923 | if (i >= 0 && i <= 7) |
946 | if (i >= 0 && i <= 7) |
924 | { /* normal colors */ |
947 | { /* normal colors */ |
925 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
948 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
926 | SET_PIXCOLOR (idx); |
949 | SET_PIXCOLOR (idx); |
927 | goto Done; |
950 | goto Done; |
928 | } |
951 | } |
929 | } |
952 | } |
930 | |
953 | |
931 | if (!rXParseAllocColor (& xcol, color)) |
954 | if (!rXParseAllocColor (&xcol, color)) |
932 | return; |
955 | return; |
933 | |
956 | |
934 | /* XStoreColor (display->display, display->cmap, XColor*); */ |
957 | /* XStoreColor (display->display, display->cmap, XColor*); */ |
935 | |
958 | |
936 | /* |
959 | /* |
… | |
… | |
1039 | * -------------------------------------------------------------------- */ |
1062 | * -------------------------------------------------------------------- */ |
1040 | void |
1063 | void |
1041 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1064 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1042 | { |
1065 | { |
1043 | int fix_screen; |
1066 | int fix_screen; |
1044 | |
|
|
1045 | #ifdef SMART_RESIZE |
1067 | #ifdef SMART_RESIZE |
1046 | int old_width = szHint.width, old_height = szHint.height; |
1068 | int old_width = szHint.width, old_height = szHint.height; |
1047 | #endif |
1069 | #endif |
|
|
1070 | dDisp; |
1048 | |
1071 | |
1049 | window_calc (width, height); |
1072 | window_calc (width, height); |
1050 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1073 | XSetWMNormalHints (disp, TermWin.parent[0], &szHint); |
1051 | |
1074 | |
1052 | if (!ignoreparent) |
1075 | if (!ignoreparent) |
1053 | { |
1076 | { |
1054 | #ifdef SMART_RESIZE |
1077 | #ifdef SMART_RESIZE |
1055 | /* |
1078 | /* |
… | |
… | |
1059 | int x, y, x1, y1; |
1082 | int x, y, x1, y1; |
1060 | int dx, dy; |
1083 | int dx, dy; |
1061 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1084 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1062 | Window unused_cr; |
1085 | Window unused_cr; |
1063 | |
1086 | |
1064 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1087 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
1065 | 0, 0, &x, &y, &unused_cr); |
1088 | 0, 0, &x, &y, &unused_cr); |
1066 | XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, |
1089 | XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1, |
1067 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1090 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1068 | /* |
1091 | /* |
1069 | * if display->root isn't the parent window, a WM will probably have offset |
1092 | * if display->root isn't the parent window, a WM will probably have offset |
1070 | * our position for handles and decorations. Counter it |
1093 | * our position for handles and decorations. Counter it |
1071 | */ |
1094 | */ |
… | |
… | |
1073 | { |
1096 | { |
1074 | x -= x1; |
1097 | x -= x1; |
1075 | y -= y1; |
1098 | y -= y1; |
1076 | } |
1099 | } |
1077 | |
1100 | |
1078 | x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; |
1101 | x1 = (DisplayWidth (disp, display->screen) - old_width) / 2; |
1079 | y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; |
1102 | y1 = (DisplayHeight (disp, display->screen) - old_height) / 2; |
1080 | dx = old_width - szHint.width; |
1103 | dx = old_width - szHint.width; |
1081 | dy = old_height - szHint.height; |
1104 | dy = old_height - szHint.height; |
1082 | |
1105 | |
1083 | /* Check position of the center of the window */ |
1106 | /* Check position of the center of the window */ |
1084 | if (x < x1) /* left half */ |
1107 | if (x < x1) /* left half */ |
… | |
… | |
1088 | if (y < y1) /* top half */ |
1111 | if (y < y1) /* top half */ |
1089 | dy = 0; |
1112 | dy = 0; |
1090 | else if (y == y1) /* exact center */ |
1113 | else if (y == y1) /* exact center */ |
1091 | dy /= 2; |
1114 | dy /= 2; |
1092 | |
1115 | |
1093 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1116 | XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy, |
1094 | szHint.width, szHint.height); |
1117 | szHint.width, szHint.height); |
1095 | #else |
1118 | #else |
1096 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
1119 | XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height); |
1097 | #endif |
1120 | #endif |
1098 | } |
1121 | } |
1099 | |
1122 | |
1100 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1123 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1101 | |
1124 | |
1102 | if (fix_screen || width != old_width || height != old_height) |
1125 | if (fix_screen || width != old_width || height != old_height) |
1103 | { |
1126 | { |
1104 | if (scrollbar_visible ()) |
1127 | if (scrollbar_visible ()) |
1105 | { |
1128 | { |
1106 | XMoveResizeWindow (display->display, scrollBar.win, |
1129 | XMoveResizeWindow (disp, scrollBar.win, |
1107 | window_sb_x, 0, |
1130 | window_sb_x, 0, |
1108 | scrollbar_TotalWidth (), szHint.height); |
1131 | scrollbar_TotalWidth (), szHint.height); |
1109 | resize_scrollbar (); |
1132 | resize_scrollbar (); |
1110 | } |
1133 | } |
1111 | |
1134 | |
1112 | if (menubar_visible ()) |
1135 | if (menubar_visible ()) |
1113 | XMoveResizeWindow (display->display, menuBar.win, |
1136 | XMoveResizeWindow (disp, menuBar.win, |
1114 | window_vt_x, 0, |
1137 | window_vt_x, 0, |
1115 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1138 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1116 | |
1139 | |
1117 | XMoveResizeWindow (display->display, TermWin.vt, |
1140 | XMoveResizeWindow (disp, TermWin.vt, |
1118 | window_vt_x, window_vt_y, |
1141 | window_vt_x, window_vt_y, |
1119 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1142 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
|
|
1143 | |
1120 | scr_clear (); |
1144 | scr_clear (); |
1121 | #ifdef XPM_BACKGROUND |
1145 | #ifdef XPM_BACKGROUND |
1122 | resize_pixmap (); |
1146 | resize_pixmap (); |
1123 | #endif |
1147 | #endif |
1124 | } |
1148 | } |
… | |
… | |
1146 | } |
1170 | } |
1147 | } |
1171 | } |
1148 | |
1172 | |
1149 | old_width = szHint.width; |
1173 | old_width = szHint.width; |
1150 | old_height = szHint.height; |
1174 | old_height = szHint.height; |
|
|
1175 | |
|
|
1176 | #ifdef XPM_BACKGROUND |
|
|
1177 | if (TermWin.pixmap) |
|
|
1178 | scr_touch (false); |
|
|
1179 | #endif |
1151 | |
1180 | |
1152 | #ifdef USE_XIM |
1181 | #ifdef USE_XIM |
1153 | IMSetStatusPosition (); |
1182 | IMSetStatusPosition (); |
1154 | #endif |
1183 | #endif |
1155 | } |
1184 | } |
… | |
… | |
1385 | "*", |
1414 | "*", |
1386 | TermWin.fheight, |
1415 | TermWin.fheight, |
1387 | TermWin.fheight + 1, TermWin.fheight - 1, |
1416 | TermWin.fheight + 1, TermWin.fheight - 1, |
1388 | TermWin.fheight - 2, TermWin.fheight + 2); |
1417 | TermWin.fheight - 2, TermWin.fheight + 2); |
1389 | |
1418 | |
1390 | fs = XCreateFontSet (display->display, pat, |
1419 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1391 | &missing_charset_list, &missing_charset_count, &def_string); |
1420 | &missing_charset_list, &missing_charset_count, &def_string); |
1392 | |
1421 | |
1393 | if (missing_charset_list) |
1422 | if (missing_charset_list) |
1394 | XFreeStringList (missing_charset_list); |
1423 | XFreeStringList (missing_charset_list); |
1395 | |
1424 | |