… | |
… | |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
12 | * - extensive modifications |
12 | * - extensive modifications |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
15 | * - extensive modifications |
15 | * - extensive modifications |
16 | * Copyright (c) 2003-2010 Marc Lehmann <schmorp@schmorp.de> |
16 | * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de> |
|
|
17 | * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
17 | * |
18 | * |
18 | * This program is free software; you can redistribute it and/or modify |
19 | * 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 |
20 | * 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 |
21 | * the Free Software Foundation; either version 3 of the License, or |
21 | * (at your option) any later version. |
22 | * (at your option) any later version. |
22 | * |
23 | * |
23 | * This program is distributed in the hope that it will be useful, |
24 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
150 | } |
151 | } |
151 | #endif |
152 | #endif |
152 | |
153 | |
153 | rxvt_term::rxvt_term () |
154 | rxvt_term::rxvt_term () |
154 | { |
155 | { |
155 | #if HAVE_BG_PIXMAP |
|
|
156 | update_background_ev.set<rxvt_term, &rxvt_term::update_background_cb> (this); |
|
|
157 | #endif |
|
|
158 | #ifdef CURSOR_BLINK |
156 | #ifdef CURSOR_BLINK |
159 | cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); |
157 | cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); |
160 | #endif |
158 | #endif |
161 | #ifdef TEXT_BLINK |
159 | #ifdef TEXT_BLINK |
162 | text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); |
160 | text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); |
… | |
… | |
168 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
166 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
169 | #endif |
167 | #endif |
170 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
168 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
171 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
169 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
172 | #endif |
170 | #endif |
173 | #if BG_IMAGE_FROM_ROOT || ENABLE_PERL |
171 | #if ENABLE_PERL |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
172 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
175 | #endif |
173 | #endif |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
174 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
177 | #if USE_XIM |
175 | #if USE_XIM |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
176 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
… | |
… | |
222 | if (fontset[i] != fontset[0]) |
220 | if (fontset[i] != fontset[0]) |
223 | delete fontset[i]; |
221 | delete fontset[i]; |
224 | #endif |
222 | #endif |
225 | delete fontset[0]; |
223 | delete fontset[0]; |
226 | |
224 | |
227 | #ifdef HAVE_BG_PIXMAP |
225 | #if HAVE_IMG |
228 | bg_destroy (); |
226 | delete bg_img; |
229 | #endif |
227 | #endif |
230 | |
228 | |
231 | if (display) |
229 | if (display) |
232 | { |
230 | { |
233 | selection_clear (); |
231 | selection_clear (); |
… | |
… | |
235 | |
233 | |
236 | #if USE_XIM |
234 | #if USE_XIM |
237 | im_destroy (); |
235 | im_destroy (); |
238 | #endif |
236 | #endif |
239 | scrollBar.destroy (); |
237 | scrollBar.destroy (); |
|
|
238 | |
|
|
239 | if (gc) |
240 | if (gc) XFreeGC (dpy, gc); |
240 | XFreeGC (dpy, gc); |
241 | |
241 | |
242 | delete drawable; |
242 | delete drawable; |
|
|
243 | |
243 | // destroy all windows |
244 | // destroy all windows |
244 | if (parent) |
245 | if (parent) |
245 | XDestroyWindow (dpy, parent); |
246 | XDestroyWindow (dpy, parent); |
246 | |
247 | |
247 | for (int i = 0; i < TOTAL_COLORS; i++) |
248 | for (int i = 0; i < TOTAL_COLORS; i++) |
248 | if (ISSET_PIXCOLOR (i)) |
249 | if (ISSET_PIXCOLOR (i)) |
249 | { |
250 | { |
250 | pix_colors_focused [i].free (this); |
251 | pix_colors_focused [i].free (this); |
251 | #if OFF_FOCUS_FADING |
252 | #if OFF_FOCUS_FADING |
|
|
253 | if (rs[Rs_fade]) |
252 | pix_colors_unfocused [i].free (this); |
254 | pix_colors_unfocused [i].free (this); |
253 | #endif |
255 | #endif |
254 | } |
256 | } |
255 | |
257 | |
256 | clear (); |
258 | clear (); |
257 | |
259 | |
… | |
… | |
270 | free (locale); |
272 | free (locale); |
271 | free (v_buffer); |
273 | free (v_buffer); |
272 | |
274 | |
273 | delete selection_req; |
275 | delete selection_req; |
274 | |
276 | |
|
|
277 | if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *))) |
|
|
278 | rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n"); |
|
|
279 | |
|
|
280 | delete [] env; |
|
|
281 | |
275 | delete envv; |
282 | delete envv; |
276 | delete argv; |
283 | delete argv; |
277 | |
284 | |
278 | #ifdef KEYSYM_RESOURCE |
285 | #ifdef KEYSYM_RESOURCE |
279 | delete keyboard; |
286 | delete keyboard; |
280 | #endif |
287 | #endif |
281 | #ifndef NO_RESOURCES |
288 | #ifndef NO_RESOURCES |
282 | XrmDestroyDatabase (option_db); |
289 | XrmDestroyDatabase (option_db); |
283 | #endif |
290 | #endif |
|
|
291 | |
|
|
292 | SET_R ((rxvt_term *)0); |
284 | } |
293 | } |
285 | |
294 | |
286 | // child has exited, usually destroys |
295 | // child has exited, usually destroys |
287 | void |
296 | void |
288 | rxvt_term::child_cb (ev::child &w, int status) |
297 | rxvt_term::child_cb (ev::child &w, int status) |
… | |
… | |
311 | { |
320 | { |
312 | #if USE_XIM |
321 | #if USE_XIM |
313 | im_ev.stop (display); |
322 | im_ev.stop (display); |
314 | #endif |
323 | #endif |
315 | scrollbar_ev.stop (display); |
324 | scrollbar_ev.stop (display); |
316 | #if BG_IMAGE_FROM_ROOT || ENABLE_PERL |
325 | #if ENABLE_PERL |
317 | rootwin_ev.stop (display); |
326 | rootwin_ev.stop (display); |
318 | #endif |
327 | #endif |
319 | termwin_ev.stop (display); |
328 | termwin_ev.stop (display); |
320 | vt_ev.stop (display); |
329 | vt_ev.stop (display); |
321 | } |
330 | } |
… | |
… | |
376 | |
385 | |
377 | #if !ENABLE_MINIMAL |
386 | #if !ENABLE_MINIMAL |
378 | static void ecb_cold |
387 | static void ecb_cold |
379 | print_x_error (Display *dpy, XErrorEvent *event) |
388 | print_x_error (Display *dpy, XErrorEvent *event) |
380 | { |
389 | { |
381 | char buffer[BUFSIZ]; |
390 | char buffer[BUFSIZ]; |
382 | char mesg[BUFSIZ]; |
391 | char mesg[BUFSIZ]; |
383 | char number[32]; |
392 | char number[32]; |
384 | |
393 | |
385 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
394 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
386 | |
395 | |
387 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
396 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
388 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
397 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
389 | |
398 | |
390 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
399 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
391 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
400 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
392 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
401 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
393 | |
402 | |
394 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
403 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
395 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
404 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
396 | |
405 | |
397 | if (event->request_code >= 128) |
406 | if (event->request_code >= 128) |
398 | { |
407 | { |
399 | #if 0 |
408 | #if 0 |
400 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
409 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
401 | int nexts; |
410 | int nexts; |
402 | char **exts = XListExtensions (dpy, &nexts); |
411 | char **exts = XListExtensions (dpy, &nexts); |
403 | |
412 | |
404 | while (nexts) |
413 | while (nexts) |
405 | { |
414 | { |
406 | char *extname = exts [nexts - 1]; |
415 | char *extname = exts [nexts - 1]; |
407 | int major, first_event, first_error; |
416 | int major, first_event, first_error; |
408 | |
417 | |
409 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
418 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
410 | { |
419 | { |
411 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
420 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
412 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
421 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
413 | |
422 | |
414 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
423 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
415 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
424 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
416 | rxvt_warn ("+ (which is %s)\n", buffer); |
425 | rxvt_warn ("+ (which is %s)\n", buffer); |
417 | |
426 | |
418 | break; |
427 | break; |
419 | } |
428 | } |
420 | |
429 | |
421 | printf ("nextss %d %s\n", nexts, extname);//D |
430 | printf ("nextss %d %s\n", nexts, extname);//D |
422 | --nexts; |
431 | --nexts; |
423 | ++exts; |
432 | ++exts; |
424 | } |
433 | } |
425 | #else |
434 | #else |
426 | int nexts = 0; |
435 | int nexts = 0; |
427 | char **exts = 0; |
436 | char **exts = 0; |
428 | #endif |
437 | #endif |
429 | |
438 | |
430 | if (!nexts) |
439 | if (!nexts) |
431 | { |
440 | { |
432 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
441 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
433 | |
442 | |
434 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
443 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
435 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
444 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
436 | |
445 | |
437 | #if 0 |
446 | #if 0 |
438 | sprintf (number, "RENDER.%d", event->minor_code); |
447 | sprintf (number, "RENDER.%d", event->minor_code); |
439 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
448 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
440 | rxvt_warn ("+ (which is %s)\n", buffer); |
449 | rxvt_warn ("+ (which is %s)\n", buffer); |
441 | #endif |
450 | #endif |
442 | } |
451 | } |
443 | |
452 | |
444 | XFreeExtensionList (exts); |
453 | XFreeExtensionList (exts); |
445 | } |
454 | } |
446 | else |
455 | else |
447 | { |
456 | { |
448 | sprintf (number, "%d", event->request_code); |
457 | sprintf (number, "%d", event->request_code); |
449 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
458 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
450 | rxvt_warn ("+ (which is %s)\n", buffer); |
459 | rxvt_warn ("+ (which is %s)\n", buffer); |
451 | } |
460 | } |
452 | |
461 | |
453 | if (event->error_code == BadWindow |
462 | if (event->error_code == BadWindow |
454 | || event->error_code == BadPixmap |
463 | || event->error_code == BadPixmap |
455 | || event->error_code == BadCursor |
464 | || event->error_code == BadCursor |
456 | || event->error_code == BadFont |
465 | || event->error_code == BadFont |
457 | || event->error_code == BadDrawable |
466 | || event->error_code == BadDrawable |
458 | || event->error_code == BadColor |
467 | || event->error_code == BadColor |
459 | || event->error_code == BadGC |
468 | || event->error_code == BadGC |
460 | || event->error_code == BadIDChoice |
469 | || event->error_code == BadIDChoice |
461 | || event->error_code == BadValue |
470 | || event->error_code == BadValue |
462 | || event->error_code == BadAtom) |
471 | || event->error_code == BadAtom) |
463 | { |
472 | { |
464 | if (event->error_code == BadValue) |
473 | if (event->error_code == BadValue) |
465 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
474 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
466 | else if (event->error_code == BadAtom) |
475 | else if (event->error_code == BadAtom) |
467 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
476 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
468 | else |
477 | else |
469 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
478 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
470 | |
479 | |
471 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
480 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
472 | } |
481 | } |
473 | } |
482 | } |
474 | #endif |
483 | #endif |
475 | |
484 | |
476 | int ecb_cold |
485 | int ecb_cold |
477 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
486 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
478 | { |
487 | { |
479 | if (GET_R->allowedxerror == -1) |
488 | if (GET_R && GET_R->allowedxerror == -1) |
480 | GET_R->allowedxerror = event->error_code; |
489 | GET_R->allowedxerror = event->error_code; |
481 | else |
490 | else |
482 | { |
491 | { |
483 | // GET_R is most likely not the terminal which caused the error, |
492 | // GET_R is most likely not the terminal which caused the error, |
484 | // so just output the error and continue |
493 | // so just output the error and continue |
… | |
… | |
927 | |
936 | |
928 | void |
937 | void |
929 | rxvt_term::set_window_color (int idx, const char *color) |
938 | rxvt_term::set_window_color (int idx, const char *color) |
930 | { |
939 | { |
931 | #ifdef XTERM_COLOR_CHANGE |
940 | #ifdef XTERM_COLOR_CHANGE |
932 | rxvt_color xcol; |
|
|
933 | |
|
|
934 | if (color == NULL || *color == '\0') |
941 | if (color == NULL || *color == '\0') |
935 | return; |
942 | return; |
936 | |
943 | |
937 | color = strdup (color); |
944 | color = strdup (color); |
938 | allocated.push_back ((void *)color); |
945 | allocated.push_back ((void *)color); |
… | |
… | |
944 | int i = atoi (color); |
951 | int i = atoi (color); |
945 | |
952 | |
946 | if (i >= 8 && i <= 15) |
953 | if (i >= 8 && i <= 15) |
947 | { |
954 | { |
948 | /* bright colors */ |
955 | /* bright colors */ |
949 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
956 | alias_color (idx, minBrightCOLOR + i - 8); |
950 | goto done; |
957 | goto done; |
951 | } |
958 | } |
952 | |
959 | |
953 | if (i >= 0 && i <= 7) |
960 | if (i >= 0 && i <= 7) |
954 | { |
961 | { |
955 | /* normal colors */ |
962 | /* normal colors */ |
956 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
963 | alias_color (idx, minCOLOR + i); |
957 | goto done; |
964 | goto done; |
958 | } |
965 | } |
959 | } |
966 | } |
960 | |
967 | |
961 | set_color (xcol, color); |
968 | pix_colors_focused[idx].free (this); |
962 | |
969 | set_color (pix_colors_focused[idx], color); |
963 | /* |
|
|
964 | * FIXME: should free colors here, but no idea how to do it so instead, |
|
|
965 | * so just keep gobbling up the colormap |
|
|
966 | */ |
|
|
967 | |
|
|
968 | pix_colors_focused[idx] = xcol; |
|
|
969 | |
970 | |
970 | done: |
971 | done: |
971 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
972 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
972 | |
973 | |
973 | update_fade_color (idx); |
974 | update_fade_color (idx); |
974 | recolour_cursor (); |
975 | recolor_cursor (); |
975 | scr_recolour (); |
976 | scr_recolor (); |
976 | #endif /* XTERM_COLOR_CHANGE */ |
977 | #endif /* XTERM_COLOR_CHANGE */ |
977 | } |
978 | } |
978 | |
979 | |
979 | void |
980 | void |
980 | rxvt_term::recolour_cursor () |
981 | rxvt_term::recolor_cursor () |
981 | { |
982 | { |
982 | XColor fg, bg; |
983 | XColor fg, bg; |
983 | |
984 | |
984 | (ISSET_PIXCOLOR (Color_pointer_fg) |
985 | (ISSET_PIXCOLOR (Color_pointer_fg) |
985 | ? pix_colors_focused[Color_pointer_fg] |
986 | ? pix_colors_focused[Color_pointer_fg] |
… | |
… | |
1014 | |
1015 | |
1015 | for (i = Color_Black; i <= Color_White; i++) |
1016 | for (i = Color_Black; i <= Color_White; i++) |
1016 | if (pix_colors[Color_bg] == pix_colors[i]) |
1017 | if (pix_colors[Color_bg] == pix_colors[i]) |
1017 | { |
1018 | { |
1018 | sprintf (bstr, "%d", i - Color_Black); |
1019 | sprintf (bstr, "%d", i - Color_Black); |
1019 | #if BG_IMAGE_FROM_FILE |
1020 | #if HAVE_IMG |
1020 | xpmb = "default;"; |
1021 | xpmb = "default;"; |
1021 | #endif |
1022 | #endif |
1022 | break; |
1023 | break; |
1023 | } |
1024 | } |
1024 | |
1025 | |
… | |
… | |
1040 | } |
1041 | } |
1041 | |
1042 | |
1042 | void |
1043 | void |
1043 | rxvt_term::alias_color (int dst, int src) |
1044 | rxvt_term::alias_color (int dst, int src) |
1044 | { |
1045 | { |
|
|
1046 | pix_colors[dst].free (this); |
1045 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1047 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1046 | } |
1048 | } |
|
|
1049 | |
|
|
1050 | #ifdef SMART_RESIZE |
|
|
1051 | static unsigned int |
|
|
1052 | get_parent_bw (Display *dpy, Window w) |
|
|
1053 | { |
|
|
1054 | int idummy; |
|
|
1055 | unsigned int udummy; |
|
|
1056 | Window wdummy, parent; |
|
|
1057 | Window *children; |
|
|
1058 | unsigned int nchildren, border_width; |
|
|
1059 | |
|
|
1060 | XQueryTree (dpy, w, &wdummy, &parent, &children, &nchildren); |
|
|
1061 | XFree (children); |
|
|
1062 | XGetGeometry (dpy, parent, &wdummy, &idummy, &idummy, |
|
|
1063 | &udummy, &udummy, &border_width, &udummy); |
|
|
1064 | |
|
|
1065 | return border_width; |
|
|
1066 | } |
|
|
1067 | #endif |
1047 | |
1068 | |
1048 | /* -------------------------------------------------------------------- * |
1069 | /* -------------------------------------------------------------------- * |
1049 | * - WINDOW RESIZING - * |
1070 | * - WINDOW RESIZING - * |
1050 | * -------------------------------------------------------------------- */ |
1071 | * -------------------------------------------------------------------- */ |
1051 | void |
1072 | void |
… | |
… | |
1087 | * if display->root isn't the parent window, a WM will probably have offset |
1108 | * if display->root isn't the parent window, a WM will probably have offset |
1088 | * our position for handles and decorations. Counter it |
1109 | * our position for handles and decorations. Counter it |
1089 | */ |
1110 | */ |
1090 | if (x1 != x || y1 != y) |
1111 | if (x1 != x || y1 != y) |
1091 | { |
1112 | { |
1092 | x -= x1; |
1113 | unsigned int border_width = get_parent_bw (dpy, parent); |
1093 | y -= y1; |
1114 | |
|
|
1115 | x -= x1 + border_width; |
|
|
1116 | y -= y1 + border_width; |
1094 | } |
1117 | } |
1095 | |
1118 | |
1096 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1119 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1097 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1120 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1098 | dx = old_width - szHint.width; |
1121 | dx = old_width - szHint.width; |
… | |
… | |
1128 | XMoveResizeWindow (dpy, vt, |
1151 | XMoveResizeWindow (dpy, vt, |
1129 | window_vt_x, window_vt_y, |
1152 | window_vt_x, window_vt_y, |
1130 | vt_width, vt_height); |
1153 | vt_width, vt_height); |
1131 | |
1154 | |
1132 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
1155 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
1133 | |
|
|
1134 | #ifdef HAVE_BG_PIXMAP |
|
|
1135 | if (bg_window_size_sensitive ()) |
|
|
1136 | update_background (); |
|
|
1137 | #endif |
|
|
1138 | } |
1156 | } |
1139 | |
1157 | |
1140 | if (fix_screen || old_height == 0) |
1158 | if (fix_screen || old_height == 0) |
1141 | scr_reset (); |
1159 | scr_reset (); |
1142 | |
1160 | |
… | |
… | |
1363 | unsigned long fg, bg; |
1381 | unsigned long fg, bg; |
1364 | const char *p; |
1382 | const char *p; |
1365 | char **s; |
1383 | char **s; |
1366 | XIMStyles *xim_styles; |
1384 | XIMStyles *xim_styles; |
1367 | |
1385 | |
1368 | set_environ (envv); |
1386 | set_environ (env); |
1369 | |
1387 | |
1370 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1388 | if (!((p = XSetLocaleModifiers (modifiers)) && *p)) |
1371 | return false; |
1389 | return false; |
1372 | |
1390 | |
1373 | input_method = display->get_xim (locale, modifiers); |
1391 | input_method = display->get_xim (locale, modifiers); |
1374 | if (input_method == NULL) |
1392 | if (input_method == NULL) |
1375 | return false; |
1393 | return false; |
… | |
… | |
1675 | { |
1693 | { |
1676 | Window cr; |
1694 | Window cr; |
1677 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1695 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1678 | } |
1696 | } |
1679 | |
1697 | |
1680 | #ifdef HAVE_BG_PIXMAP |
|
|
1681 | |
|
|
1682 | void |
|
|
1683 | rxvt_term::update_background () |
|
|
1684 | { |
|
|
1685 | if (update_background_ev.is_active ()) |
|
|
1686 | return; |
|
|
1687 | |
|
|
1688 | bg_invalidate (); |
|
|
1689 | |
|
|
1690 | if (!mapped) |
|
|
1691 | return; |
|
|
1692 | |
|
|
1693 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
|
|
1694 | |
|
|
1695 | if (to_wait <= 0.) |
|
|
1696 | bg_render (); |
|
|
1697 | else |
|
|
1698 | update_background_ev.start (to_wait); |
|
|
1699 | } |
|
|
1700 | |
|
|
1701 | void |
|
|
1702 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
|
|
1703 | { |
|
|
1704 | make_current (); |
|
|
1705 | |
|
|
1706 | update_background_ev.stop (); |
|
|
1707 | bg_render (); |
|
|
1708 | refresh_check (); |
|
|
1709 | } |
|
|
1710 | |
|
|
1711 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1712 | |
|
|
1713 | /*----------------------- end-of-file (C source) -----------------------*/ |
1698 | /*----------------------- end-of-file (C source) -----------------------*/ |