… | |
… | |
169 | COLOR_SCROLLTROUGH, |
169 | COLOR_SCROLLTROUGH, |
170 | #endif /* KEEP_SCROLLCOLOR */ |
170 | #endif /* KEEP_SCROLLCOLOR */ |
171 | #if TINTING |
171 | #if TINTING |
172 | NULL, |
172 | NULL, |
173 | #endif |
173 | #endif |
|
|
174 | #if OFF_FOCUS_FADING |
|
|
175 | "black", |
|
|
176 | #endif |
174 | }; |
177 | }; |
175 | |
178 | |
176 | const char *const xa_names[] = |
179 | const char *const xa_names[] = |
177 | { |
180 | { |
178 | "TEXT", |
181 | "TEXT", |
… | |
… | |
185 | "INCR", |
188 | "INCR", |
186 | "WM_PROTOCOLS", |
189 | "WM_PROTOCOLS", |
187 | "WM_DELETE_WINDOW", |
190 | "WM_DELETE_WINDOW", |
188 | "CLIPBOARD", |
191 | "CLIPBOARD", |
189 | #if ENABLE_FRILLS |
192 | #if ENABLE_FRILLS |
|
|
193 | "_MOTIF_WM_HINTS", |
|
|
194 | #endif |
|
|
195 | #if ENABLE_EWMH |
190 | "_NET_WM_PID", |
196 | "_NET_WM_PID", |
191 | "_MOTIF_WM_HINTS", |
|
|
192 | "_NET_WM_NAME", |
197 | "_NET_WM_NAME", |
193 | "_NET_WM_ICON_NAME", |
198 | "_NET_WM_ICON_NAME", |
|
|
199 | "_NET_WM_PING", |
194 | #endif |
200 | #endif |
195 | #if USE_XIM |
201 | #if USE_XIM |
196 | "WM_LOCALE_NAME", |
202 | "WM_LOCALE_NAME", |
197 | #endif |
203 | #endif |
198 | #ifdef TRANSPARENT |
204 | #ifdef TRANSPARENT |
… | |
… | |
203 | "DndProtocol", |
209 | "DndProtocol", |
204 | "DndSelection", |
210 | "DndSelection", |
205 | #endif |
211 | #endif |
206 | #if ENABLE_XEMBED |
212 | #if ENABLE_XEMBED |
207 | "_XEMBED", |
213 | "_XEMBED", |
|
|
214 | "_XEMBED_INFO", |
208 | #endif |
215 | #endif |
209 | }; |
216 | }; |
210 | |
217 | |
211 | bool |
218 | bool |
212 | rxvt_term::init_vars () |
219 | rxvt_term::init_vars () |
… | |
… | |
340 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
347 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
341 | rs[Rs_display_name] = ":0"; |
348 | rs[Rs_display_name] = ":0"; |
342 | |
349 | |
343 | get_options (r_argc, r_argv); |
350 | get_options (r_argc, r_argv); |
344 | |
351 | |
345 | #ifdef LOCAL_X_IS_UNIX |
|
|
346 | if (rs[Rs_display_name][0] == ':') |
|
|
347 | { |
|
|
348 | val = rxvt_malloc (5 + strlen (rs[Rs_display_name])); |
|
|
349 | strcpy (val, "unix"); |
|
|
350 | strcat (val, rs[Rs_display_name]); |
|
|
351 | display = displays.get (val); |
|
|
352 | free (val); |
|
|
353 | } |
|
|
354 | #endif |
|
|
355 | |
|
|
356 | if (!display |
|
|
357 | && ! (display = displays.get (rs[Rs_display_name]))) |
352 | if (!(display = displays.get (rs[Rs_display_name]))) |
358 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
353 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
359 | |
354 | |
360 | extract_resources (); |
355 | extract_resources (); |
361 | free (r_argv); |
356 | free (r_argv); |
362 | |
357 | |
… | |
… | |
745 | } |
740 | } |
746 | } |
741 | } |
747 | } |
742 | } |
748 | |
743 | |
749 | pix_colors[i] = xcol; |
744 | pix_colors[i] = xcol; |
|
|
745 | SET_PIXCOLOR (i); |
|
|
746 | } |
|
|
747 | |
750 | #ifdef OFF_FOCUS_FADING |
748 | #ifdef OFF_FOCUS_FADING |
751 | if (rs[Rs_fade]) |
749 | if (rs[Rs_fade]) |
|
|
750 | for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) |
752 | pix_colors_unfocused[i] = xcol.fade (display, atoi (rs[Rs_fade])); |
751 | pix_colors_unfocused[i] = pix_colors_focused[i].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); |
753 | #endif |
752 | #endif |
754 | SET_PIXCOLOR (i); |
|
|
755 | } |
|
|
756 | |
753 | |
757 | if (display->depth <= 2) |
754 | if (display->depth <= 2) |
758 | { |
755 | { |
759 | if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; |
756 | if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; |
760 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
757 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
… | |
… | |
768 | * from the fvwm window manager. |
765 | * from the fvwm window manager. |
769 | */ |
766 | */ |
770 | #ifdef KEEP_SCROLLCOLOR |
767 | #ifdef KEEP_SCROLLCOLOR |
771 | |
768 | |
772 | if (display->depth <= 2) |
769 | if (display->depth <= 2) |
|
|
770 | { |
773 | { /* Monochrome */ |
771 | /* Monochrome */ |
774 | pix_colors[Color_scroll] = pix_colors[Color_fg]; |
772 | pix_colors[Color_scroll] = pix_colors[Color_fg]; |
775 | pix_colors[Color_topShadow] = pix_colors[Color_bg]; |
773 | pix_colors[Color_topShadow] = pix_colors[Color_bg]; |
776 | pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; |
774 | pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; |
777 | } |
775 | } |
778 | else |
776 | else |
… | |
… | |
929 | #endif |
927 | #endif |
930 | XGCValues gcvalue; |
928 | XGCValues gcvalue; |
931 | long vt_emask; |
929 | long vt_emask; |
932 | XSetWindowAttributes attributes; |
930 | XSetWindowAttributes attributes; |
933 | XWindowAttributes gattr; |
931 | XWindowAttributes gattr; |
934 | Window top; |
932 | Window top, parent; |
935 | dDisp; |
933 | dDisp; |
936 | |
934 | |
937 | #ifdef USING_W11LIB |
935 | #ifdef USING_W11LIB |
938 | /* enable W11 callbacks */ |
936 | /* enable W11 callbacks */ |
939 | W11AddEventHandler (disp, rxvt_W11_process_x_event); |
937 | W11AddEventHandler (disp, rxvt_W11_process_x_event); |
… | |
… | |
966 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
964 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
967 | mwmhints.decorations = 0; |
965 | mwmhints.decorations = 0; |
968 | } |
966 | } |
969 | } |
967 | } |
970 | else |
968 | else |
971 | { |
|
|
972 | mwmhints.flags = 0; |
969 | mwmhints.flags = 0; |
973 | } |
|
|
974 | #endif |
970 | #endif |
975 | |
971 | |
976 | /* grab colors before netscape does */ |
972 | /* grab colors before netscape does */ |
977 | Get_Colours (); |
973 | Get_Colours (); |
978 | |
974 | |
979 | if (!set_fonts ()) |
975 | if (!set_fonts ()) |
980 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
976 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
981 | |
977 | |
|
|
978 | parent = DefaultRootWindow (disp); |
|
|
979 | |
982 | #if ENABLE_XEMBED |
980 | #if ENABLE_XEMBED |
983 | if (rs[Rs_embed]) |
981 | if (rs[Rs_embed]) |
984 | { |
982 | { |
985 | XWindowAttributes wattr; |
983 | XWindowAttributes wattr; |
986 | |
984 | |
987 | top = strtol (rs[Rs_embed], 0, 0); |
985 | parent = strtol (rs[Rs_embed], 0, 0); |
988 | |
986 | |
989 | if (!XGetWindowAttributes (disp, top, &wattr)) |
987 | if (!XGetWindowAttributes (disp, parent, &wattr)) |
990 | rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); |
988 | rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); |
991 | |
989 | |
992 | window_calc (wattr.width, wattr.height); |
990 | window_calc (wattr.width, wattr.height); |
|
|
991 | } |
993 | |
992 | |
994 | #if 0 |
993 | #endif |
995 | if (wattr.map_state == IsViewable) |
994 | window_calc (0, 0); |
996 | { |
995 | |
997 | TermWin.mapped = 1; |
996 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
998 | refresh_type = FAST_REFRESH; |
997 | #ifdef PREFER_24BIT |
999 | XClearWindow (disp, top); |
998 | attributes.background_pixel = pix_colors_focused[Color_border]; |
1000 | // TODO: make XMapNotify-event-code a function and call it |
999 | attributes.border_pixel = pix_colors_focused[Color_border]; |
1001 | // TODO: how can I detect visibility without unmap/map? |
1000 | attributes.colormap = display->cmap; |
1002 | // TODO: focusin etc. |
1001 | top = XCreateWindow (disp, parent, |
1003 | } |
1002 | szHint.x, szHint.y, |
|
|
1003 | szHint.width, szHint.height, |
|
|
1004 | TermWin.ext_bwidth, |
|
|
1005 | display->depth, InputOutput, |
|
|
1006 | display->visual, |
|
|
1007 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
1004 | #else |
1008 | #else |
1005 | // it's easiest just to unmap/map to get all state correctly set-up |
1009 | top = XCreateSimpleWindow (disp, parent, |
1006 | XUnmapWindow (disp, top); |
|
|
1007 | #endif |
|
|
1008 | } |
|
|
1009 | else |
|
|
1010 | #endif |
|
|
1011 | { |
|
|
1012 | window_calc (0, 0); |
|
|
1013 | |
|
|
1014 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
|
|
1015 | #ifdef PREFER_24BIT |
|
|
1016 | attributes.background_pixel = pix_colors_focused[Color_border]; |
|
|
1017 | attributes.border_pixel = pix_colors_focused[Color_border]; |
|
|
1018 | attributes.colormap = display->cmap; |
|
|
1019 | top = XCreateWindow (disp, DefaultRootWindow (disp), |
|
|
1020 | szHint.x, szHint.y, |
1010 | szHint.x, szHint.y, |
1021 | szHint.width, szHint.height, |
1011 | szHint.width, szHint.height, |
1022 | TermWin.ext_bwidth, |
1012 | TermWin.ext_bwidth, |
1023 | display->depth, InputOutput, |
|
|
1024 | display->visual, |
|
|
1025 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
|
|
1026 | #else |
|
|
1027 | top = XCreateSimpleWindow (disp, DefaultRootWindow (disp), |
|
|
1028 | szHint.x, szHint.y, |
|
|
1029 | szHint.width, szHint.height, |
|
|
1030 | TermWin.ext_bwidth, |
|
|
1031 | pix_colors_focused[Color_border], |
1013 | pix_colors_focused[Color_border], |
1032 | pix_colors_focused[Color_border]); |
1014 | pix_colors_focused[Color_border]); |
1033 | #endif |
1015 | #endif |
1034 | } |
|
|
1035 | |
1016 | |
1036 | TermWin.parent[0] = top; |
1017 | TermWin.parent[0] = top; |
1037 | |
1018 | |
1038 | old_width = szHint.width; |
1019 | old_width = szHint.width; |
1039 | old_height = szHint.height; |
1020 | old_height = szHint.height; |
… | |
… | |
1047 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1028 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1048 | wmHint.input = True; |
1029 | wmHint.input = True; |
1049 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1030 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1050 | wmHint.window_group = top; |
1031 | wmHint.window_group = top; |
1051 | |
1032 | |
1052 | XSetWMProperties (disp, top, NULL, NULL, |
1033 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1053 | (char **)argv, argc, &szHint, &wmHint, &classHint); |
1034 | &szHint, &wmHint, &classHint); |
1054 | |
1035 | |
1055 | /* Enable delete window protocol */ |
1036 | Atom protocols[] = { |
1056 | XSetWMProtocols (disp, top, &xa[XA_WM_DELETE_WINDOW], 1); |
1037 | xa[XA_WM_DELETE_WINDOW], |
|
|
1038 | #if ENABLE_EWMH |
|
|
1039 | xa[XA_NET_WM_PING], |
|
|
1040 | #endif |
|
|
1041 | }; |
1057 | |
1042 | |
1058 | #if ENABLE_FRILLS |
1043 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
|
|
1044 | |
|
|
1045 | #if ENABLE_EWMH |
1059 | long pid = getpid (); |
1046 | long pid = getpid (); |
1060 | |
1047 | |
1061 | XChangeProperty (disp, top, |
1048 | XChangeProperty (disp, top, |
1062 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1049 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1063 | PropModeReplace, (unsigned char *)&pid, 1); |
1050 | PropModeReplace, (unsigned char *)&pid, 1); |
|
|
1051 | |
|
|
1052 | // _NET_WM_WINDOW_TYPE is NORMAL, which is the default |
1064 | #endif |
1053 | #endif |
1065 | |
1054 | |
1066 | XSelectInput (disp, top, |
1055 | XSelectInput (disp, top, |
1067 | KeyPressMask |
1056 | KeyPressMask |
1068 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 |
1057 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 |
… | |
… | |
1185 | |
1174 | |
1186 | pointer_unblank (); |
1175 | pointer_unblank (); |
1187 | scr_recolour (); |
1176 | scr_recolour (); |
1188 | |
1177 | |
1189 | #if ENABLE_XEMBED |
1178 | #if ENABLE_XEMBED |
1190 | // why this is necessary, I don't know, race condition?? |
1179 | if (rs[Rs_embed]) |
1191 | XMoveWindow (disp, TermWin.vt, window_vt_x, window_vt_y); |
1180 | { |
|
|
1181 | long info[2] = { 0, XEMBED_MAPPED }; |
|
|
1182 | |
|
|
1183 | XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
|
|
1184 | 32, PropModeReplace, (unsigned char *)&info, 2); |
|
|
1185 | } |
1192 | #endif |
1186 | #endif |
1193 | } |
1187 | } |
1194 | |
1188 | |
1195 | /* ------------------------------------------------------------------------- * |
1189 | /* ------------------------------------------------------------------------- * |
1196 | * GET TTY CURRENT STATE * |
1190 | * GET TTY CURRENT STATE * |