… | |
… | |
357 | }; |
357 | }; |
358 | |
358 | |
359 | bool |
359 | bool |
360 | rxvt_term::init_vars () |
360 | rxvt_term::init_vars () |
361 | { |
361 | { |
362 | PixColors = new rxvt_color [TOTAL_COLORS]; |
362 | PixColorsFocused = new rxvt_color [TOTAL_COLORS]; |
|
|
363 | #ifdef OFF_FOCUS_FADING |
|
|
364 | PixColorsUnFocused = new rxvt_color [TOTAL_COLORS]; |
|
|
365 | #endif |
|
|
366 | PixColors = PixColorsFocused; |
|
|
367 | |
363 | if (PixColors == NULL) |
368 | if (PixColors == NULL) |
364 | return false; |
369 | return false; |
365 | |
370 | |
366 | #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) |
371 | #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) |
367 | TermWin.pixmap = None; |
372 | TermWin.pixmap = None; |
… | |
… | |
873 | void |
878 | void |
874 | rxvt_term::Get_Colours () |
879 | rxvt_term::Get_Colours () |
875 | { |
880 | { |
876 | int i; |
881 | int i; |
877 | |
882 | |
|
|
883 | #ifdef OFF_FOCUS_FADING |
|
|
884 | PixColors = PixColorsFocused; |
|
|
885 | #endif |
|
|
886 | |
878 | for (i = 0; i < (XDEPTH <= 2 ? 2 : NRS_COLORS); i++) |
887 | for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) |
879 | { |
888 | { |
880 | rxvt_color xcol; |
889 | rxvt_color xcol; |
881 | |
890 | |
882 | if (!rs[Rs_color + i]) |
891 | if (!rs[Rs_color + i]) |
883 | continue; |
892 | continue; |
… | |
… | |
918 | } |
927 | } |
919 | } |
928 | } |
920 | } |
929 | } |
921 | |
930 | |
922 | PixColors[i] = xcol; |
931 | PixColors[i] = xcol; |
|
|
932 | #ifdef OFF_FOCUS_FADING |
|
|
933 | if (rs[Rs_fade]) |
|
|
934 | PixColorsUnFocused[i] = xcol.fade (display, atoi (rs[Rs_fade])); |
|
|
935 | #endif |
923 | SET_PIXCOLOR (i); |
936 | SET_PIXCOLOR (i); |
924 | } |
937 | } |
925 | |
938 | |
926 | if (XDEPTH <= 2) |
939 | if (display->depth <= 2) |
927 | { |
940 | { |
928 | if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg]; |
941 | if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg]; |
929 | if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg]; |
942 | if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg]; |
930 | if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg]; |
943 | if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg]; |
931 | } |
944 | } |
… | |
… | |
936 | * The calculations of topShadow/bottomShadow values are adapted |
949 | * The calculations of topShadow/bottomShadow values are adapted |
937 | * from the fvwm window manager. |
950 | * from the fvwm window manager. |
938 | */ |
951 | */ |
939 | #ifdef KEEP_SCROLLCOLOR |
952 | #ifdef KEEP_SCROLLCOLOR |
940 | |
953 | |
941 | if (XDEPTH <= 2) |
954 | if (display->depth <= 2) |
942 | { /* Monochrome */ |
955 | { /* Monochrome */ |
943 | PixColors[Color_scroll] = PixColors[Color_fg]; |
956 | PixColors[Color_scroll] = PixColors[Color_fg]; |
944 | PixColors[Color_topShadow] = PixColors[Color_bg]; |
957 | PixColors[Color_topShadow] = PixColors[Color_bg]; |
945 | PixColors[Color_bottomShadow] = PixColors[Color_bg]; |
958 | PixColors[Color_bottomShadow] = PixColors[Color_bg]; |
946 | } |
959 | } |
947 | else |
960 | else |
948 | { |
961 | { |
949 | rxvt_color xcol[3]; |
962 | rxvt_color xcol[2]; |
950 | /* xcol[0] == white |
963 | /* xcol[0] == white |
951 | * xcol[1] == top shadow |
964 | * xcol[1] == top shadow |
952 | * xcol[2] == bot shadow */ |
965 | * xcol[2] == bot shadow */ |
953 | |
966 | |
954 | xcol[1] = PixColors[Color_scroll]; |
967 | xcol[1] = PixColors[Color_scroll]; |
955 | # ifdef PREFER_24BIT |
|
|
956 | xcol[0].set (display, 65535, 65535, 65535); |
968 | xcol[0].set (display, 65535, 65535, 65535); |
957 | /* XFreeColors (display->display, XCMAP, & (xcol[0].pixel), 1, ~0); */ |
|
|
958 | # else |
|
|
959 | xcol[0].set (display, WhitePixel (display->display, display->screen)); |
|
|
960 | # endif |
|
|
961 | |
969 | |
962 | unsigned short pr1, pg1, pb1, pr0, pg0, pb0; |
970 | unsigned short pr1, pg1, pb1, pr0, pg0, pb0; |
963 | |
971 | |
964 | xcol[0].get (display, pr0, pg0, pb0); |
972 | xcol[0].get (display, pr0, pg0, pb0); |
965 | xcol[1].get (display, pr1, pg1, pb1); |
973 | xcol[1].get (display, pr1, pg1, pb1); |
966 | |
974 | |
967 | /* bottomShadowColor */ |
|
|
968 | if (!xcol[2].set (display, pr1 / 2, pg1 / 2, pb1 / 2)) |
|
|
969 | xcol[2] = PixColors[Color_Black]; |
|
|
970 | |
|
|
971 | PixColors[Color_bottomShadow] = xcol[2]; |
975 | PixColors[Color_bottomShadow] = xcol[1].fade (display, 50); |
972 | |
976 | |
973 | /* topShadowColor */ |
977 | /* topShadowColor */ |
974 | if (!xcol[1].set (display, |
978 | if (!xcol[1].set (display, |
975 | min (pr0, max (pr0 / 5, pr1) * 7 / 5), |
979 | min (pr0, max (pr0 / 5, pr1) * 7 / 5), |
976 | min (pg0, max (pg0 / 5, pg1) * 7 / 5), |
980 | min (pg0, max (pg0 / 5, pg1) * 7 / 5), |
… | |
… | |
1082 | void |
1086 | void |
1083 | rxvt_term::create_windows (int argc, const char *const *argv) |
1087 | rxvt_term::create_windows (int argc, const char *const *argv) |
1084 | { |
1088 | { |
1085 | XClassHint classHint; |
1089 | XClassHint classHint; |
1086 | XWMHints wmHint; |
1090 | XWMHints wmHint; |
|
|
1091 | #ifndef NO_FRILLS |
|
|
1092 | Atom prop = None; |
|
|
1093 | MWMHints mwmhints; |
|
|
1094 | #endif |
1087 | XGCValues gcvalue; |
1095 | XGCValues gcvalue; |
1088 | long vt_emask; |
1096 | long vt_emask; |
1089 | XSetWindowAttributes attributes; |
1097 | XSetWindowAttributes attributes; |
1090 | XWindowAttributes gattr; |
1098 | XWindowAttributes gattr; |
1091 | |
1099 | |
1092 | if (Options & Opt_transparent) |
1100 | if (Options & Opt_transparent) |
1093 | { |
1101 | { |
1094 | XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); |
1102 | XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); |
1095 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
1103 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
1096 | } |
1104 | } |
|
|
1105 | |
|
|
1106 | #ifndef NO_FRILLS |
|
|
1107 | if (Options & Opt_borderLess) |
|
|
1108 | { |
|
|
1109 | prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True); |
|
|
1110 | if (prop == None) |
|
|
1111 | { |
|
|
1112 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
|
|
1113 | #ifdef PREFER_24BIT |
|
|
1114 | attributes.override_redirect = TRUE; |
|
|
1115 | #endif |
|
|
1116 | mwmhints.flags = 0; |
|
|
1117 | } |
|
|
1118 | else |
|
|
1119 | { |
|
|
1120 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
|
|
1121 | mwmhints.decorations = 0; |
|
|
1122 | } |
|
|
1123 | } |
|
|
1124 | else |
|
|
1125 | { |
|
|
1126 | mwmhints.flags = 0; |
|
|
1127 | } |
|
|
1128 | #endif |
1097 | |
1129 | |
1098 | /* grab colors before netscape does */ |
1130 | /* grab colors before netscape does */ |
1099 | Get_Colours (); |
1131 | Get_Colours (); |
1100 | |
1132 | |
1101 | if (!change_font (rs[Rs_font])) |
1133 | if (!change_font (rs[Rs_font])) |
… | |
… | |
1151 | display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, |
1183 | display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, |
1152 | PropModeReplace, (unsigned char *)&pid, 1); |
1184 | PropModeReplace, (unsigned char *)&pid, 1); |
1153 | #endif |
1185 | #endif |
1154 | |
1186 | |
1155 | XSelectInput (display->display, TermWin.parent[0], |
1187 | XSelectInput (display->display, TermWin.parent[0], |
1156 | KeyPressMask |
1188 | KeyPressMask |
1157 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1189 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1158 | | KeyReleaseMask |
1190 | | KeyReleaseMask |
1159 | #endif |
1191 | #endif |
1160 | | FocusChangeMask | VisibilityChangeMask |
1192 | | FocusChangeMask | VisibilityChangeMask |
|
|
1193 | | ExposureMask |
1161 | | StructureNotifyMask); |
1194 | | StructureNotifyMask); |
1162 | termwin_ev.start (display, TermWin.parent[0]); |
1195 | termwin_ev.start (display, TermWin.parent[0]); |
|
|
1196 | |
|
|
1197 | #ifndef NO_FRILLS |
|
|
1198 | if (mwmhints.flags) |
|
|
1199 | { |
|
|
1200 | prop = XInternAtom(display->display, "_MOTIF_WM_HINTS", False); |
|
|
1201 | XChangeProperty(display->display, TermWin.parent[0], prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); |
|
|
1202 | } |
|
|
1203 | #endif |
1163 | |
1204 | |
1164 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1205 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1165 | TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); |
1206 | TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); |
1166 | |
1207 | |
1167 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1208 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
… | |
… | |
1189 | TermWin_TotalWidth (), |
1230 | TermWin_TotalWidth (), |
1190 | TermWin_TotalHeight (), |
1231 | TermWin_TotalHeight (), |
1191 | 0, |
1232 | 0, |
1192 | PixColors[Color_fg], |
1233 | PixColors[Color_fg], |
1193 | PixColors[Color_bg]); |
1234 | PixColors[Color_bg]); |
1194 | |
|
|
1195 | #ifdef DEBUG_X |
1235 | #ifdef DEBUG_X |
1196 | XStoreName (display->display, TermWin.vt, "vt window"); |
1236 | XStoreName (display->display, TermWin.vt, "vt window"); |
1197 | #endif |
1237 | #endif |
1198 | |
1238 | |
1199 | attributes.bit_gravity = NorthWestGravity; |
1239 | attributes.bit_gravity = NorthWestGravity; |
1200 | XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes); |
1240 | XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes); |
1201 | |
1241 | |
1202 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1242 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1203 | |
1243 | |
|
|
1244 | pointer_unblank (); |
|
|
1245 | |
1204 | #ifdef POINTER_BLANK |
1246 | #ifdef POINTER_BLANK |
1205 | pointer_unblank (); |
|
|
1206 | |
|
|
1207 | if (Options & Opt_pointerBlank) |
1247 | if (Options & Opt_pointerBlank) |
1208 | vt_emask |= PointerMotionMask; |
1248 | vt_emask |= PointerMotionMask; |
1209 | else |
1249 | else |
1210 | #endif |
1250 | #endif |
1211 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1251 | vt_emask |= Button1MotionMask | Button3MotionMask; |
… | |
… | |
1242 | |
1282 | |
1243 | #ifdef XPM_BACKGROUND |
1283 | #ifdef XPM_BACKGROUND |
1244 | if (rs[Rs_backgroundPixmap] != NULL |
1284 | if (rs[Rs_backgroundPixmap] != NULL |
1245 | && ! (Options & Opt_transparent)) |
1285 | && ! (Options & Opt_transparent)) |
1246 | { |
1286 | { |
1247 | const char *p = rs[Rs_backgroundPixmap]; |
1287 | const char *p = rs[Rs_backgroundPixmap]; |
1248 | |
1288 | |
1249 | if ((p = STRCHR (p, ';')) != NULL) |
1289 | if ((p = STRCHR (p, ';')) != NULL) |
1250 | { |
1290 | { |
1251 | p++; |
1291 | p++; |
1252 | scale_pixmap (p); |
1292 | scale_pixmap (p); |
… | |
… | |
1269 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1309 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1270 | gcvalue.foreground = PixColors[Color_topShadow]; |
1310 | gcvalue.foreground = PixColors[Color_topShadow]; |
1271 | topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1311 | topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1272 | gcvalue.foreground = PixColors[Color_bottomShadow]; |
1312 | gcvalue.foreground = PixColors[Color_bottomShadow]; |
1273 | botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1313 | botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1274 | gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; |
1314 | gcvalue.foreground = PixColors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1275 | scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1315 | scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
|
|
1316 | #endif |
|
|
1317 | |
|
|
1318 | #ifdef OFF_FOCUS_FADING |
|
|
1319 | // initially we are in unfocused state |
|
|
1320 | if (rs[Rs_fade]) |
|
|
1321 | PixColors = PixColorsUnFocused; |
1276 | #endif |
1322 | #endif |
1277 | } |
1323 | } |
1278 | |
1324 | |
1279 | /*----------------------------------------------------------------------*/ |
1325 | /*----------------------------------------------------------------------*/ |
1280 | /* |
1326 | /* |