ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.352 by sf-exg, Fri Feb 11 01:24:46 2011 UTC vs.
Revision 1.403 by root, Thu Jun 17 00:49:20 2021 UTC

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 <pcg@goof.com> 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
36#include "keyboard.h" 37#include "keyboard.h"
37#include "rxvtperl.h" 38#include "rxvtperl.h"
38 39
39#include <limits> 40#include <limits>
40 41
41#include <cassert> 42#include <assert.h>
42#include <csignal> 43#include <signal.h>
43#include <cstring> 44#include <string.h>
44 45
45#include <termios.h> 46#include <termios.h>
46 47
47#ifdef HAVE_XSETLOCALE 48#ifdef HAVE_XSETLOCALE
48# define X_LOCALE 49# define X_LOCALE
49# include <X11/Xlocale.h> 50# include <X11/Xlocale.h>
50#else 51#else
51# ifdef HAVE_SETLOCALE
52# include <clocale> 52# include <locale.h>
53# endif
54#endif 53#endif
55 54
56struct termios rxvt_term::def_tio; 55struct termios rxvt_term::def_tio;
57vector<rxvt_term *> rxvt_term::termlist; 56vector<rxvt_term *> rxvt_term::termlist;
58 57
60rxvt_t rxvt_current_term; 59rxvt_t rxvt_current_term;
61 60
62static char curlocale[128], savelocale[128]; 61static char curlocale[128], savelocale[128];
63 62
64bool 63bool
65rxvt_set_locale (const char *locale) NOTHROW 64rxvt_set_locale (const char *locale) noexcept
66{ 65{
67 int size = strlen (locale) + 1; 66 int size = strlen (locale) + 1;
68 67
69 if (size > sizeof (curlocale)) 68 if (size > sizeof (curlocale))
70 rxvt_fatal ("locale string too long, aborting.\n"); 69 rxvt_fatal ("locale string too long, aborting.\n");
76 setlocale (LC_CTYPE, curlocale); 75 setlocale (LC_CTYPE, curlocale);
77 return true; 76 return true;
78} 77}
79 78
80void 79void
81rxvt_push_locale (const char *locale) NOTHROW 80rxvt_push_locale (const char *locale) noexcept
82{ 81{
83 strcpy (savelocale, curlocale); 82 strcpy (savelocale, curlocale);
84 rxvt_set_locale (locale); 83 rxvt_set_locale (locale);
85} 84}
86 85
87void 86void
88rxvt_pop_locale () NOTHROW 87rxvt_pop_locale () noexcept
89{ 88{
90 rxvt_set_locale (savelocale); 89 rxvt_set_locale (savelocale);
91} 90}
92 91
93#if ENABLE_COMBINING 92#if ENABLE_COMBINING
105 if (cc->c2 == c2) return c1; 104 if (cc->c2 == c2) return c1;
106 cc = (*this)[cc->c1]; 105 cc = (*this)[cc->c1];
107 } 106 }
108 107
109 // check to see whether this combination already exists otherwise 108 // check to see whether this combination already exists otherwise
110 for (cc = v.end (); cc-- > v.begin (); ) 109 for (cc = v.begin (); cc < v.end (); cc++)
111 if (cc->c1 == c1 && cc->c2 == c2) 110 if (cc->c1 == c1 && cc->c2 == c2)
112 return COMPOSE_LO + (cc - v.begin ()); 111 return COMPOSE_LO + (cc - v.begin ());
113 112
114 // allocate a new combination 113 // allocate a new combination
115 if (v.size () == COMPOSE_HI - COMPOSE_LO + 1) 114 if (v.size () == COMPOSE_HI - COMPOSE_LO + 1)
125 v.push_back (compose_char (c1, c2)); 124 v.push_back (compose_char (c1, c2));
126 125
127 return v.size () - 1 + COMPOSE_LO; 126 return v.size () - 1 + COMPOSE_LO;
128} 127}
129 128
129template<typename T>
130int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) 130int rxvt_composite_vec::expand (unicode_t c, T *r)
131{ 131{
132 compose_char *cc = (*this)[c]; 132 compose_char *cc = (*this)[c];
133 133
134 if (!cc) 134 if (!cc)
135 { 135 {
146 len++; 146 len++;
147 if (r) *r++ = cc->c2; 147 if (r) *r++ = cc->c2;
148 } 148 }
149 149
150 return len; 150 return len;
151
152} 151}
152
153template int rxvt_composite_vec::expand<text_t> (unicode_t c, text_t *);
154template int rxvt_composite_vec::expand<wchar_t> (unicode_t c, wchar_t *);
153#endif 155#endif
154 156
155rxvt_term::rxvt_term () 157rxvt_term::rxvt_term ()
156{ 158{
157#if HAVE_BG_PIXMAP
158 update_background_ev.set<rxvt_term, &rxvt_term::update_background_cb> (this);
159#endif
160#ifdef CURSOR_BLINK 159#ifdef CURSOR_BLINK
161 cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); 160 cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL);
162#endif 161#endif
163#ifdef TEXT_BLINK 162#ifdef TEXT_BLINK
164 text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); 163 text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL);
170 sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); 169 sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this);
171#endif 170#endif
172#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 171#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
173 slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); 172 slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this);
174#endif 173#endif
175#if ENABLE_TRANSPARENCY || ENABLE_PERL 174#if ENABLE_PERL
176 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), 175 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this),
177#endif 176#endif
178 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), 177 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this),
179#ifdef USE_XIM 178#if USE_XIM
180 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), 179 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this),
181#endif 180#endif
182#ifdef POINTER_BLANK 181#ifdef POINTER_BLANK
183 pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); 182 pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this);
184#endif 183#endif
224 if (fontset[i] != fontset[0]) 223 if (fontset[i] != fontset[0])
225 delete fontset[i]; 224 delete fontset[i];
226#endif 225#endif
227 delete fontset[0]; 226 delete fontset[0];
228 227
229#ifdef HAVE_BG_PIXMAP 228#if HAVE_IMG
230 bg_destroy (); 229 delete bg_img;
231#endif 230#endif
232 231
233 if (display) 232 if (display)
234 { 233 {
235 selection_clear (); 234 selection_clear ();
236 selection_clear (true); 235 selection_clear (true);
237 236
238#ifdef USE_XIM 237#if USE_XIM
239 im_destroy (); 238 im_destroy ();
240#endif 239#endif
241 scrollBar.destroy (); 240 scrollBar.destroy ();
241
242 if (gc)
242 if (gc) XFreeGC (dpy, gc); 243 XFreeGC (dpy, gc);
243 244
244 delete drawable; 245 delete drawable;
246
245 // destroy all windows 247 // destroy all windows
246 if (parent[0]) 248 if (parent)
247 XDestroyWindow (dpy, parent[0]); 249 XDestroyWindow (dpy, parent);
248 250
249 for (int i = 0; i < TOTAL_COLORS; i++) 251 for (int i = 0; i < TOTAL_COLORS; i++)
250 if (ISSET_PIXCOLOR (i)) 252 if (ISSET_PIXCOLOR (i))
251 { 253 {
252 pix_colors_focused [i].free (this); 254 pix_colors_focused [i].free (this);
253#if OFF_FOCUS_FADING 255#if OFF_FOCUS_FADING
256 if (rs[Rs_fade])
254 pix_colors_unfocused [i].free (this); 257 pix_colors_unfocused [i].free (this);
255#endif 258#endif
256 } 259 }
257 260
258 clear (); 261 clear ();
259 262
267 for (int i = 0; i < allocated.size (); i++) 270 for (int i = 0; i < allocated.size (); i++)
268 free (allocated [i]); 271 free (allocated [i]);
269 272
270 free (selection.text); 273 free (selection.text);
271 free (selection.clip_text); 274 free (selection.clip_text);
272 // TODO: manage env vars in child only(!)
273 free (env_display);
274 free (env_term);
275 free (locale); 275 free (locale);
276 free (v_buffer); 276 free (v_buffer);
277 277
278 delete selection_req;
279
280 if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *)))
281 rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n");
282
283 delete [] env;
284
278 delete envv; 285 delete envv;
279 delete argv; 286 delete argv;
280 287
281#ifdef KEYSYM_RESOURCE 288#ifdef KEYSYM_RESOURCE
282 delete keyboard; 289 delete keyboard;
283#endif 290#endif
284#ifndef NO_RESOURCES 291#ifndef NO_RESOURCES
285 XrmDestroyDatabase (option_db); 292 XrmDestroyDatabase (option_db);
286#endif 293#endif
294
295 SET_R ((rxvt_term *)0);
287} 296}
288 297
289// child has exited, usually destroys 298// child has exited, usually destroys
290void 299void
291rxvt_term::child_cb (ev::child &w, int status) 300rxvt_term::child_cb (ev::child &w, int status)
314 { 323 {
315#if USE_XIM 324#if USE_XIM
316 im_ev.stop (display); 325 im_ev.stop (display);
317#endif 326#endif
318 scrollbar_ev.stop (display); 327 scrollbar_ev.stop (display);
319#if ENABLE_TRANSPARENCY || ENABLE_PERL 328#if ENABLE_PERL
320 rootwin_ev.stop (display); 329 rootwin_ev.stop (display);
321#endif 330#endif
322 termwin_ev.stop (display); 331 termwin_ev.stop (display);
323 vt_ev.stop (display); 332 vt_ev.stop (display);
324 } 333 }
351 360
352 delete this; 361 delete this;
353} 362}
354 363
355void 364void
356rxvt_term::set_option (uint8_t opt, bool set) 365rxvt_term::set_option (uint8_t opt, bool set) noexcept
357{ 366{
358 if (!opt) 367 if (!opt)
359 return; 368 return;
360 369
361 uint8_t mask = 1 << (opt & 7); 370 uint8_t mask = 1 << (opt & 7);
365} 374}
366 375
367/*----------------------------------------------------------------------*/ 376/*----------------------------------------------------------------------*/
368/* 377/*
369 * Exit gracefully, clearing the utmp entry and restoring tty attributes 378 * Exit gracefully, clearing the utmp entry and restoring tty attributes
370 * TODO: if debugging, this should free up any known resources if we can
371 */ 379 */
372static XErrorHandler old_xerror_handler; 380static XErrorHandler old_xerror_handler;
373 381
374static void 382static void
375rxvt_emergency_cleanup () 383rxvt_emergency_cleanup ()
377 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 385 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
378 (*t)->emergency_cleanup (); 386 (*t)->emergency_cleanup ();
379} 387}
380 388
381#if !ENABLE_MINIMAL 389#if !ENABLE_MINIMAL
382static void 390static void ecb_cold
383print_x_error (Display *dpy, XErrorEvent *event) 391print_x_error (Display *dpy, XErrorEvent *event)
384{ 392{
385 char buffer[BUFSIZ]; 393 char buffer[BUFSIZ];
386 char mesg[BUFSIZ]; 394 char mesg[BUFSIZ];
387 char number[32]; 395 char number[32];
388 const char mtype[] = "XlibMessage"; 396
389 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
390 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
391 rxvt_warn ("An X Error occurred, trying to continue after report.\n"); 397 rxvt_warn ("An X Error occurred, trying to continue after report.\n");
398
399 XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ);
400 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial);
401
402 XGetErrorText (dpy, event->error_code, buffer, BUFSIZ);
403 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ);
392 rxvt_warn ("%s: %s\n", mesg, buffer); 404 rxvt_warn ("+ %s: %s\n", mesg, buffer);
405
393 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); 406 XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ);
394 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); 407 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code);
408
409 if (event->request_code >= 128)
410 {
411#if 0
412 /* XListExtensions and probably query extensions hangs when there are multiple queues errors */
413 int nexts;
414 char **exts = XListExtensions (dpy, &nexts);
415
416 while (nexts)
417 {
418 char *extname = exts [nexts - 1];
419 int major, first_event, first_error;
420
421 if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code)
422 {
423 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ);
424 rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code);
425
426 snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code);
427 XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ);
428 rxvt_warn ("+ (which is %s)\n", buffer);
429
430 break;
431 }
432
433 printf ("nextss %d %s\n", nexts, extname);//D
434 --nexts;
435 ++exts;
436 }
437#else
438 int nexts = 0;
439 char **exts = 0;
440#endif
441
442 if (!nexts)
443 {
444 rxvt_warn ("+ (which is an unknown extension)\n", buffer);
445
446 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ);
447 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code);
448
449#if 0
450 sprintf (number, "RENDER.%d", event->minor_code);
451 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ);
452 rxvt_warn ("+ (which is %s)\n", buffer);
453#endif
454 }
455
456 XFreeExtensionList (exts);
457 }
458 else
459 {
395 sprintf(number, "%d", event->request_code); 460 sprintf (number, "%d", event->request_code);
396 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); 461 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ);
397 rxvt_warn ("(which is %s)\n", buffer); 462 rxvt_warn ("+ (which is %s)\n", buffer);
398 if (event->request_code >= 128) {
399 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
400 mesg, BUFSIZ);
401 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
402 } 463 }
464
403 if ((event->error_code == BadWindow) || 465 if (event->error_code == BadWindow
404 (event->error_code == BadPixmap) || 466 || event->error_code == BadPixmap
405 (event->error_code == BadCursor) || 467 || event->error_code == BadCursor
406 (event->error_code == BadFont) || 468 || event->error_code == BadFont
407 (event->error_code == BadDrawable) || 469 || event->error_code == BadDrawable
408 (event->error_code == BadColor) || 470 || event->error_code == BadColor
409 (event->error_code == BadGC) || 471 || event->error_code == BadGC
410 (event->error_code == BadIDChoice) || 472 || event->error_code == BadIDChoice
411 (event->error_code == BadValue) || 473 || event->error_code == BadValue
412 (event->error_code == BadAtom)) { 474 || event->error_code == BadAtom)
475 {
413 if (event->error_code == BadValue) 476 if (event->error_code == BadValue)
414 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", 477 XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ);
415 mesg, BUFSIZ);
416 else if (event->error_code == BadAtom) 478 else if (event->error_code == BadAtom)
417 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", 479 XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ);
418 mesg, BUFSIZ);
419 else 480 else
420 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", 481 XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ);
421 mesg, BUFSIZ);
422 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
423 }
424 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
425 mesg, BUFSIZ);
426 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
427}
428#endif
429 482
430int 483 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid);
484 }
485}
486#endif
487
488int ecb_cold
431rxvt_xerror_handler (Display *display, XErrorEvent *event) 489rxvt_xerror_handler (Display *display, XErrorEvent *event)
432{ 490{
433 if (GET_R->allowedxerror == -1) 491 if (GET_R && GET_R->allowedxerror == -1)
434 GET_R->allowedxerror = event->error_code; 492 GET_R->allowedxerror = event->error_code;
435 else 493 else
436 { 494 {
437 // GET_R is most likely not the terminal which caused the error, 495 // GET_R is most likely not the terminal which caused the error,
438 // so just output the error and continue 496 // so just output the error and continue
444 } 502 }
445 503
446 return 0; 504 return 0;
447} 505}
448 506
449int 507int ecb_cold
450rxvt_xioerror_handler (Display *display) 508rxvt_xioerror_handler (Display *display)
451{ 509{
452 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", 510 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
453 DisplayString (display)); 511 DisplayString (display));
454 rxvt_emergency_cleanup (); 512 rxvt_emergency_cleanup ();
574 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 632 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
575 // TODO: handle this with exceptions and tolerate the memory loss 633 // TODO: handle this with exceptions and tolerate the memory loss
576 XSetIOErrorHandler (rxvt_xioerror_handler); 634 XSetIOErrorHandler (rxvt_xioerror_handler);
577 635
578 XrmInitialize (); 636 XrmInitialize ();
637
638#if HAVE_PIXBUF
639 g_type_init ();
640#endif
579} 641}
580 642
581/*----------------------------------------------------------------------*/ 643/*----------------------------------------------------------------------*/
582/* 644/*
583 * window size/position calculations for XSizeHint and other storage. 645 * window size/position calculations for XSizeHint and other storage.
704 if (recalc_y) 766 if (recalc_y)
705 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; 767 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth;
706 768
707 ncol = width / fwidth; 769 ncol = width / fwidth;
708 nrow = height / fheight; 770 nrow = height / fheight;
771
772 // When the size of the vt window is not a multiple of the cell
773 // size, i.e., when the wm does not honour our size hints, there are
774 // extra areas not covered by the terminal screen. Such gaps, when a
775 // bg pixmap is set, would have to be cleared manually to properly
776 // refresh the background. We take the simpler route and shrink the
777 // vt window so as to avoid creating gaps.
778 vt_width = ncol * fwidth;
779 vt_height = nrow * fheight;
709} 780}
710 781
711/*----------------------------------------------------------------------*/ 782/*----------------------------------------------------------------------*/
712/* 783/*
713 * Tell the teletype handler what size the window is. 784 * Tell the teletype handler what size the window is.
721 792
722 struct winsize ws; 793 struct winsize ws;
723 794
724 ws.ws_col = ncol; 795 ws.ws_col = ncol;
725 ws.ws_row = nrow; 796 ws.ws_row = nrow;
726 ws.ws_xpixel = width; 797 ws.ws_xpixel = vt_width;
727 ws.ws_ypixel = height; 798 ws.ws_ypixel = vt_height;
728 ioctl (pty->pty, TIOCSWINSZ, &ws); 799 ioctl (pty->pty, TIOCSWINSZ, &ws);
729 800
730#if 0 801#if 0
731 // TIOCSWINSZ is supposed to do this automatically and correctly 802 // TIOCSWINSZ is supposed to do this automatically and correctly
732 if (cmd_pid) /* force through to the command */ 803 if (cmd_pid) /* force through to the command */
733 kill (-cmd_pid, SIGWINCH); 804 kill (-cmd_pid, SIGWINCH);
734#endif 805#endif
735} 806}
736 807
737/*----------------------------------------------------------------------*/ 808/*----------------------------------------------------------------------*/
738/* set_fonts () - load and set the various fonts 809/* load and set the various fonts */
739 *
740 * init = 1 - initialize
741 *
742 * fontname == FONT_UP - switch to bigger font
743 * fontname == FONT_DN - switch to smaller font
744 */
745bool 810bool
746rxvt_term::set_fonts () 811rxvt_term::set_fonts ()
747{ 812{
748 rxvt_fontset *fs = new rxvt_fontset (this); 813 rxvt_fontset *fs = new rxvt_fontset (this);
749 rxvt_fontprop prop; 814 rxvt_fontprop prop;
764 829
765 delete fontset[0]; 830 delete fontset[0];
766 fontset[0] = fs; 831 fontset[0] = fs;
767 832
768 prop = (*fs)[rxvt_fontset::firstFont]->properties (); 833 prop = (*fs)[rxvt_fontset::firstFont]->properties ();
769 prop.height += lineSpace; 834 prop.width = max (prop.width + letterSpace, 1);
770 prop.width += letterSpace;
771 835
772 fs->set_prop (prop, false); 836 fs->set_prop (prop, false);
773 837
774 fwidth = prop.width; 838 fwidth = prop.width;
775 fheight = prop.height; 839 fheight = prop.height + lineSpace;
776 fbase = prop.ascent; 840 fbase = prop.ascent;
777 841
778 for (int style = 1; style < 4; style++) 842 for (int style = 1; style < 4; style++)
779 { 843 {
780#if ENABLE_STYLES 844#if ENABLE_STYLES
806#else 870#else
807 fontset[style] = fontset[0]; 871 fontset[style] = fontset[0];
808#endif 872#endif
809 } 873 }
810 874
811 if (parent[0]) 875 if (parent)
812 { 876 {
813 resize_all_windows (0, 0, 0); 877 resize_all_windows (0, 0, 0);
814 scr_remap_chars (); 878 scr_remap_chars ();
815 scr_touch (true); 879 scr_touch (true);
816 } 880 }
819} 883}
820 884
821void 885void
822rxvt_term::set_string_property (Atom prop, const char *str, int len) 886rxvt_term::set_string_property (Atom prop, const char *str, int len)
823{ 887{
824 XChangeProperty (dpy, parent[0], 888 XChangeProperty (dpy, parent,
825 prop, XA_STRING, 8, PropModeReplace, 889 prop, XA_STRING, 8, PropModeReplace,
826 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 890 (const unsigned char *)str, len >= 0 ? len : strlen (str));
827} 891}
828 892
829void 893void
831{ 895{
832 XTextProperty ct; 896 XTextProperty ct;
833 897
834 if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0) 898 if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0)
835 { 899 {
836 XSetTextProperty (dpy, parent[0], &ct, prop); 900 XSetTextProperty (dpy, parent, &ct, prop);
837 XFree (ct.value); 901 XFree (ct.value);
838 } 902 }
839} 903}
840 904
841void 905void
842rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 906rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
843{ 907{
844 wchar_t *ws = rxvt_mbstowcs (str, len); 908 wchar_t *ws = rxvt_mbstowcs (str, len);
845 char *s = rxvt_wcstoutf8 (ws); 909 char *s = rxvt_wcstoutf8 (ws);
846 910
847 XChangeProperty (dpy, parent[0], 911 XChangeProperty (dpy, parent,
848 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 912 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
849 (const unsigned char *)s, strlen (s)); 913 (const unsigned char *)s, strlen (s));
850 914
851 free (s); 915 free (s);
852 free (ws); 916 free (ws);
875 939
876void 940void
877rxvt_term::set_window_color (int idx, const char *color) 941rxvt_term::set_window_color (int idx, const char *color)
878{ 942{
879#ifdef XTERM_COLOR_CHANGE 943#ifdef XTERM_COLOR_CHANGE
880 rxvt_color xcol;
881
882 if (color == NULL || *color == '\0') 944 if (color == NULL || *color == '\0')
883 return; 945 return;
884 946
885 color = strdup (color); 947 color = strdup (color);
886 allocated.push_back ((void *)color); 948 allocated.push_back ((void *)color);
892 int i = atoi (color); 954 int i = atoi (color);
893 955
894 if (i >= 8 && i <= 15) 956 if (i >= 8 && i <= 15)
895 { 957 {
896 /* bright colors */ 958 /* bright colors */
897 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 959 alias_color (idx, minBrightCOLOR + i - 8);
898 goto done; 960 goto done;
899 } 961 }
900 962
901 if (i >= 0 && i <= 7) 963 if (i >= 0 && i <= 7)
902 { 964 {
903 /* normal colors */ 965 /* normal colors */
904 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 966 alias_color (idx, minCOLOR + i);
905 goto done; 967 goto done;
906 } 968 }
907 } 969 }
908 970
909 set_color (xcol, color); 971 pix_colors_focused[idx].free (this);
910 972 set_color (pix_colors_focused[idx], color);
911 /*
912 * FIXME: should free colors here, but no idea how to do it so instead,
913 * so just keep gobbling up the colormap
914 */
915
916 pix_colors_focused[idx] = xcol;
917 973
918done: 974done:
919 /*TODO: handle Color_BD, scrollbar background, etc. */ 975 /*TODO: handle Color_BD, scrollbar background, etc. */
920 976
921 update_fade_color (idx); 977 update_fade_color (idx);
922 recolour_cursor (); 978 recolor_cursor ();
923 scr_recolour (); 979 scr_recolor ();
924#endif /* XTERM_COLOR_CHANGE */ 980#endif /* XTERM_COLOR_CHANGE */
925} 981}
926 982
927void 983void
928rxvt_term::recolour_cursor () 984rxvt_term::recolor_cursor ()
929{ 985{
930 XColor fg, bg; 986 XColor fg, bg;
931 987
932 (ISSET_PIXCOLOR (Color_pointer_fg) 988 (ISSET_PIXCOLOR (Color_pointer_fg)
933 ? pix_colors_focused[Color_pointer_fg] 989 ? pix_colors_focused[Color_pointer_fg]
942 998
943/*----------------------------------------------------------------------*/ 999/*----------------------------------------------------------------------*/
944/* 1000/*
945 * find if fg/bg matches any of the normal (low-intensity) colors 1001 * find if fg/bg matches any of the normal (low-intensity) colors
946 */ 1002 */
947void 1003char *
948rxvt_term::set_colorfgbg () 1004rxvt_term::get_colorfgbg ()
949{ 1005{
950 unsigned int i; 1006 unsigned int i;
951 const char *xpmb = ""; 1007 const char *xpmb = "";
952 char fstr[] = "default"; 1008 char fstr[] = "default";
953 char bstr[] = "default"; 1009 char bstr[] = "default";
1010 char *env_colorfgbg;
954 1011
955 for (i = Color_Black; i <= Color_White; i++) 1012 for (i = Color_Black; i <= Color_White; i++)
956 if (pix_colors[Color_fg] == pix_colors[i]) 1013 if (pix_colors[Color_fg] == pix_colors[i])
957 { 1014 {
958 sprintf (fstr, "%d", i - Color_Black); 1015 sprintf (fstr, "%d", i - Color_Black);
961 1018
962 for (i = Color_Black; i <= Color_White; i++) 1019 for (i = Color_Black; i <= Color_White; i++)
963 if (pix_colors[Color_bg] == pix_colors[i]) 1020 if (pix_colors[Color_bg] == pix_colors[i])
964 { 1021 {
965 sprintf (bstr, "%d", i - Color_Black); 1022 sprintf (bstr, "%d", i - Color_Black);
966#ifdef BG_IMAGE_FROM_FILE 1023#if HAVE_IMG
967 xpmb = "default;"; 1024 xpmb = "default;";
968#endif 1025#endif
969 break; 1026 break;
970 } 1027 }
971 1028
1029 env_colorfgbg = (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg"));
972 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1030 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
1031 return env_colorfgbg;
973} 1032}
974 1033
975/*----------------------------------------------------------------------*/ 1034/*----------------------------------------------------------------------*/
976 1035
977bool 1036bool
985} 1044}
986 1045
987void 1046void
988rxvt_term::alias_color (int dst, int src) 1047rxvt_term::alias_color (int dst, int src)
989{ 1048{
1049 pix_colors[dst].free (this);
990 pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); 1050 pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]);
991} 1051}
1052
1053#ifdef SMART_RESIZE
1054static unsigned int
1055get_parent_bw (Display *dpy, Window w)
1056{
1057 int idummy;
1058 unsigned int udummy;
1059 Window wdummy, parent;
1060 Window *children;
1061 unsigned int nchildren, border_width;
1062
1063 XQueryTree (dpy, w, &wdummy, &parent, &children, &nchildren);
1064 XFree (children);
1065 XGetGeometry (dpy, parent, &wdummy, &idummy, &idummy,
1066 &udummy, &udummy, &border_width, &udummy);
1067
1068 return border_width;
1069}
1070#endif
992 1071
993/* -------------------------------------------------------------------- * 1072/* -------------------------------------------------------------------- *
994 * - WINDOW RESIZING - * 1073 * - WINDOW RESIZING - *
995 * -------------------------------------------------------------------- */ 1074 * -------------------------------------------------------------------- */
996void 1075void
1006 1085
1007 // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow 1086 // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow
1008 if (set_hint) 1087 if (set_hint)
1009 { 1088 {
1010 szHint.flags &= ~(PBaseSize | PResizeInc); 1089 szHint.flags &= ~(PBaseSize | PResizeInc);
1011 XSetWMNormalHints (dpy, parent[0], &szHint); 1090 XSetWMNormalHints (dpy, parent, &szHint);
1012 szHint.flags |= PBaseSize | PResizeInc; 1091 szHint.flags |= PBaseSize | PResizeInc;
1013 } 1092 }
1014 1093
1015 if (!ignoreparent) 1094 if (!ignoreparent)
1016 { 1095 {
1022 int x, y, x1, y1; 1101 int x, y, x1, y1;
1023 int dx, dy; 1102 int dx, dy;
1024 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1103 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1025 Window unused_cr; 1104 Window unused_cr;
1026 1105
1027 XTranslateCoordinates (dpy, parent[0], display->root, 1106 XTranslateCoordinates (dpy, parent, display->root,
1028 0, 0, &x, &y, &unused_cr); 1107 0, 0, &x, &y, &unused_cr);
1029 XGetGeometry (dpy, parent[0], &unused_cr, &x1, &y1, 1108 XGetGeometry (dpy, parent, &unused_cr, &x1, &y1,
1030 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1109 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1031 /* 1110 /*
1032 * if display->root isn't the parent window, a WM will probably have offset 1111 * if display->root isn't the parent window, a WM will probably have offset
1033 * our position for handles and decorations. Counter it 1112 * our position for handles and decorations. Counter it
1034 */ 1113 */
1035 if (x1 != x || y1 != y) 1114 if (x1 != x || y1 != y)
1036 { 1115 {
1037 x -= x1; 1116 unsigned int border_width = get_parent_bw (dpy, parent);
1038 y -= y1; 1117
1118 x -= x1 + border_width;
1119 y -= y1 + border_width;
1039 } 1120 }
1040 1121
1041 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; 1122 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
1042 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; 1123 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2;
1043 dx = old_width - szHint.width; 1124 dx = old_width - szHint.width;
1051 if (y < y1) /* top half */ 1132 if (y < y1) /* top half */
1052 dy = 0; 1133 dy = 0;
1053 else if (y == y1) /* exact center */ 1134 else if (y == y1) /* exact center */
1054 dy /= 2; 1135 dy /= 2;
1055 1136
1056 XMoveResizeWindow (dpy, parent[0], x + dx, y + dy, 1137 XMoveResizeWindow (dpy, parent, x + dx, y + dy,
1057 szHint.width, szHint.height); 1138 szHint.width, szHint.height);
1058#else 1139#else
1059 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 1140 XResizeWindow (dpy, parent, szHint.width, szHint.height);
1060#endif 1141#endif
1061 } 1142 }
1062 1143
1063 if (set_hint) 1144 if (set_hint)
1064 XSetWMNormalHints (dpy, parent[0], &szHint); 1145 XSetWMNormalHints (dpy, parent, &szHint);
1065 1146
1066 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 1147 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
1067 1148
1068 if (fix_screen || newwidth != old_width || newheight != old_height) 1149 if (fix_screen || newwidth != old_width || newheight != old_height)
1069 { 1150 {
1070 if (scrollBar.state) 1151 if (scrollBar.state)
1071 scrollBar.resize (); 1152 scrollBar.resize ();
1072 1153
1073 XMoveResizeWindow (dpy, vt, 1154 XMoveResizeWindow (dpy, vt,
1074 window_vt_x, window_vt_y, 1155 window_vt_x, window_vt_y,
1075 width, height); 1156 vt_width, vt_height);
1076 1157
1077#ifdef HAVE_BG_PIXMAP 1158 HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END));
1078 if (bg_window_size_sensitive ())
1079 update_background ();
1080#endif
1081 } 1159 }
1082 1160
1083 if (fix_screen || old_height == 0) 1161 if (fix_screen || old_height == 0)
1084 scr_reset (); 1162 scr_reset ();
1085 1163
1086#ifdef USE_XIM 1164#if USE_XIM
1087 IMSetPosition (); 1165 im_set_position ();
1088#endif 1166#endif
1089} 1167}
1090 1168
1091/* 1169/*
1092 * Set the width/height of the vt window in characters. Units are pixels. 1170 * Set the width/height of the vt window in characters. Units are pixels.
1105 newwidth = wattr.width - szHint.base_width; 1183 newwidth = wattr.width - szHint.base_width;
1106 if (newheight == 0) 1184 if (newheight == 0)
1107 newheight = wattr.height - szHint.base_height; 1185 newheight = wattr.height - szHint.base_height;
1108 } 1186 }
1109 1187
1110 if (newwidth != width || newheight != height) 1188 if (newwidth != vt_width || newheight != vt_height)
1111 { 1189 {
1112 newwidth += szHint.base_width; 1190 newwidth += szHint.base_width;
1113 newheight += szHint.base_height; 1191 newheight += szHint.base_height;
1114 resize_all_windows (newwidth, newheight, 0); 1192 resize_all_windows (newwidth, newheight, 0);
1115 } 1193 }
1116} 1194}
1117 1195
1118/* -------------------------------------------------------------------- * 1196/* -------------------------------------------------------------------- *
1119 * - X INPUT METHOD ROUTINES - * 1197 * - X INPUT METHOD ROUTINES - *
1120 * -------------------------------------------------------------------- */ 1198 * -------------------------------------------------------------------- */
1121#ifdef USE_XIM 1199#if USE_XIM
1122 1200
1123void 1201void
1124rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) 1202rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg)
1125{ 1203{
1126 fg = pix_colors [Color_fg]; 1204 fg = pix_colors [Color_fg];
1153 status_rect.height = fheight; 1231 status_rect.height = fheight;
1154} 1232}
1155 1233
1156/* Checking whether input method is running. */ 1234/* Checking whether input method is running. */
1157bool 1235bool
1158rxvt_term::IMisRunning () 1236rxvt_term::im_is_running ()
1159{ 1237{
1160 Atom atom; 1238 Atom atom;
1161 Window win; 1239 Window win;
1162 char server[IMBUFSIZ]; 1240 char server[IMBUFSIZ];
1163 1241
1179 1257
1180 return false; 1258 return false;
1181} 1259}
1182 1260
1183void 1261void
1184rxvt_term::IMSendSpot () 1262rxvt_term::im_send_spot ()
1185{ 1263{
1186 XPoint nspot; 1264 XPoint nspot;
1187 XVaNestedList preedit_attr; 1265 XVaNestedList preedit_attr;
1188 1266
1189 if (!Input_Context 1267 if (!Input_Context
1295/* 1373/*
1296 * Try to open a XIM with the current modifiers, then see if we can 1374 * Try to open a XIM with the current modifiers, then see if we can
1297 * open a suitable preedit type 1375 * open a suitable preedit type
1298 */ 1376 */
1299bool 1377bool
1300rxvt_term::IM_get_IC (const char *modifiers) 1378rxvt_term::im_get_ic (const char *modifiers)
1301{ 1379{
1302 int i, j, found; 1380 int i, j, found;
1303 XIM xim; 1381 XIM xim;
1304 XPoint spot; 1382 XPoint spot;
1305 XRectangle rect, status_rect, needed_rect; 1383 XRectangle rect, status_rect, needed_rect;
1306 unsigned long fg, bg; 1384 unsigned long fg, bg;
1307 const char *p; 1385 const char *p;
1308 char **s; 1386 char **s;
1309 XIMStyles *xim_styles; 1387 XIMStyles *xim_styles;
1310#ifdef ENABLE_XIM_ONTHESPOT
1311 XIMCallback xcb[4];
1312#endif
1313 1388
1314 set_environ (envv); 1389 set_environ (env);
1315 1390
1316 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1391 if (!((p = XSetLocaleModifiers (modifiers)) && *p))
1317 return false; 1392 return false;
1318 1393
1319 input_method = display->get_xim (locale, modifiers); 1394 input_method = display->get_xim (locale, modifiers);
1320 if (input_method == NULL) 1395 if (input_method == NULL)
1321 return false; 1396 return false;
1457 NULL); 1532 NULL);
1458 } 1533 }
1459#if ENABLE_XIM_ONTHESPOT 1534#if ENABLE_XIM_ONTHESPOT
1460 else if (input_style & XIMPreeditCallbacks) 1535 else if (input_style & XIMPreeditCallbacks)
1461 { 1536 {
1537 XIMCallback xcb[4];
1538
1462 im_set_position (spot); 1539 im_set_position (spot);
1463 1540
1464 xcb[0].client_data = (XPointer)this; xcb[0].callback = (XIMProc)xim_preedit_start; 1541 xcb[0].client_data = (XPointer)this; xcb[0].callback = (XIMProc)xim_preedit_start;
1465 xcb[1].client_data = (XPointer)this; xcb[1].callback = (XIMProc)xim_preedit_done; 1542 xcb[1].client_data = (XPointer)this; xcb[1].callback = (XIMProc)xim_preedit_done;
1466 xcb[2].client_data = (XPointer)this; xcb[2].callback = (XIMProc)xim_preedit_draw; 1543 xcb[2].client_data = (XPointer)this; xcb[2].callback = (XIMProc)xim_preedit_draw;
1481#endif 1558#endif
1482 1559
1483 Input_Context = XCreateIC (xim, 1560 Input_Context = XCreateIC (xim,
1484 XNInputStyle, input_style, 1561 XNInputStyle, input_style,
1485 XNClientWindow, vt, 1562 XNClientWindow, vt,
1486 XNFocusWindow, parent[0], 1563 XNFocusWindow, parent,
1487 preedit_attr ? XNPreeditAttributes : NULL, 1564 preedit_attr ? XNPreeditAttributes : NULL,
1488 preedit_attr, 1565 preedit_attr,
1489 status_attr ? XNStatusAttributes : NULL, 1566 status_attr ? XNStatusAttributes : NULL,
1490 status_attr, NULL); 1567 status_attr, NULL);
1491 1568
1504 // unfortunately, only the focus window is used by XIM, hard to fix 1581 // unfortunately, only the focus window is used by XIM, hard to fix
1505 if (!XGetICValues (Input_Context, XNFilterEvents, &vt_emask_xim, NULL)) 1582 if (!XGetICValues (Input_Context, XNFilterEvents, &vt_emask_xim, NULL))
1506 vt_select_input (); 1583 vt_select_input ();
1507#endif 1584#endif
1508 1585
1509 IMSetPosition (); 1586 im_set_position ();
1510 1587
1511 return true; 1588 return true;
1512} 1589}
1513 1590
1514void 1591void
1524 im_destroy (); 1601 im_destroy ();
1525 1602
1526 if (Input_Context) 1603 if (Input_Context)
1527 return; 1604 return;
1528 1605
1529#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
1530 if (rs[Rs_imLocale]) 1606 if (rs[Rs_imLocale])
1531 SET_LOCALE (rs[Rs_imLocale]); 1607 SET_LOCALE (rs[Rs_imLocale]);
1532#endif
1533 1608
1534 p = rs[Rs_inputMethod]; 1609 p = rs[Rs_inputMethod];
1535 if (p && *p) 1610 if (p && *p)
1536 { 1611 {
1537 bool found = false; 1612 bool found = false;
1542 { 1617 {
1543 if (*s[i]) 1618 if (*s[i])
1544 { 1619 {
1545 strcpy (buf, "@im="); 1620 strcpy (buf, "@im=");
1546 strncat (buf, s[i], IMBUFSIZ - 5); 1621 strncat (buf, s[i], IMBUFSIZ - 5);
1547 if (IM_get_IC (buf)) 1622 if (im_get_ic (buf))
1548 { 1623 {
1549 found = true; 1624 found = true;
1550 break; 1625 break;
1551 } 1626 }
1552 } 1627 }
1557 if (found) 1632 if (found)
1558 goto done; 1633 goto done;
1559 } 1634 }
1560 1635
1561 /* try with XMODIFIERS env. var. */ 1636 /* try with XMODIFIERS env. var. */
1562 if (IM_get_IC ("")) 1637 if (im_get_ic (""))
1563 goto done; 1638 goto done;
1564 1639
1565 /* try with no modifiers base IF the user didn't specify an IM */ 1640 /* try with no modifiers base IF the user didn't specify an IM */
1566 if (IM_get_IC ("@im=none")) 1641 if (im_get_ic ("@im=none"))
1567 goto done; 1642 goto done;
1568 1643
1569done: 1644done:
1570#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
1571 if (rs[Rs_imLocale]) 1645 if (rs[Rs_imLocale])
1572 SET_LOCALE (locale); 1646 SET_LOCALE (locale);
1573#endif
1574} 1647}
1575 1648
1576void 1649void
1577rxvt_term::IMSetPosition () 1650rxvt_term::im_set_position ()
1578{ 1651{
1579 XRectangle preedit_rect, status_rect, *needed_rect; 1652 XRectangle preedit_rect, status_rect, *needed_rect;
1580 XVaNestedList preedit_attr, status_attr; 1653 XVaNestedList preedit_attr, status_attr;
1581 1654
1582 if (!Input_Context 1655 if (!Input_Context
1583 || !focus 1656 || !focus
1584 || !(input_style & (XIMPreeditArea | XIMPreeditPosition)) 1657 || !(input_style & (XIMPreeditArea | XIMPreeditPosition))
1585 || !IMisRunning ()) 1658 || !im_is_running ())
1586 return; 1659 return;
1587 1660
1588 if (input_style & XIMPreeditPosition) 1661 if (input_style & XIMPreeditPosition)
1589 { 1662 {
1590 im_set_size (preedit_rect); 1663 im_set_size (preedit_rect);
1620 1693
1621void 1694void
1622rxvt_term::get_window_origin (int &x, int &y) 1695rxvt_term::get_window_origin (int &x, int &y)
1623{ 1696{
1624 Window cr; 1697 Window cr;
1625 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); 1698 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr);
1626} 1699}
1627
1628Pixmap
1629rxvt_term::get_pixmap_property (Atom property)
1630{
1631 Pixmap pixmap = None;
1632
1633 int aformat;
1634 unsigned long nitems, bytes_after;
1635 Atom atype;
1636 unsigned char *prop;
1637 int result = XGetWindowProperty (dpy, display->root, property,
1638 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1639 &nitems, &bytes_after, &prop);
1640 if (result == Success)
1641 {
1642 if (atype == XA_PIXMAP)
1643 pixmap = *(Pixmap *)prop;
1644 XFree (prop);
1645 }
1646
1647 return pixmap;
1648}
1649
1650#ifdef HAVE_BG_PIXMAP
1651
1652void
1653rxvt_term::update_background ()
1654{
1655 if (update_background_ev.is_active ())
1656 return;
1657
1658 bg_invalidate ();
1659
1660 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1661
1662 if (to_wait <= 0.)
1663 bg_render ();
1664 else
1665 update_background_ev.start (to_wait);
1666}
1667
1668void
1669rxvt_term::update_background_cb (ev::timer &w, int revents)
1670{
1671 make_current ();
1672
1673 update_background_ev.stop ();
1674 bg_render ();
1675 refresh_check ();
1676}
1677
1678#endif /* HAVE_BG_PIXMAP */
1679 1700
1680/*----------------------- end-of-file (C source) -----------------------*/ 1701/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines