… | |
… | |
15 | * - extensive modifications |
15 | * - extensive modifications |
16 | * Copyright (c) 2003-2010 Marc Lehmann <schmorp@schmorp.de> |
16 | * Copyright (c) 2003-2010 Marc Lehmann <schmorp@schmorp.de> |
17 | * |
17 | * |
18 | * This program is free software; you can redistribute it and/or modify |
18 | * This program is free software; you can redistribute it and/or modify |
19 | * it under the terms of the GNU General Public License as published by |
19 | * it under the terms of the GNU General Public License as published by |
20 | * the Free Software Foundation; either version 2 of the License, or |
20 | * the Free Software Foundation; either version 3 of the License, or |
21 | * (at your option) any later version. |
21 | * (at your option) any later version. |
22 | * |
22 | * |
23 | * This program is distributed in the hope that it will be useful, |
23 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
168 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
168 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
169 | #endif |
169 | #endif |
170 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
170 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
171 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
171 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
172 | #endif |
172 | #endif |
173 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
173 | #if BG_IMAGE_FROM_ROOT || ENABLE_PERL |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
175 | #endif |
175 | #endif |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
177 | #if USE_XIM |
177 | #if USE_XIM |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
… | |
… | |
226 | |
226 | |
227 | #ifdef HAVE_BG_PIXMAP |
227 | #ifdef HAVE_BG_PIXMAP |
228 | bg_destroy (); |
228 | bg_destroy (); |
229 | #endif |
229 | #endif |
230 | |
230 | |
|
|
231 | #if HAVE_IMG |
|
|
232 | delete bg_img; |
|
|
233 | #endif |
|
|
234 | |
231 | if (display) |
235 | if (display) |
232 | { |
236 | { |
233 | selection_clear (); |
237 | selection_clear (); |
234 | selection_clear (true); |
238 | selection_clear (true); |
235 | |
239 | |
236 | #if USE_XIM |
240 | #if USE_XIM |
237 | im_destroy (); |
241 | im_destroy (); |
238 | #endif |
242 | #endif |
239 | scrollBar.destroy (); |
243 | scrollBar.destroy (); |
|
|
244 | |
|
|
245 | if (gc) |
240 | if (gc) XFreeGC (dpy, gc); |
246 | XFreeGC (dpy, gc); |
241 | |
247 | |
242 | delete drawable; |
248 | delete drawable; |
|
|
249 | |
243 | // destroy all windows |
250 | // destroy all windows |
244 | if (parent) |
251 | if (parent) |
245 | XDestroyWindow (dpy, parent); |
252 | XDestroyWindow (dpy, parent); |
246 | |
253 | |
247 | for (int i = 0; i < TOTAL_COLORS; i++) |
254 | for (int i = 0; i < TOTAL_COLORS; i++) |
… | |
… | |
311 | { |
318 | { |
312 | #if USE_XIM |
319 | #if USE_XIM |
313 | im_ev.stop (display); |
320 | im_ev.stop (display); |
314 | #endif |
321 | #endif |
315 | scrollbar_ev.stop (display); |
322 | scrollbar_ev.stop (display); |
316 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
323 | #if BG_IMAGE_FROM_ROOT || ENABLE_PERL |
317 | rootwin_ev.stop (display); |
324 | rootwin_ev.stop (display); |
318 | #endif |
325 | #endif |
319 | termwin_ev.stop (display); |
326 | termwin_ev.stop (display); |
320 | vt_ev.stop (display); |
327 | vt_ev.stop (display); |
321 | } |
328 | } |
… | |
… | |
362 | } |
369 | } |
363 | |
370 | |
364 | /*----------------------------------------------------------------------*/ |
371 | /*----------------------------------------------------------------------*/ |
365 | /* |
372 | /* |
366 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
373 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
367 | * TODO: if debugging, this should free up any known resources if we can |
|
|
368 | */ |
374 | */ |
369 | static XErrorHandler old_xerror_handler; |
375 | static XErrorHandler old_xerror_handler; |
370 | |
376 | |
371 | static void |
377 | static void |
372 | rxvt_emergency_cleanup () |
378 | rxvt_emergency_cleanup () |
… | |
… | |
380 | print_x_error (Display *dpy, XErrorEvent *event) |
386 | print_x_error (Display *dpy, XErrorEvent *event) |
381 | { |
387 | { |
382 | char buffer[BUFSIZ]; |
388 | char buffer[BUFSIZ]; |
383 | char mesg[BUFSIZ]; |
389 | char mesg[BUFSIZ]; |
384 | char number[32]; |
390 | char number[32]; |
385 | const char mtype[] = "XlibMessage"; |
391 | |
|
|
392 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
|
|
393 | |
|
|
394 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
|
|
395 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
386 | |
396 | |
387 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
397 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
388 | XGetErrorDatabaseText (dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
398 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
389 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
|
|
390 | rxvt_warn ("%s: %s\n", mesg, buffer); |
399 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
|
|
400 | |
391 | XGetErrorDatabaseText (dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
401 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
392 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
402 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
393 | sprintf (number, "%d", event->request_code); |
|
|
394 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
|
|
395 | rxvt_warn ("(which is %s)\n", buffer); |
|
|
396 | |
403 | |
397 | if (event->request_code >= 128) |
404 | if (event->request_code >= 128) |
398 | { |
405 | { |
|
|
406 | #if 0 |
|
|
407 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
|
|
408 | int nexts; |
|
|
409 | char **exts = XListExtensions (dpy, &nexts); |
|
|
410 | |
|
|
411 | while (nexts) |
|
|
412 | { |
|
|
413 | char *extname = exts [nexts - 1]; |
|
|
414 | int major, first_event, first_error; |
|
|
415 | |
|
|
416 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
|
|
417 | { |
|
|
418 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
|
|
419 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
|
|
420 | |
|
|
421 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
|
|
422 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
|
|
423 | rxvt_warn ("+ (which is %s)\n", buffer); |
|
|
424 | |
|
|
425 | break; |
|
|
426 | } |
|
|
427 | |
|
|
428 | printf ("nextss %d %s\n", nexts, extname);//D |
|
|
429 | --nexts; |
|
|
430 | ++exts; |
|
|
431 | } |
|
|
432 | #else |
|
|
433 | int nexts = 0; |
|
|
434 | char **exts = 0; |
|
|
435 | #endif |
|
|
436 | |
|
|
437 | if (!nexts) |
|
|
438 | { |
|
|
439 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
|
|
440 | |
399 | XGetErrorDatabaseText (dpy, mtype, "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
441 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
400 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
442 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
|
|
443 | |
|
|
444 | #if 0 |
|
|
445 | sprintf (number, "RENDER.%d", event->minor_code); |
|
|
446 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
|
|
447 | rxvt_warn ("+ (which is %s)\n", buffer); |
|
|
448 | #endif |
|
|
449 | } |
|
|
450 | |
|
|
451 | XFreeExtensionList (exts); |
|
|
452 | } |
|
|
453 | else |
|
|
454 | { |
|
|
455 | sprintf (number, "%d", event->request_code); |
|
|
456 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
|
|
457 | rxvt_warn ("+ (which is %s)\n", buffer); |
401 | } |
458 | } |
402 | |
459 | |
403 | if (event->error_code == BadWindow |
460 | if (event->error_code == BadWindow |
404 | || event->error_code == BadPixmap |
461 | || event->error_code == BadPixmap |
405 | || event->error_code == BadCursor |
462 | || event->error_code == BadCursor |
… | |
… | |
410 | || event->error_code == BadIDChoice |
467 | || event->error_code == BadIDChoice |
411 | || event->error_code == BadValue |
468 | || event->error_code == BadValue |
412 | || event->error_code == BadAtom) |
469 | || event->error_code == BadAtom) |
413 | { |
470 | { |
414 | if (event->error_code == BadValue) |
471 | if (event->error_code == BadValue) |
415 | XGetErrorDatabaseText (dpy, mtype, "Value", "Value 0x%x", mesg, BUFSIZ); |
472 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
416 | else if (event->error_code == BadAtom) |
473 | else if (event->error_code == BadAtom) |
417 | XGetErrorDatabaseText (dpy, mtype, "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
474 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
418 | else |
475 | else |
419 | XGetErrorDatabaseText (dpy, mtype, "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
476 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
420 | |
477 | |
421 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
478 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
422 | } |
479 | } |
423 | |
|
|
424 | XGetErrorDatabaseText (dpy, mtype, "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
|
|
425 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
|
|
426 | } |
480 | } |
427 | #endif |
481 | #endif |
428 | |
482 | |
429 | int ecb_cold |
483 | int ecb_cold |
430 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
484 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
… | |
… | |
770 | |
824 | |
771 | delete fontset[0]; |
825 | delete fontset[0]; |
772 | fontset[0] = fs; |
826 | fontset[0] = fs; |
773 | |
827 | |
774 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
828 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
775 | prop.width += letterSpace; |
829 | prop.width = max (prop.width + letterSpace, 1); |
776 | |
830 | |
777 | fs->set_prop (prop, false); |
831 | fs->set_prop (prop, false); |
778 | |
832 | |
779 | fwidth = prop.width; |
833 | fwidth = prop.width; |
780 | fheight = prop.height + lineSpace; |
834 | fheight = prop.height + lineSpace; |
… | |
… | |
1318 | char **s; |
1372 | char **s; |
1319 | XIMStyles *xim_styles; |
1373 | XIMStyles *xim_styles; |
1320 | |
1374 | |
1321 | set_environ (envv); |
1375 | set_environ (envv); |
1322 | |
1376 | |
1323 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1377 | if (!((p = XSetLocaleModifiers (modifiers)) && *p)) |
1324 | return false; |
1378 | return false; |
1325 | |
1379 | |
1326 | input_method = display->get_xim (locale, modifiers); |
1380 | input_method = display->get_xim (locale, modifiers); |
1327 | if (input_method == NULL) |
1381 | if (input_method == NULL) |
1328 | return false; |
1382 | return false; |
… | |
… | |
1636 | rxvt_term::update_background () |
1690 | rxvt_term::update_background () |
1637 | { |
1691 | { |
1638 | if (update_background_ev.is_active ()) |
1692 | if (update_background_ev.is_active ()) |
1639 | return; |
1693 | return; |
1640 | |
1694 | |
1641 | bg_invalidate (); |
|
|
1642 | |
|
|
1643 | if (!mapped) |
|
|
1644 | return; |
|
|
1645 | |
|
|
1646 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
1695 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
1647 | |
1696 | |
1648 | if (to_wait <= 0.) |
1697 | if (to_wait <= 0.) |
1649 | bg_render (); |
1698 | bg_render (); |
1650 | else |
1699 | else |