1 | /*--------------------------------*-C-*---------------------------------*; |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: main.c |
2 | * File: main.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
44 | # include <termios.h> |
44 | # include <termios.h> |
45 | #endif |
45 | #endif |
46 | |
46 | |
47 | #include <cstring> |
47 | #include <cstring> |
48 | |
48 | |
|
|
49 | vector<rxvt_term *> rxvt_term::termlist; |
|
|
50 | |
49 | static char curlocale[128]; |
51 | static char curlocale[128]; |
50 | |
52 | |
51 | void |
53 | bool |
52 | rxvt_set_locale (const char *locale) |
54 | rxvt_set_locale (const char *locale) |
53 | { |
55 | { |
54 | if (locale && STRNCMP (locale, curlocale, 128)) |
56 | if (!locale || !STRNCMP (locale, curlocale, 128)) |
55 | { |
57 | return false; |
|
|
58 | |
56 | STRNCPY (curlocale, locale, 128); |
59 | STRNCPY (curlocale, locale, 128); |
57 | setlocale (LC_CTYPE, curlocale); |
60 | setlocale (LC_CTYPE, curlocale); |
58 | } |
61 | return true; |
59 | } |
62 | } |
60 | |
63 | |
61 | #if ENABLE_COMBINING |
64 | #if ENABLE_COMBINING |
62 | class rxvt_composite_vec rxvt_composite; |
65 | class rxvt_composite_vec rxvt_composite; |
63 | |
66 | |
64 | text_t rxvt_composite_vec::compose (uint32_t c1, uint32_t c2) |
67 | text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) |
65 | { |
68 | { |
66 | compose_char *cc; |
69 | compose_char *cc; |
67 | |
70 | |
68 | // break compose chains, as stupid readline really likes to duplicate |
71 | // break compose chains, as stupid readline really likes to duplicate |
69 | // composing characters for some reason near the end of a line. |
72 | // composing characters for some reason near the end of a line. |
… | |
… | |
95 | v.push_back (compose_char (c1, c2)); |
98 | v.push_back (compose_char (c1, c2)); |
96 | |
99 | |
97 | return v.size () - 1 + COMPOSE_LO; |
100 | return v.size () - 1 + COMPOSE_LO; |
98 | } |
101 | } |
99 | |
102 | |
100 | int rxvt_composite_vec::expand (uint32_t c, wchar_t *r) |
103 | int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) |
101 | { |
104 | { |
102 | compose_char *cc = (*this)[c]; |
105 | compose_char *cc = (*this)[c]; |
103 | |
106 | |
104 | if (!cc) |
107 | if (!cc) |
105 | { |
108 | { |
… | |
… | |
152 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
155 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
153 | #endif |
156 | #endif |
154 | #ifdef TEXT_BLINK |
157 | #ifdef TEXT_BLINK |
155 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
158 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
156 | #endif |
159 | #endif |
|
|
160 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
161 | cont_scroll_ev (this, &rxvt_term::cont_scroll_cb), |
|
|
162 | #endif |
|
|
163 | #ifdef SELECTION_SCROLLING |
|
|
164 | sel_scroll_ev (this, &rxvt_term::sel_scroll_cb), |
|
|
165 | #endif |
|
|
166 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
167 | slip_wheel_ev (this, &rxvt_term::slip_wheel_cb), |
|
|
168 | #endif |
157 | #ifdef POINTER_BLANK |
169 | #ifdef POINTER_BLANK |
158 | pointer_ev (this, &rxvt_term::pointer_cb), |
170 | pointer_ev (this, &rxvt_term::pointer_cb), |
159 | #endif |
171 | #endif |
160 | #ifdef USE_XIM |
172 | #ifdef USE_XIM |
161 | im_ev (this, &rxvt_term::im_cb), |
173 | im_ev (this, &rxvt_term::im_cb), |
… | |
… | |
164 | destroy_ev (this, &rxvt_term::destroy_cb), |
176 | destroy_ev (this, &rxvt_term::destroy_cb), |
165 | pty_ev (this, &rxvt_term::pty_cb), |
177 | pty_ev (this, &rxvt_term::pty_cb), |
166 | incr_ev (this, &rxvt_term::incr_cb) |
178 | incr_ev (this, &rxvt_term::incr_cb) |
167 | { |
179 | { |
168 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
180 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
181 | |
|
|
182 | termlist.push_back (this); |
169 | } |
183 | } |
170 | |
184 | |
171 | rxvt_term::~rxvt_term () |
185 | rxvt_term::~rxvt_term () |
172 | { |
186 | { |
|
|
187 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
188 | |
173 | if (cmd_fd >= 0) |
189 | if (cmd_fd >= 0) |
174 | close (cmd_fd); |
190 | close (cmd_fd); |
175 | |
191 | |
176 | #ifndef NO_SETOWNER_TTYDEV |
192 | #ifndef NO_SETOWNER_TTYDEV |
177 | privileged_ttydev (RESTORE); |
193 | privileged_ttydev (RESTORE); |
… | |
… | |
182 | |
198 | |
183 | delete TermWin.fontset; |
199 | delete TermWin.fontset; |
184 | |
200 | |
185 | if (display) |
201 | if (display) |
186 | { |
202 | { |
|
|
203 | selection_clear (); |
|
|
204 | |
|
|
205 | #ifdef MENUBAR |
|
|
206 | if (menubarGC) XFreeGC (display->display, menubarGC); |
|
|
207 | #endif |
|
|
208 | #ifdef XTERM_SCROLLBAR |
|
|
209 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
|
|
210 | if (ShadowGC) XFreeGC (display->display, ShadowGC); |
|
|
211 | #endif |
|
|
212 | #ifdef PLAIN_SCROLLBAR |
|
|
213 | if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); |
|
|
214 | #endif |
|
|
215 | #ifdef NEXT_SCROLLBAR |
|
|
216 | if (blackGC) XFreeGC (display->display, blackGC); |
|
|
217 | if (whiteGC) XFreeGC (display->display, whiteGC); |
|
|
218 | if (grayGC) XFreeGC (display->display, grayGC); |
|
|
219 | if (darkGC) XFreeGC (display->display, darkGC); |
|
|
220 | if (stippleGC) XFreeGC (display->display, stippleGC); |
|
|
221 | if (dimple) XFreePixmap (display->display, dimple); |
|
|
222 | if (upArrow) XFreePixmap (display->display, upArrow); |
|
|
223 | if (downArrow) XFreePixmap (display->display, downArrow); |
|
|
224 | if (upArrowHi) XFreePixmap (display->display, upArrowHi); |
|
|
225 | if (downArrowHi) XFreePixmap (display->display, downArrowHi); |
|
|
226 | #endif |
|
|
227 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
|
|
228 | if (topShadowGC) XFreeGC (display->display, topShadowGC); |
|
|
229 | if (botShadowGC) XFreeGC (display->display, botShadowGC); |
|
|
230 | if (scrollbarGC) XFreeGC (display->display, scrollbarGC); |
|
|
231 | #endif |
|
|
232 | if (TermWin.gc) XFreeGC (display->display, TermWin.gc); |
|
|
233 | |
187 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
234 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
188 | delete menuBar.drawable; |
235 | delete menuBar.drawable; |
189 | //if (menuBar.win) |
236 | //if (menuBar.win) |
190 | // XDestroyWindow (display->display, menuBar.win); |
237 | // XDestroyWindow (display->display, menuBar.win); |
191 | #endif |
238 | #endif |
… | |
… | |
201 | |
248 | |
202 | displays.put (display); |
249 | displays.put (display); |
203 | |
250 | |
204 | scr_release (); |
251 | scr_release (); |
205 | |
252 | |
|
|
253 | /* clear all resources */ |
|
|
254 | for (int i = 0; i < allocated.size (); i++) |
|
|
255 | free (allocated[i]); |
|
|
256 | |
|
|
257 | free (selection.text); |
|
|
258 | // TODO: manage env vars in child only(!) |
206 | free (env_windowid); |
259 | free (env_windowid); |
207 | free (env_display); |
260 | free (env_display); |
208 | free (env_term); |
261 | free (env_term); |
209 | free (env_colorfgbg); |
262 | free (env_colorfgbg); |
210 | free (locale); |
263 | free (locale); |
|
|
264 | #if 0 |
211 | free (codeset); |
265 | free (codeset); |
|
|
266 | #endif |
212 | |
267 | |
213 | delete envv; |
268 | delete envv; |
214 | delete argv; |
269 | delete argv; |
215 | } |
270 | } |
216 | |
271 | |
… | |
… | |
240 | cursor_blink_ev.stop (); |
295 | cursor_blink_ev.stop (); |
241 | #endif |
296 | #endif |
242 | #ifdef TEXT_BLINK |
297 | #ifdef TEXT_BLINK |
243 | text_blink_ev.stop (); |
298 | text_blink_ev.stop (); |
244 | #endif |
299 | #endif |
|
|
300 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
301 | cont_scroll_ev.stop (); |
|
|
302 | #endif |
|
|
303 | #ifdef SELECTION_SCROLLING |
|
|
304 | sel_scroll_ev.stop (); |
|
|
305 | #endif |
245 | #ifdef POINTER_BLANK |
306 | #ifdef POINTER_BLANK |
246 | pointer_ev.stop (); |
307 | pointer_ev.stop (); |
247 | #endif |
308 | #endif |
248 | |
309 | |
249 | destroy_ev.start (0); |
310 | destroy_ev.start (0); |
… | |
… | |
257 | delete this; |
318 | delete this; |
258 | } |
319 | } |
259 | |
320 | |
260 | /*----------------------------------------------------------------------*/ |
321 | /*----------------------------------------------------------------------*/ |
261 | /* rxvt_init () */ |
322 | /* rxvt_init () */ |
262 | /* LIBPROTO */ |
|
|
263 | rxvt_t |
|
|
264 | rxvt_init (int argc, const char *const *argv) |
|
|
265 | { |
|
|
266 | SET_R (new rxvt_term); |
|
|
267 | |
|
|
268 | if (!GET_R->init_vars () || !GET_R->init (argc, argv)) |
|
|
269 | { |
|
|
270 | delete GET_R; |
|
|
271 | SET_R (0); |
|
|
272 | } |
|
|
273 | |
|
|
274 | return GET_R; |
|
|
275 | } |
|
|
276 | |
|
|
277 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
278 | |
|
|
279 | void |
|
|
280 | rxvt_init_signals () |
|
|
281 | { |
|
|
282 | /* install exit handler for cleanup */ |
|
|
283 | #if 0 |
|
|
284 | #ifdef HAVE_ATEXIT |
|
|
285 | atexit (rxvt_clean_exit); |
|
|
286 | #else |
|
|
287 | #endif |
|
|
288 | #endif |
|
|
289 | |
|
|
290 | struct sigaction sa; |
|
|
291 | |
|
|
292 | sigfillset (&sa.sa_mask); |
|
|
293 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
294 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
295 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
296 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
297 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
298 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
299 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
300 | |
|
|
301 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
302 | /* signal (SIGURG, SIG_DFL); */ |
|
|
303 | |
|
|
304 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
305 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
306 | } |
|
|
307 | |
|
|
308 | bool |
323 | bool |
309 | rxvt_term::init (int argc, const char *const *argv) |
324 | rxvt_term::init (int argc, const char *const *argv) |
310 | { |
325 | { |
|
|
326 | SET_R (this); |
|
|
327 | |
|
|
328 | if (!init_vars ()) |
|
|
329 | return false; |
|
|
330 | |
311 | /* |
331 | /* |
312 | * Save and then give up any super-user privileges |
332 | * Save and then give up any super-user privileges |
313 | * If we need privileges in any area then we must specifically request it. |
333 | * If we need privileges in any area then we must specifically request it. |
314 | * We should only need to be root in these cases: |
334 | * We should only need to be root in these cases: |
315 | * 1. write utmp entries on some systems |
335 | * 1. write utmp entries on some systems |
… | |
… | |
370 | check_ev.start (); |
390 | check_ev.start (); |
371 | |
391 | |
372 | return true; |
392 | return true; |
373 | } |
393 | } |
374 | |
394 | |
|
|
395 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
396 | |
|
|
397 | void |
|
|
398 | rxvt_init_signals () |
|
|
399 | { |
|
|
400 | /* install exit handler for cleanup */ |
|
|
401 | #if 0 |
|
|
402 | #ifdef HAVE_ATEXIT |
|
|
403 | atexit (rxvt_clean_exit); |
|
|
404 | #else |
|
|
405 | #endif |
|
|
406 | #endif |
|
|
407 | |
|
|
408 | struct sigaction sa; |
|
|
409 | |
|
|
410 | sigfillset (&sa.sa_mask); |
|
|
411 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
412 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
413 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
414 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
415 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
416 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
417 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
418 | |
|
|
419 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
420 | /* signal (SIGURG, SIG_DFL); */ |
|
|
421 | |
|
|
422 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
423 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
424 | } |
|
|
425 | |
375 | /* ------------------------------------------------------------------------- * |
426 | /* ------------------------------------------------------------------------- * |
376 | * SIGNAL HANDLING & EXIT HANDLER * |
427 | * SIGNAL HANDLING & EXIT HANDLER * |
377 | * ------------------------------------------------------------------------- */ |
428 | * ------------------------------------------------------------------------- */ |
378 | /* |
429 | /* |
379 | * Catch a SIGCHLD signal and exit if the direct child has died |
430 | * Catch a SIGCHLD signal and exit if the direct child has died |
380 | */ |
431 | */ |
|
|
432 | |
|
|
433 | void rxvt_term::child_exited (int pid) |
|
|
434 | { |
|
|
435 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
436 | if (pid == (*t)->cmd_pid) |
|
|
437 | { |
|
|
438 | (*t)->destroy (); |
|
|
439 | break; |
|
|
440 | } |
|
|
441 | } |
|
|
442 | |
381 | /* ARGSUSED */ |
443 | /* ARGSUSED */ |
382 | /* EXTPROTO */ |
444 | /* EXTPROTO */ |
383 | RETSIGTYPE |
445 | RETSIGTYPE |
384 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
446 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
385 | { |
447 | { |
386 | int pid, save_errno = errno; |
448 | int pid, save_errno = errno; |
|
|
449 | |
387 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
450 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
388 | ; |
451 | rxvt_term::child_exited (pid); |
|
|
452 | |
389 | errno = save_errno; |
453 | errno = save_errno; |
390 | |
|
|
391 | #if 0 |
|
|
392 | if (pid == cmd_pid) |
|
|
393 | exit (EXIT_SUCCESS); |
|
|
394 | #endif |
|
|
395 | } |
454 | } |
396 | |
455 | |
397 | /* |
456 | /* |
398 | * Catch a fatal signal and tidy up before quitting |
457 | * Catch a fatal signal and tidy up before quitting |
399 | */ |
458 | */ |
… | |
… | |
401 | RETSIGTYPE |
460 | RETSIGTYPE |
402 | rxvt_Exit_signal (int sig) |
461 | rxvt_Exit_signal (int sig) |
403 | { |
462 | { |
404 | signal (sig, SIG_DFL); |
463 | signal (sig, SIG_DFL); |
405 | #ifdef DEBUG_CMD |
464 | #ifdef DEBUG_CMD |
406 | rxvt_print_error ("signal %d", sig); |
465 | rxvt_warn ("caught signal %d, exiting.\n", sig); |
407 | #endif |
466 | #endif |
408 | rxvt_clean_exit (); |
467 | rxvt_clean_exit (); |
409 | kill (getpid (), sig); |
468 | kill (getpid (), sig); |
410 | } |
469 | } |
411 | |
470 | |
… | |
… | |
696 | max_height = MAX_ROWS * TermWin.fheight; |
755 | max_height = MAX_ROWS * TermWin.fheight; |
697 | |
756 | |
698 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
757 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
699 | |
758 | |
700 | sb_w = mb_h = 0; |
759 | sb_w = mb_h = 0; |
701 | window_vt_x = window_vt_y = 0; |
760 | window_vt_x = window_vt_y = TermWin.int_bwidth; |
|
|
761 | |
702 | if (scrollbar_visible ()) |
762 | if (scrollbar_visible ()) |
703 | { |
763 | { |
704 | sb_w = scrollbar_TotalWidth (); |
764 | sb_w = scrollbar_TotalWidth (); |
705 | szHint.base_width += sb_w; |
765 | szHint.base_width += sb_w; |
706 | if (! (Options & Opt_scrollBar_right)) |
766 | if (!(Options & Opt_scrollBar_right)) |
707 | window_vt_x = sb_w; |
767 | window_vt_x += sb_w; |
708 | } |
768 | } |
|
|
769 | |
709 | if (menubar_visible ()) |
770 | if (menubar_visible ()) |
710 | { |
771 | { |
711 | mb_h = menuBar_TotalHeight (); |
772 | mb_h = menuBar_TotalHeight (); |
712 | szHint.base_height += mb_h; |
773 | szHint.base_height += mb_h; |
713 | window_vt_y = mb_h; |
774 | window_vt_y += mb_h; |
714 | } |
775 | } |
|
|
776 | |
715 | szHint.width_inc = TermWin.fwidth; |
777 | szHint.width_inc = TermWin.fwidth; |
716 | szHint.height_inc = TermWin.fheight; |
778 | szHint.height_inc = TermWin.fheight; |
717 | szHint.min_width = szHint.base_width + szHint.width_inc; |
779 | szHint.min_width = szHint.base_width + szHint.width_inc; |
718 | szHint.min_height = szHint.base_height + szHint.height_inc; |
780 | szHint.min_height = szHint.base_height + szHint.height_inc; |
719 | |
781 | |
… | |
… | |
725 | else |
787 | else |
726 | { |
788 | { |
727 | MIN_IT (TermWin.width, max_width); |
789 | MIN_IT (TermWin.width, max_width); |
728 | szHint.width = szHint.base_width + TermWin.width; |
790 | szHint.width = szHint.base_width + TermWin.width; |
729 | } |
791 | } |
|
|
792 | |
730 | if (height && height - szHint.base_height < max_height) |
793 | if (height && height - szHint.base_height < max_height) |
731 | { |
794 | { |
732 | szHint.height = height; |
795 | szHint.height = height; |
733 | TermWin.height = height - szHint.base_height; |
796 | TermWin.height = height - szHint.base_height; |
734 | } |
797 | } |
735 | else |
798 | else |
736 | { |
799 | { |
737 | MIN_IT (TermWin.height, max_height); |
800 | MIN_IT (TermWin.height, max_height); |
738 | szHint.height = szHint.base_height + TermWin.height; |
801 | szHint.height = szHint.base_height + TermWin.height; |
739 | } |
802 | } |
|
|
803 | |
740 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
804 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
741 | window_sb_x = szHint.width - sb_w; |
805 | window_sb_x = szHint.width - sb_w; |
742 | |
806 | |
743 | if (recalc_x) |
807 | if (recalc_x) |
744 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
808 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
… | |
… | |
838 | /*----------------------------------------------------------------------*/ |
902 | /*----------------------------------------------------------------------*/ |
839 | /* xterm sequences - title, iconName, color (exptl) */ |
903 | /* xterm sequences - title, iconName, color (exptl) */ |
840 | void |
904 | void |
841 | rxvt_term::set_title (const char *str) |
905 | rxvt_term::set_title (const char *str) |
842 | { |
906 | { |
843 | #ifndef SMART_WINDOW_TITLE |
907 | #ifdef SMART_WINDOW_TITLE |
844 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
845 | #else |
|
|
846 | char *name; |
908 | char *name; |
847 | |
909 | |
848 | if (XFetchName (display->display, TermWin.parent[0], &name) == 0) |
910 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
849 | name = NULL; |
911 | name = NULL; |
|
|
912 | |
850 | if (name == NULL || STRCMP (name, str)) |
913 | if (name == NULL || STRCMP (name, str)) |
|
|
914 | #endif |
851 | XStoreName (display->display, TermWin.parent[0], str); |
915 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
916 | |
|
|
917 | #ifdef SMART_WINDOW_TITLE |
852 | if (name) |
918 | if (name) |
853 | XFree (name); |
919 | XFree (name); |
854 | #endif |
920 | #endif |
855 | } |
921 | } |
856 | |
922 | |
857 | void |
923 | void |
858 | rxvt_term::set_iconName (const char *str) |
924 | rxvt_term::set_icon_name (const char *str) |
859 | { |
925 | { |
860 | #ifndef SMART_WINDOW_TITLE |
926 | #ifdef SMART_WINDOW_TITLE |
861 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
862 | #else |
|
|
863 | char *name; |
927 | char *name; |
864 | |
928 | |
865 | if (XGetIconName (display->display, TermWin.parent[0], &name)) |
929 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
866 | name = NULL; |
930 | name = NULL; |
|
|
931 | |
867 | if (name == NULL || STRCMP (name, str)) |
932 | if (name == NULL || STRCMP (name, str)) |
|
|
933 | #endif |
868 | XSetIconName (display->display, TermWin.parent[0], str); |
934 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
935 | |
|
|
936 | #ifdef SMART_WINDOW_TITLE |
869 | if (name) |
937 | if (name) |
870 | XFree (name); |
938 | XFree (name); |
871 | #endif |
939 | #endif |
872 | } |
940 | } |
873 | |
941 | |
… | |
… | |
900 | PixColors[idx] = PixColors[minCOLOR + i]; |
968 | PixColors[idx] = PixColors[minCOLOR + i]; |
901 | SET_PIXCOLOR (idx); |
969 | SET_PIXCOLOR (idx); |
902 | goto Done; |
970 | goto Done; |
903 | } |
971 | } |
904 | } |
972 | } |
|
|
973 | |
905 | if (!rXParseAllocColor (& xcol, color)) |
974 | if (!rXParseAllocColor (& xcol, color)) |
906 | return; |
975 | return; |
|
|
976 | |
907 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
977 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
908 | |
978 | |
909 | /* |
979 | /* |
910 | * FIXME: should free colors here, but no idea how to do it so instead, |
980 | * FIXME: should free colors here, but no idea how to do it so instead, |
911 | * so just keep gobbling up the colormap |
981 | * so just keep gobbling up the colormap |
… | |
… | |
934 | |
1004 | |
935 | /* handle Color_BD, scrollbar background, etc. */ |
1005 | /* handle Color_BD, scrollbar background, etc. */ |
936 | |
1006 | |
937 | set_colorfgbg (); |
1007 | set_colorfgbg (); |
938 | recolour_cursor (); |
1008 | recolour_cursor (); |
939 | /* the only reasonable way to enforce a clean update */ |
1009 | scr_touch (true); |
940 | scr_poweron (); |
|
|
941 | } |
1010 | } |
942 | |
1011 | |
943 | #else |
1012 | #else |
944 | # define set_window_color (idx,color) ((void)0) |
1013 | # define set_window_color (idx,color) ((void)0) |
945 | #endif /* XTERM_COLOR_CHANGE */ |
1014 | #endif /* XTERM_COLOR_CHANGE */ |
946 | |
1015 | |
947 | void |
1016 | void |
948 | rxvt_term::recolour_cursor () |
1017 | rxvt_term::recolour_cursor () |
949 | { |
1018 | { |
950 | #if TODO |
|
|
951 | rxvt_color xcol[2]; |
1019 | XColor xcol[2]; |
952 | |
1020 | |
953 | xcol[0] = PixColors[Color_pointer]; |
1021 | xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg]; |
954 | xcol[1] = PixColors[Color_bg]; |
1022 | xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg]; |
955 | XQueryColors (display->display, XCMAP, xcol, 2); |
1023 | XQueryColors (display->display, XCMAP, xcol, 2); |
956 | XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); |
1024 | XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); |
957 | #endif |
|
|
958 | } |
1025 | } |
959 | |
1026 | |
960 | /*----------------------------------------------------------------------*/ |
1027 | /*----------------------------------------------------------------------*/ |
961 | /* |
1028 | /* |
962 | * find if fg/bg matches any of the normal (low-intensity) colors |
1029 | * find if fg/bg matches any of the normal (low-intensity) colors |
… | |
… | |
1011 | int |
1078 | int |
1012 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1079 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1013 | { |
1080 | { |
1014 | if (!screen_in_out->set (display, colour)) |
1081 | if (!screen_in_out->set (display, colour)) |
1015 | { |
1082 | { |
1016 | rxvt_print_error ("can't allocate colour: %s", colour); |
1083 | rxvt_warn ("can't get colour '%s', continuing without.\n", colour); |
1017 | return false; |
1084 | return false; |
1018 | } |
1085 | } |
1019 | |
1086 | |
1020 | return true; |
1087 | return true; |
1021 | } |
1088 | } |
… | |
… | |
1032 | int old_width = szHint.width, old_height = szHint.height; |
1099 | int old_width = szHint.width, old_height = szHint.height; |
1033 | #endif |
1100 | #endif |
1034 | |
1101 | |
1035 | window_calc (width, height); |
1102 | window_calc (width, height); |
1036 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1103 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
|
|
1104 | |
1037 | if (!ignoreparent) |
1105 | if (!ignoreparent) |
1038 | { |
1106 | { |
1039 | #ifdef SMART_RESIZE |
1107 | #ifdef SMART_RESIZE |
1040 | /* |
1108 | /* |
1041 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
1109 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
… | |
… | |
1076 | dy /= 2; |
1144 | dy /= 2; |
1077 | |
1145 | |
1078 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1146 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1079 | szHint.width, szHint.height); |
1147 | szHint.width, szHint.height); |
1080 | #else |
1148 | #else |
1081 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, |
1149 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
1082 | szHint.height); |
|
|
1083 | #endif |
1150 | #endif |
1084 | |
|
|
1085 | } |
1151 | } |
1086 | |
1152 | |
1087 | fix_screen = (TermWin.ncol != prev_ncol |
1153 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1088 | || TermWin.nrow != prev_nrow); |
|
|
1089 | |
1154 | |
1090 | if (fix_screen || width != old_width || height != old_height) |
1155 | if (fix_screen || width != old_width || height != old_height) |
1091 | { |
1156 | { |
1092 | if (scrollbar_visible ()) |
1157 | if (scrollbar_visible ()) |
1093 | { |
1158 | { |
1094 | XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, |
1159 | XMoveResizeWindow (display->display, scrollBar.win, |
|
|
1160 | window_sb_x, 0, |
1095 | 0, scrollbar_TotalWidth (), szHint.height); |
1161 | scrollbar_TotalWidth (), szHint.height); |
1096 | resize_scrollbar (); |
1162 | resize_scrollbar (); |
1097 | } |
1163 | } |
1098 | |
1164 | |
1099 | if (menubar_visible ()) |
1165 | if (menubar_visible ()) |
1100 | XMoveResizeWindow (display->display, menuBar.win, window_vt_x, |
1166 | XMoveResizeWindow (display->display, menuBar.win, |
|
|
1167 | window_vt_x, 0, |
1101 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1168 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1102 | |
1169 | |
1103 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
1170 | XMoveResizeWindow (display->display, TermWin.vt, |
1104 | window_vt_y, TermWin_TotalWidth (), |
1171 | window_vt_x, window_vt_y, |
1105 | TermWin_TotalHeight ()); |
1172 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1106 | scr_clear (height != old_height); |
1173 | scr_clear (); |
1107 | #ifdef XPM_BACKGROUND |
1174 | #ifdef XPM_BACKGROUND |
1108 | resize_pixmap (); |
1175 | resize_pixmap (); |
1109 | #endif |
1176 | #endif |
1110 | |
|
|
1111 | } |
1177 | } |
1112 | |
1178 | |
1113 | if (fix_screen || old_height == 0) |
1179 | if (fix_screen || old_height == 0) |
1114 | { |
1180 | { |
1115 | int curr_screen = -1; |
1181 | int curr_screen = -1; |
… | |
… | |
1388 | if (preedit_attr) XFree (preedit_attr); |
1454 | if (preedit_attr) XFree (preedit_attr); |
1389 | if (status_attr) XFree (status_attr); |
1455 | if (status_attr) XFree (status_attr); |
1390 | |
1456 | |
1391 | if (Input_Context == NULL) |
1457 | if (Input_Context == NULL) |
1392 | { |
1458 | { |
1393 | rxvt_print_error ("failed to create input context"); |
1459 | rxvt_warn ("failed to create input context, continuing without XIM.\n"); |
1394 | display->put_xim (input_method); |
1460 | display->put_xim (input_method); |
1395 | return false; |
1461 | return false; |
1396 | } |
1462 | } |
1397 | |
1463 | |
1398 | if (input_style & XIMPreeditArea) |
1464 | if (input_style & XIMPreeditArea) |