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 | |
… | |
… | |
137 | free (p); |
140 | free (p); |
138 | } |
141 | } |
139 | |
142 | |
140 | rxvt_term::rxvt_term () |
143 | rxvt_term::rxvt_term () |
141 | : |
144 | : |
|
|
145 | #if TRANSPARENT |
142 | rootwin_ev (this, &rxvt_term::rootwin_cb), |
146 | rootwin_ev (this, &rxvt_term::rootwin_cb), |
|
|
147 | #endif |
|
|
148 | #ifdef HAVE_SCROLLBARS |
|
|
149 | scrollbar_ev (this, &rxvt_term::x_cb), |
|
|
150 | #endif |
|
|
151 | #ifdef MENUBAR |
|
|
152 | menubar_ev (this, &rxvt_term::x_cb), |
|
|
153 | #endif |
|
|
154 | #ifdef CURSOR_BLINK |
|
|
155 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
|
|
156 | #endif |
|
|
157 | #ifdef TEXT_BLINK |
|
|
158 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
|
|
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 |
|
|
169 | #ifdef POINTER_BLANK |
|
|
170 | pointer_ev (this, &rxvt_term::pointer_cb), |
|
|
171 | #endif |
|
|
172 | #ifdef USE_XIM |
|
|
173 | im_ev (this, &rxvt_term::im_cb), |
|
|
174 | #endif |
143 | termwin_ev (this, &rxvt_term::x_cb), |
175 | termwin_ev (this, &rxvt_term::x_cb), |
144 | vt_ev (this, &rxvt_term::x_cb), |
176 | vt_ev (this, &rxvt_term::x_cb), |
145 | #ifdef HAVE_SCROLLBARS |
|
|
146 | scrollbar_ev (this, &rxvt_term::x_cb), |
|
|
147 | #endif |
|
|
148 | #ifdef MENUBAR |
|
|
149 | menubar_ev (this, &rxvt_term::x_cb), |
|
|
150 | #endif |
|
|
151 | #ifdef CURSOR_BLINK |
|
|
152 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
|
|
153 | #endif |
|
|
154 | #ifdef TEXT_BLINK |
|
|
155 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
|
|
156 | #endif |
|
|
157 | #ifdef POINTER_BLANK |
|
|
158 | pointer_ev (this, &rxvt_term::pointer_cb), |
|
|
159 | #endif |
|
|
160 | #ifdef USE_XIM |
|
|
161 | im_ev (this, &rxvt_term::im_cb), |
|
|
162 | #endif |
|
|
163 | check_ev (this, &rxvt_term::check_cb), |
177 | check_ev (this, &rxvt_term::check_cb), |
|
|
178 | flush_ev (this, &rxvt_term::flush_cb), |
164 | destroy_ev (this, &rxvt_term::destroy_cb), |
179 | destroy_ev (this, &rxvt_term::destroy_cb), |
165 | pty_ev (this, &rxvt_term::pty_cb), |
180 | pty_ev (this, &rxvt_term::pty_cb), |
166 | incr_ev (this, &rxvt_term::incr_cb) |
181 | incr_ev (this, &rxvt_term::incr_cb) |
167 | { |
182 | { |
168 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
183 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
184 | |
|
|
185 | termlist.push_back (this); |
169 | } |
186 | } |
170 | |
187 | |
171 | rxvt_term::~rxvt_term () |
188 | rxvt_term::~rxvt_term () |
172 | { |
189 | { |
|
|
190 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
191 | |
173 | if (cmd_fd >= 0) |
192 | if (cmd_fd >= 0) |
174 | close (cmd_fd); |
193 | close (cmd_fd); |
175 | |
194 | |
176 | #ifndef NO_SETOWNER_TTYDEV |
195 | #ifndef NO_SETOWNER_TTYDEV |
177 | privileged_ttydev (RESTORE); |
196 | privileged_ttydev (RESTORE); |
… | |
… | |
184 | |
203 | |
185 | if (display) |
204 | if (display) |
186 | { |
205 | { |
187 | selection_clear (); |
206 | selection_clear (); |
188 | |
207 | |
|
|
208 | #ifdef USE_XIM |
|
|
209 | im_destroy (); |
|
|
210 | #endif |
189 | #ifdef MENUBAR |
211 | #ifdef MENUBAR |
190 | if (menubarGC) XFreeGC (display->display, menubarGC); |
212 | if (menubarGC) XFreeGC (display->display, menubarGC); |
191 | #endif |
213 | #endif |
192 | #ifdef XTERM_SCROLLBAR |
214 | #ifdef XTERM_SCROLLBAR |
193 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
215 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
… | |
… | |
226 | XDestroyWindow (display->display, TermWin.parent[0]); |
248 | XDestroyWindow (display->display, TermWin.parent[0]); |
227 | } |
249 | } |
228 | |
250 | |
229 | // TODO: free pixcolours, colours should become part of rxvt_display |
251 | // TODO: free pixcolours, colours should become part of rxvt_display |
230 | |
252 | |
231 | delete PixColors; |
253 | delete PixColorsFocused; |
|
|
254 | #ifdef OFF_FOCUS_FADING |
|
|
255 | delete PixColorsUnFocused; |
|
|
256 | #endif |
232 | |
257 | |
233 | displays.put (display); |
258 | displays.put (display); |
234 | |
259 | |
235 | scr_release (); |
260 | scr_release (); |
236 | |
261 | |
… | |
… | |
254 | } |
279 | } |
255 | |
280 | |
256 | void |
281 | void |
257 | rxvt_term::destroy () |
282 | rxvt_term::destroy () |
258 | { |
283 | { |
|
|
284 | if (destroy_ev.active) |
|
|
285 | return; |
|
|
286 | |
259 | if (display) |
287 | if (display) |
260 | { |
288 | { |
|
|
289 | #if USE_XIM |
|
|
290 | im_ev.stop (display); |
|
|
291 | #endif |
|
|
292 | #if HAVE_SCROLLBARS |
|
|
293 | scrollbar_ev.stop (display); |
|
|
294 | #endif |
|
|
295 | #if MENUBAR |
|
|
296 | menubar_ev.stop (display); |
|
|
297 | #endif |
|
|
298 | #if TRANSPARENT |
261 | rootwin_ev.stop (display); |
299 | rootwin_ev.stop (display); |
|
|
300 | #endif |
|
|
301 | incr_ev.stop (); |
262 | termwin_ev.stop (display); |
302 | termwin_ev.stop (display); |
263 | vt_ev.stop (display); |
303 | vt_ev.stop (display); |
264 | #ifdef USE_XIM |
|
|
265 | im_destroy (); |
|
|
266 | im_ev.stop (display); |
|
|
267 | #endif |
|
|
268 | #ifdef HAVE_SCROLLBARS |
|
|
269 | scrollbar_ev.stop (display); |
|
|
270 | #endif |
|
|
271 | #ifdef MENUBAR |
|
|
272 | menubar_ev.stop (display); |
|
|
273 | #endif |
|
|
274 | } |
304 | } |
275 | |
305 | |
276 | check_ev.stop (); |
306 | check_ev.stop (); |
277 | pty_ev.stop (); |
307 | pty_ev.stop (); |
278 | #ifdef CURSOR_BLINK |
308 | #ifdef CURSOR_BLINK |
279 | cursor_blink_ev.stop (); |
309 | cursor_blink_ev.stop (); |
280 | #endif |
310 | #endif |
281 | #ifdef TEXT_BLINK |
311 | #ifdef TEXT_BLINK |
282 | text_blink_ev.stop (); |
312 | text_blink_ev.stop (); |
|
|
313 | #endif |
|
|
314 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
315 | cont_scroll_ev.stop (); |
|
|
316 | #endif |
|
|
317 | #ifdef SELECTION_SCROLLING |
|
|
318 | sel_scroll_ev.stop (); |
283 | #endif |
319 | #endif |
284 | #ifdef POINTER_BLANK |
320 | #ifdef POINTER_BLANK |
285 | pointer_ev.stop (); |
321 | pointer_ev.stop (); |
286 | #endif |
322 | #endif |
287 | |
323 | |
… | |
… | |
351 | #ifdef TRANSPARENT |
387 | #ifdef TRANSPARENT |
352 | if (Options & Opt_transparent) |
388 | if (Options & Opt_transparent) |
353 | { |
389 | { |
354 | XSelectInput (display->display, display->root, PropertyChangeMask); |
390 | XSelectInput (display->display, display->root, PropertyChangeMask); |
355 | check_our_parents (); |
391 | check_our_parents (); |
356 | } |
|
|
357 | #endif |
|
|
358 | |
|
|
359 | rootwin_ev.start (display, display->root); |
392 | rootwin_ev.start (display, display->root); |
|
|
393 | } |
|
|
394 | #endif |
360 | |
395 | |
361 | XMapWindow (display->display, TermWin.vt); |
396 | XMapWindow (display->display, TermWin.vt); |
362 | XMapWindow (display->display, TermWin.parent[0]); |
397 | XMapWindow (display->display, TermWin.parent[0]); |
363 | |
398 | |
364 | init_command (cmd_argv); |
399 | init_command (cmd_argv); |
… | |
… | |
405 | * SIGNAL HANDLING & EXIT HANDLER * |
440 | * SIGNAL HANDLING & EXIT HANDLER * |
406 | * ------------------------------------------------------------------------- */ |
441 | * ------------------------------------------------------------------------- */ |
407 | /* |
442 | /* |
408 | * Catch a SIGCHLD signal and exit if the direct child has died |
443 | * Catch a SIGCHLD signal and exit if the direct child has died |
409 | */ |
444 | */ |
|
|
445 | |
|
|
446 | void rxvt_term::child_exited (int pid) |
|
|
447 | { |
|
|
448 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
449 | if (pid == (*t)->cmd_pid) |
|
|
450 | { |
|
|
451 | (*t)->destroy (); |
|
|
452 | break; |
|
|
453 | } |
|
|
454 | } |
|
|
455 | |
410 | /* ARGSUSED */ |
456 | /* ARGSUSED */ |
411 | /* EXTPROTO */ |
457 | /* EXTPROTO */ |
412 | RETSIGTYPE |
458 | RETSIGTYPE |
413 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
459 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
414 | { |
460 | { |
415 | int pid, save_errno = errno; |
461 | int pid, save_errno = errno; |
|
|
462 | |
416 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
463 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
417 | ; |
464 | rxvt_term::child_exited (pid); |
|
|
465 | |
418 | errno = save_errno; |
466 | errno = save_errno; |
419 | |
|
|
420 | #if 0 |
|
|
421 | if (pid == cmd_pid) |
|
|
422 | exit (EXIT_SUCCESS); |
|
|
423 | #endif |
|
|
424 | } |
467 | } |
425 | |
468 | |
426 | /* |
469 | /* |
427 | * Catch a fatal signal and tidy up before quitting |
470 | * Catch a fatal signal and tidy up before quitting |
428 | */ |
471 | */ |
… | |
… | |
725 | max_height = MAX_ROWS * TermWin.fheight; |
768 | max_height = MAX_ROWS * TermWin.fheight; |
726 | |
769 | |
727 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
770 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
728 | |
771 | |
729 | sb_w = mb_h = 0; |
772 | sb_w = mb_h = 0; |
730 | window_vt_x = window_vt_y = 0; |
773 | window_vt_x = window_vt_y = TermWin.int_bwidth; |
|
|
774 | |
731 | if (scrollbar_visible ()) |
775 | if (scrollbar_visible ()) |
732 | { |
776 | { |
733 | sb_w = scrollbar_TotalWidth (); |
777 | sb_w = scrollbar_TotalWidth (); |
734 | szHint.base_width += sb_w; |
778 | szHint.base_width += sb_w; |
735 | if (! (Options & Opt_scrollBar_right)) |
779 | if (!(Options & Opt_scrollBar_right)) |
736 | window_vt_x = sb_w; |
780 | window_vt_x += sb_w; |
737 | } |
781 | } |
|
|
782 | |
738 | if (menubar_visible ()) |
783 | if (menubar_visible ()) |
739 | { |
784 | { |
740 | mb_h = menuBar_TotalHeight (); |
785 | mb_h = menuBar_TotalHeight (); |
741 | szHint.base_height += mb_h; |
786 | szHint.base_height += mb_h; |
742 | window_vt_y = mb_h; |
787 | window_vt_y += mb_h; |
743 | } |
788 | } |
|
|
789 | |
744 | szHint.width_inc = TermWin.fwidth; |
790 | szHint.width_inc = TermWin.fwidth; |
745 | szHint.height_inc = TermWin.fheight; |
791 | szHint.height_inc = TermWin.fheight; |
746 | szHint.min_width = szHint.base_width + szHint.width_inc; |
792 | szHint.min_width = szHint.base_width + szHint.width_inc; |
747 | szHint.min_height = szHint.base_height + szHint.height_inc; |
793 | szHint.min_height = szHint.base_height + szHint.height_inc; |
748 | |
794 | |
… | |
… | |
754 | else |
800 | else |
755 | { |
801 | { |
756 | MIN_IT (TermWin.width, max_width); |
802 | MIN_IT (TermWin.width, max_width); |
757 | szHint.width = szHint.base_width + TermWin.width; |
803 | szHint.width = szHint.base_width + TermWin.width; |
758 | } |
804 | } |
|
|
805 | |
759 | if (height && height - szHint.base_height < max_height) |
806 | if (height && height - szHint.base_height < max_height) |
760 | { |
807 | { |
761 | szHint.height = height; |
808 | szHint.height = height; |
762 | TermWin.height = height - szHint.base_height; |
809 | TermWin.height = height - szHint.base_height; |
763 | } |
810 | } |
764 | else |
811 | else |
765 | { |
812 | { |
766 | MIN_IT (TermWin.height, max_height); |
813 | MIN_IT (TermWin.height, max_height); |
767 | szHint.height = szHint.base_height + TermWin.height; |
814 | szHint.height = szHint.base_height + TermWin.height; |
768 | } |
815 | } |
|
|
816 | |
769 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
817 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
770 | window_sb_x = szHint.width - sb_w; |
818 | window_sb_x = szHint.width - sb_w; |
771 | |
819 | |
772 | if (recalc_x) |
820 | if (recalc_x) |
773 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
821 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
… | |
… | |
848 | resize_all_windows (0, 0, 0); |
896 | resize_all_windows (0, 0, 0); |
849 | scr_remap_chars (); |
897 | scr_remap_chars (); |
850 | scr_touch (true); |
898 | scr_touch (true); |
851 | } |
899 | } |
852 | |
900 | |
|
|
901 | for (unicode_t ch = 0x20; ch <= 0x7f; ch++) |
|
|
902 | TermWin.ascii_map [ch - 0x20] = fs->find_font (ch); |
|
|
903 | |
853 | return true; |
904 | return true; |
854 | } |
905 | } |
855 | } |
906 | } |
856 | |
907 | |
857 | return false; |
908 | return false; |
… | |
… | |
867 | /*----------------------------------------------------------------------*/ |
918 | /*----------------------------------------------------------------------*/ |
868 | /* xterm sequences - title, iconName, color (exptl) */ |
919 | /* xterm sequences - title, iconName, color (exptl) */ |
869 | void |
920 | void |
870 | rxvt_term::set_title (const char *str) |
921 | rxvt_term::set_title (const char *str) |
871 | { |
922 | { |
872 | #ifndef SMART_WINDOW_TITLE |
923 | #ifdef SMART_WINDOW_TITLE |
873 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
874 | #else |
|
|
875 | char *name; |
924 | char *name; |
876 | |
925 | |
877 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
926 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
878 | name = NULL; |
927 | name = NULL; |
879 | |
928 | |
880 | if (name == NULL || STRCMP (name, str)) |
929 | if (name == NULL || STRCMP (name, str)) |
|
|
930 | #endif |
881 | XStoreName (display->display, TermWin.parent[0], str); |
931 | XStoreName (display->display, TermWin.parent[0], str); |
882 | |
932 | |
|
|
933 | #ifdef SMART_WINDOW_TITLE |
883 | if (name) |
934 | if (name) |
884 | XFree (name); |
935 | XFree (name); |
885 | #endif |
936 | #endif |
886 | } |
937 | } |
887 | |
938 | |
888 | void |
939 | void |
889 | rxvt_term::set_icon_name (const char *str) |
940 | rxvt_term::set_icon_name (const char *str) |
890 | { |
941 | { |
891 | #ifndef SMART_WINDOW_TITLE |
942 | #ifdef SMART_WINDOW_TITLE |
892 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
893 | #else |
|
|
894 | char *name; |
943 | char *name; |
895 | |
944 | |
896 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
945 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
897 | name = NULL; |
946 | name = NULL; |
898 | |
947 | |
899 | if (name == NULL || STRCMP (name, str)) |
948 | if (name == NULL || STRCMP (name, str)) |
|
|
949 | #endif |
900 | XSetIconName (display->display, TermWin.parent[0], str); |
950 | XSetIconName (display->display, TermWin.parent[0], str); |
901 | |
951 | |
|
|
952 | #ifdef SMART_WINDOW_TITLE |
902 | if (name) |
953 | if (name) |
903 | XFree (name); |
954 | XFree (name); |
904 | #endif |
955 | #endif |
905 | } |
956 | } |
906 | |
957 | |
… | |
… | |
920 | i = atoi (color); |
971 | i = atoi (color); |
921 | if (i >= 8 && i <= 15) |
972 | if (i >= 8 && i <= 15) |
922 | { /* bright colors */ |
973 | { /* bright colors */ |
923 | i -= 8; |
974 | i -= 8; |
924 | # ifndef NO_BRIGHTCOLOR |
975 | # ifndef NO_BRIGHTCOLOR |
925 | PixColors[idx] = PixColors[minBrightCOLOR + i]; |
976 | PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i]; |
926 | SET_PIXCOLOR (idx); |
977 | SET_PIXCOLOR (idx); |
927 | goto Done; |
978 | goto Done; |
928 | # endif |
979 | # endif |
929 | |
980 | |
930 | } |
981 | } |
931 | if (i >= 0 && i <= 7) |
982 | if (i >= 0 && i <= 7) |
932 | { /* normal colors */ |
983 | { /* normal colors */ |
933 | PixColors[idx] = PixColors[minCOLOR + i]; |
984 | PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i]; |
934 | SET_PIXCOLOR (idx); |
985 | SET_PIXCOLOR (idx); |
935 | goto Done; |
986 | goto Done; |
936 | } |
987 | } |
937 | } |
988 | } |
|
|
989 | |
938 | if (!rXParseAllocColor (& xcol, color)) |
990 | if (!rXParseAllocColor (& xcol, color)) |
939 | return; |
991 | return; |
|
|
992 | |
940 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
993 | /* XStoreColor (display->display, display->cmap, XColor*); */ |
941 | |
994 | |
942 | /* |
995 | /* |
943 | * FIXME: should free colors here, but no idea how to do it so instead, |
996 | * FIXME: should free colors here, but no idea how to do it so instead, |
944 | * so just keep gobbling up the colormap |
997 | * so just keep gobbling up the colormap |
945 | */ |
998 | */ |
… | |
… | |
948 | if (PixColors[idx] == PixColors[i]) |
1001 | if (PixColors[idx] == PixColors[i]) |
949 | break; |
1002 | break; |
950 | if (i > Color_White) |
1003 | if (i > Color_White) |
951 | { |
1004 | { |
952 | /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ |
1005 | /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ |
953 | XFreeColors (display->display, XCMAP, (PixColors + idx), 1, |
1006 | XFreeColors (display->display, display->cmap, (PixColors + idx), 1, |
954 | DisplayPlanes (display->display, display->screen)); |
1007 | DisplayPlanes (display->display, display->screen)); |
955 | } |
1008 | } |
956 | # endif |
1009 | # endif |
957 | |
1010 | |
958 | PixColors[idx] = xcol; |
1011 | PixColorsFocused[idx] = xcol; |
959 | SET_PIXCOLOR (idx); |
1012 | SET_PIXCOLOR (idx); |
960 | |
1013 | |
961 | /* XSetWindowAttributes attr; */ |
1014 | /* XSetWindowAttributes attr; */ |
962 | /* Cursor cursor; */ |
1015 | /* Cursor cursor; */ |
963 | Done: |
1016 | Done: |
|
|
1017 | #ifdef OFF_FOCUS_FADING |
|
|
1018 | PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade])); |
|
|
1019 | #endif |
964 | if (idx == Color_bg && ! (Options & Opt_transparent)) |
1020 | if (idx == Color_bg && ! (Options & Opt_transparent)) |
965 | XSetWindowBackground (display->display, TermWin.vt, |
1021 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
966 | PixColors[Color_bg]); |
|
|
967 | |
1022 | |
968 | /* handle Color_BD, scrollbar background, etc. */ |
1023 | /* handle Color_BD, scrollbar background, etc. */ |
969 | |
1024 | |
970 | set_colorfgbg (); |
1025 | set_colorfgbg (); |
971 | recolour_cursor (); |
1026 | recolour_cursor (); |
972 | /* the only reasonable way to enforce a clean update */ |
1027 | scr_touch (true); |
973 | scr_poweron (); |
|
|
974 | } |
1028 | } |
975 | |
1029 | |
976 | #else |
1030 | #else |
977 | # define set_window_color (idx,color) ((void)0) |
1031 | # define set_window_color (idx,color) ((void)0) |
978 | #endif /* XTERM_COLOR_CHANGE */ |
1032 | #endif /* XTERM_COLOR_CHANGE */ |
979 | |
1033 | |
980 | void |
1034 | void |
981 | rxvt_term::recolour_cursor () |
1035 | rxvt_term::recolour_cursor () |
982 | { |
1036 | { |
983 | #if TODO |
|
|
984 | rxvt_color xcol[2]; |
1037 | XColor xcol[2]; |
985 | |
1038 | |
986 | xcol[0] = PixColors[Color_pointer]; |
1039 | xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColorsFocused[Color_pointer_fg] : PixColorsFocused[Color_fg]; |
987 | xcol[1] = PixColors[Color_bg]; |
1040 | xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg]; |
988 | XQueryColors (display->display, XCMAP, xcol, 2); |
1041 | XQueryColors (display->display, display->cmap, xcol, 2); |
989 | XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); |
1042 | XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); |
990 | #endif |
|
|
991 | } |
1043 | } |
992 | |
1044 | |
993 | /*----------------------------------------------------------------------*/ |
1045 | /*----------------------------------------------------------------------*/ |
994 | /* |
1046 | /* |
995 | * find if fg/bg matches any of the normal (low-intensity) colors |
1047 | * find if fg/bg matches any of the normal (low-intensity) colors |
… | |
… | |
1065 | int old_width = szHint.width, old_height = szHint.height; |
1117 | int old_width = szHint.width, old_height = szHint.height; |
1066 | #endif |
1118 | #endif |
1067 | |
1119 | |
1068 | window_calc (width, height); |
1120 | window_calc (width, height); |
1069 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1121 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
|
|
1122 | |
1070 | if (!ignoreparent) |
1123 | if (!ignoreparent) |
1071 | { |
1124 | { |
1072 | #ifdef SMART_RESIZE |
1125 | #ifdef SMART_RESIZE |
1073 | /* |
1126 | /* |
1074 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
1127 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
… | |
… | |
1109 | dy /= 2; |
1162 | dy /= 2; |
1110 | |
1163 | |
1111 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1164 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1112 | szHint.width, szHint.height); |
1165 | szHint.width, szHint.height); |
1113 | #else |
1166 | #else |
1114 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, |
1167 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
1115 | szHint.height); |
|
|
1116 | #endif |
1168 | #endif |
1117 | |
|
|
1118 | } |
1169 | } |
1119 | |
1170 | |
1120 | fix_screen = (TermWin.ncol != prev_ncol |
1171 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1121 | || TermWin.nrow != prev_nrow); |
|
|
1122 | |
1172 | |
1123 | if (fix_screen || width != old_width || height != old_height) |
1173 | if (fix_screen || width != old_width || height != old_height) |
1124 | { |
1174 | { |
1125 | if (scrollbar_visible ()) |
1175 | if (scrollbar_visible ()) |
1126 | { |
1176 | { |
1127 | XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, |
1177 | XMoveResizeWindow (display->display, scrollBar.win, |
|
|
1178 | window_sb_x, 0, |
1128 | 0, scrollbar_TotalWidth (), szHint.height); |
1179 | scrollbar_TotalWidth (), szHint.height); |
1129 | resize_scrollbar (); |
1180 | resize_scrollbar (); |
1130 | } |
1181 | } |
1131 | |
1182 | |
1132 | if (menubar_visible ()) |
1183 | if (menubar_visible ()) |
1133 | XMoveResizeWindow (display->display, menuBar.win, window_vt_x, |
1184 | XMoveResizeWindow (display->display, menuBar.win, |
|
|
1185 | window_vt_x, 0, |
1134 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1186 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1135 | |
1187 | |
1136 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
1188 | XMoveResizeWindow (display->display, TermWin.vt, |
1137 | window_vt_y, TermWin_TotalWidth (), |
1189 | window_vt_x, window_vt_y, |
1138 | TermWin_TotalHeight ()); |
1190 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1139 | scr_clear (height != old_height); |
1191 | scr_clear (); |
1140 | #ifdef XPM_BACKGROUND |
1192 | #ifdef XPM_BACKGROUND |
1141 | resize_pixmap (); |
1193 | resize_pixmap (); |
1142 | #endif |
1194 | #endif |
1143 | |
|
|
1144 | } |
1195 | } |
1145 | |
1196 | |
1146 | if (fix_screen || old_height == 0) |
1197 | if (fix_screen || old_height == 0) |
1147 | { |
1198 | { |
1148 | int curr_screen = -1; |
1199 | int curr_screen = -1; |
… | |
… | |
1189 | if (width == 0) |
1240 | if (width == 0) |
1190 | width = wattr.width - szHint.base_width; |
1241 | width = wattr.width - szHint.base_width; |
1191 | if (height == 0) |
1242 | if (height == 0) |
1192 | height = wattr.height - szHint.base_height; |
1243 | height = wattr.height - szHint.base_height; |
1193 | } |
1244 | } |
|
|
1245 | |
1194 | if (width != TermWin.width || height != TermWin.height) |
1246 | if (width != TermWin.width || height != TermWin.height) |
1195 | { |
1247 | { |
1196 | width += szHint.base_width; |
1248 | width += szHint.base_width; |
1197 | height += szHint.base_height; |
1249 | height += szHint.base_height; |
1198 | resize_all_windows (width, height, 0); |
1250 | resize_all_windows (width, height, 0); |