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

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.14 by pcg, Thu Dec 18 05:45:11 2003 UTC vs.
Revision 1.16 by pcg, Thu Dec 18 13:33:02 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: init.c 2 * File: init.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: init.C,v 1.14 2003/12/18 05:45:11 pcg Exp $ 4 * $Id: init.C,v 1.16 2003/12/18 13:33:02 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
8 * - original version 8 * - original version
9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
795/* 795/*
796 * This is more or less stolen straight from XFree86 xterm. 796 * This is more or less stolen straight from XFree86 xterm.
797 * This should support all European type languages. 797 * This should support all European type languages.
798 */ 798 */
799void 799void
800rxvt_term::set_locale (const char *locale)
801{
802#if HAVE_XSETLOCALE || HAVE_SETLOCALE
803 free (this->locale);
804 this->locale = strdup (setlocale (LC_CTYPE, ""));
805#endif
806#if HAVE_NL_LANGINFO
807 free (codeset);
808 codeset = strdup (nl_langinfo (CODESET));
809 enc_utf8 = !STRCASECMP (codeset, "UTF-8")
810 || !STRCASECMP (codeset, "UTF8");
811#else
812 enc_utf8 = 1;
813#endif
814}
815
816void
800rxvt_term::init_xlocale () 817rxvt_term::init_xlocale ()
801{ 818{
802#ifdef USE_XIM 819#ifdef USE_XIM
803 if (!locale) 820 if (!locale)
804 rxvt_print_error ("Setting locale failed."); 821 rxvt_print_error ("Setting locale failed.");
814 if (!XSupportsLocale ()) 831 if (!XSupportsLocale ())
815 { 832 {
816 rxvt_print_error ("The locale is not supported by Xlib"); 833 rxvt_print_error ("The locale is not supported by Xlib");
817 return; 834 return;
818 } 835 }
819
820 rxvt_setTermFontSet (this, 0);
821 836
822 /* see if we can connect yet */ 837 /* see if we can connect yet */
823 rxvt_IMInstantiateCallback (Xdisplay, NULL, NULL); 838 rxvt_IMInstantiateCallback (Xdisplay, NULL, NULL);
824 839
825 /* To avoid Segmentation Fault in C locale: Solaris only? */ 840 /* To avoid Segmentation Fault in C locale: Solaris only? */
1112 R->ModMetaMask = modmasks[i - 1]; 1127 R->ModMetaMask = modmasks[i - 1];
1113} 1128}
1114 1129
1115/*----------------------------------------------------------------------*/ 1130/*----------------------------------------------------------------------*/
1116/* rxvt_Create_Windows() - Open and map the window */ 1131/* rxvt_Create_Windows() - Open and map the window */
1117/* EXTPROTO */
1118void 1132void
1119rxvt_Create_Windows(pR_ int argc, const char *const *argv) 1133rxvt_term::create_windows (int argc, const char *const *argv)
1120{ 1134{
1121 XClassHint classHint; 1135 XClassHint classHint;
1122 XWMHints wmHint; 1136 XWMHints wmHint;
1123 XGCValues gcvalue; 1137 XGCValues gcvalue;
1124 long vt_emask; 1138 long vt_emask;
1125 1139
1126#ifdef PREFER_24BIT 1140#ifdef PREFER_24BIT
1127
1128 XSetWindowAttributes attributes; 1141 XSetWindowAttributes attributes;
1129 XWindowAttributes gattr; 1142 XWindowAttributes gattr;
1130 1143
1131 XCMAP = DefaultColormap(R->Xdisplay, Xscreen); 1144 XCMAP = DefaultColormap(Xdisplay, Xscreen);
1132 XVISUAL = DefaultVisual(R->Xdisplay, Xscreen); 1145 XVISUAL = DefaultVisual(Xdisplay, Xscreen);
1133 1146
1134 if (R->Options & Opt_transparent) 1147 if (Options & Opt_transparent)
1135 { 1148 {
1136 XGetWindowAttributes(R->Xdisplay, RootWindow(R->Xdisplay, Xscreen), 1149 XGetWindowAttributes(Xdisplay, RootWindow(Xdisplay, Xscreen),
1137 &gattr); 1150 &gattr);
1138 XDEPTH = gattr.depth; 1151 XDEPTH = gattr.depth;
1139 } 1152 }
1140 else 1153 else
1141 { 1154 {
1142 XDEPTH = DefaultDepth(R->Xdisplay, Xscreen); 1155 XDEPTH = DefaultDepth(Xdisplay, Xscreen);
1143 /* 1156 /*
1144 * If depth is not 24, look for a 24bit visual. 1157 * If depth is not 24, look for a 24bit visual.
1145 */ 1158 */
1146 if (XDEPTH != 24) 1159 if (XDEPTH != 24)
1147 { 1160 {
1148 XVisualInfo vinfo; 1161 XVisualInfo vinfo;
1149 1162
1150 if (XMatchVisualInfo(R->Xdisplay, Xscreen, 24, TrueColor, &vinfo)) 1163 if (XMatchVisualInfo(Xdisplay, Xscreen, 24, TrueColor, &vinfo))
1151 { 1164 {
1152 XDEPTH = 24; 1165 XDEPTH = 24;
1153 XVISUAL = vinfo.visual; 1166 XVISUAL = vinfo.visual;
1154 XCMAP = XCreateColormap(R->Xdisplay, 1167 XCMAP = XCreateColormap(Xdisplay,
1155 RootWindow(R->Xdisplay, Xscreen), 1168 RootWindow(Xdisplay, Xscreen),
1156 XVISUAL, AllocNone); 1169 XVISUAL, AllocNone);
1157 } 1170 }
1158 } 1171 }
1159 } 1172 }
1160#endif 1173#endif
1161 1174
1162 /* grab colors before netscape does */ 1175 /* grab colors before netscape does */
1163 rxvt_Get_Colours(aR); 1176 rxvt_Get_Colours (this);
1164 1177
1165 rxvt_change_font(aR_ 1, NULL); 1178 rxvt_change_font (this, 1, NULL);
1166 rxvt_window_calc(aR_ 0, 0); 1179 window_calc (0, 0);
1167 R->old_width = R->szHint.width; 1180 old_width = szHint.width;
1168 R->old_height = R->szHint.height; 1181 old_height = szHint.height;
1169 1182
1170 /* parent window - reverse video so we can see placement errors 1183 /* parent window - reverse video so we can see placement errors
1171 * sub-window placement & size in rxvt_resize_subwindows() 1184 * sub-window placement & size in rxvt_resize_subwindows()
1172 */ 1185 */
1173 1186
1174#ifdef PREFER_24BIT 1187#ifdef PREFER_24BIT
1175
1176 attributes.background_pixel = R->PixColors[Color_fg]; 1188 attributes.background_pixel = PixColors[Color_fg];
1177 attributes.border_pixel = R->PixColors[Color_border]; 1189 attributes.border_pixel = PixColors[Color_border];
1178 attributes.colormap = XCMAP; 1190 attributes.colormap = XCMAP;
1179 R->TermWin.parent[0] = XCreateWindow(R->Xdisplay, Xroot, 1191 TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1180 R->szHint.x, R->szHint.y, 1192 szHint.x, szHint.y,
1181 R->szHint.width, R->szHint.height, 1193 szHint.width, szHint.height,
1182 R->TermWin.ext_bwidth, 1194 TermWin.ext_bwidth,
1183 XDEPTH, InputOutput, 1195 XDEPTH, InputOutput,
1184 XVISUAL, 1196 XVISUAL,
1185 CWBackPixel | CWBorderPixel 1197 CWBackPixel | CWBorderPixel
1186 | CWColormap, &attributes); 1198 | CWColormap, &attributes);
1187#else 1199#else
1188
1189 R->TermWin.parent[0] = XCreateSimpleWindow(R->Xdisplay, Xroot, 1200 TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1190 R->szHint.x, R->szHint.y, 1201 szHint.x, szHint.y,
1191 R->szHint.width, 1202 szHint.width,
1192 R->szHint.height, 1203 szHint.height,
1193 R->TermWin.ext_bwidth, 1204 TermWin.ext_bwidth,
1194 R->PixColors[Color_border], 1205 PixColors[Color_border],
1195 R->PixColors[Color_fg]); 1206 PixColors[Color_fg]);
1196#endif 1207#endif
1197 1208
1198 rxvt_xterm_seq(aR_ XTerm_title, R->rs[Rs_title], CHAR_ST); 1209 rxvt_xterm_seq (this, XTerm_title, rs[Rs_title], CHAR_ST);
1199 rxvt_xterm_seq(aR_ XTerm_iconName, R->rs[Rs_iconName], CHAR_ST); 1210 rxvt_xterm_seq (this, XTerm_iconName, rs[Rs_iconName], CHAR_ST);
1200 1211
1201 classHint.res_name = (char *)R->rs[Rs_name]; 1212 classHint.res_name = (char *)rs[Rs_name];
1202 classHint.res_class = (char *)APL_CLASS; 1213 classHint.res_class = (char *)APL_CLASS;
1203 1214
1204 wmHint.flags = (InputHint | StateHint | WindowGroupHint); 1215 wmHint.flags = (InputHint | StateHint | WindowGroupHint);
1205 wmHint.input = True; 1216 wmHint.input = True;
1206 wmHint.initial_state = (R->Options & Opt_iconic ? IconicState 1217 wmHint.initial_state = (Options & Opt_iconic ? IconicState
1207 : NormalState); 1218 : NormalState);
1208 wmHint.window_group = R->TermWin.parent[0]; 1219 wmHint.window_group = TermWin.parent[0];
1209 1220
1210 XSetWMProperties(R->Xdisplay, R->TermWin.parent[0], NULL, NULL, 1221 XSetWMProperties(Xdisplay, TermWin.parent[0], NULL, NULL,
1211 (char **)argv, argc, &R->szHint, &wmHint, &classHint); 1222 (char **)argv, argc, &szHint, &wmHint, &classHint);
1212 XSelectInput(R->Xdisplay, R->TermWin.parent[0], 1223 XSelectInput(Xdisplay, TermWin.parent[0],
1213 (KeyPressMask 1224 (KeyPressMask
1214#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1225#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1215 | KeyReleaseMask 1226 | KeyReleaseMask
1216#endif 1227#endif
1217 | FocusChangeMask | VisibilityChangeMask 1228 | FocusChangeMask | VisibilityChangeMask
1218 | StructureNotifyMask)); 1229 | StructureNotifyMask));
1219 1230
1220 /* vt cursor: Black-on-White is standard, but this is more popular */ 1231 /* vt cursor: Black-on-White is standard, but this is more popular */
1221 R->TermWin_cursor = XCreateFontCursor(R->Xdisplay, XC_xterm); 1232 TermWin_cursor = XCreateFontCursor(Xdisplay, XC_xterm);
1222 1233
1223#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 1234#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
1224 /* cursor (menuBar/scrollBar): Black-on-White */ 1235 /* cursor (menuBar/scrollBar): Black-on-White */
1225 R->leftptr_cursor = XCreateFontCursor(R->Xdisplay, XC_left_ptr); 1236 leftptr_cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
1226#endif 1237#endif
1227 1238
1228#ifdef POINTER_BLANK 1239#ifdef POINTER_BLANK
1229 1240
1230 { 1241 {
1231 XColor blackcolour; 1242 XColor blackcolour;
1232 blackcolour.red = 0; 1243 blackcolour.red = 0;
1233 blackcolour.green = 0; 1244 blackcolour.green = 0;
1234 blackcolour.blue = 0; 1245 blackcolour.blue = 0;
1235 Font f = XLoadFont (R->Xdisplay, "fixed"); 1246 Font f = XLoadFont (Xdisplay, "fixed");
1236 R->blank_cursor = XCreateGlyphCursor (R->Xdisplay, f, f, ' ', ' ', 1247 blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ',
1237 &blackcolour, &blackcolour); 1248 &blackcolour, &blackcolour);
1238 XUnloadFont (R->Xdisplay, f); 1249 XUnloadFont (Xdisplay, f);
1239 } 1250 }
1240#endif 1251#endif
1241 1252
1242 /* the vt window */ 1253 /* the vt window */
1243 R->TermWin.vt = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], 1254 TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1244 R->window_vt_x, R->window_vt_y, 1255 window_vt_x, window_vt_y,
1245 TermWin_TotalWidth(), 1256 TermWin_TotalWidth(),
1246 TermWin_TotalHeight(), 1257 TermWin_TotalHeight(),
1247 0, 1258 0,
1248 R->PixColors[Color_fg], 1259 PixColors[Color_fg],
1249 R->PixColors[Color_bg]); 1260 PixColors[Color_bg]);
1250#ifdef DEBUG_X 1261#ifdef DEBUG_X
1251 1262
1252 XStoreName(R->Xdisplay, R->TermWin.vt, "vt window"); 1263 XStoreName(Xdisplay, TermWin.vt, "vt window");
1253#endif 1264#endif
1254 1265
1255 R->pointer_unblank (); 1266 pointer_unblank ();
1256 1267
1257 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask 1268 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask
1258 | PropertyChangeMask); 1269 | PropertyChangeMask);
1259#ifdef POINTER_BLANK 1270#ifdef POINTER_BLANK
1260 1271
1261 if ((R->Options & Opt_pointerBlank)) 1272 if ((Options & Opt_pointerBlank))
1262 vt_emask |= PointerMotionMask; 1273 vt_emask |= PointerMotionMask;
1263 else 1274 else
1264#endif 1275#endif
1265 1276
1266 vt_emask |= (Button1MotionMask | Button3MotionMask); 1277 vt_emask |= (Button1MotionMask | Button3MotionMask);
1267 XSelectInput(R->Xdisplay, R->TermWin.vt, vt_emask); 1278 XSelectInput(Xdisplay, TermWin.vt, vt_emask);
1268 1279
1269#if defined(MENUBAR) && (MENUBAR_MAX > 1) 1280#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1270 1281
1271 if (menuBar_height()) 1282 if (menuBar_height())
1272 { 1283 {
1273 R->menuBar.win = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], 1284 menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1274 R->window_vt_x, 0, 1285 window_vt_x, 0,
1275 TermWin_TotalWidth(), 1286 TermWin_TotalWidth(),
1276 menuBar_TotalHeight(), 1287 menuBar_TotalHeight(),
1277 0, 1288 0,
1278 R->PixColors[Color_fg], 1289 PixColors[Color_fg],
1279 R->PixColors[Color_scroll]); 1290 PixColors[Color_scroll]);
1280#ifdef DEBUG_X 1291#ifdef DEBUG_X
1281 1292
1282 XStoreName(R->Xdisplay, R->menuBar.win, "menubar"); 1293 XStoreName(Xdisplay, menuBar.win, "menubar");
1283#endif 1294#endif
1284 1295
1285 XDefineCursor(R->Xdisplay, R->menuBar.win, R->pointer_leftptr); 1296 XDefineCursor(Xdisplay, menuBar.win, pointer_leftptr);
1286 XSelectInput(R->Xdisplay, R->menuBar.win, 1297 XSelectInput(Xdisplay, menuBar.win,
1287 (ExposureMask | ButtonPressMask | ButtonReleaseMask 1298 (ExposureMask | ButtonPressMask | ButtonReleaseMask
1288 | Button1MotionMask)); 1299 | Button1MotionMask));
1289 } 1300 }
1290#endif 1301#endif
1291#ifdef XPM_BACKGROUND 1302#ifdef XPM_BACKGROUND
1292 if (R->rs[Rs_backgroundPixmap] != NULL 1303 if (rs[Rs_backgroundPixmap] != NULL
1293 && !(R->Options & Opt_transparent)) 1304 && !(Options & Opt_transparent))
1294 { 1305 {
1295 const char *p = R->rs[Rs_backgroundPixmap]; 1306 const char *p = rs[Rs_backgroundPixmap];
1296 1307
1297 if ((p = STRCHR(p, ';')) != NULL) 1308 if ((p = STRCHR(p, ';')) != NULL)
1298 { 1309 {
1299 p++; 1310 p++;
1300 rxvt_scale_pixmap(aR_ p); 1311 rxvt_scale_pixmap (this, p);
1301 } 1312 }
1302 rxvt_set_bgPixmap(aR_ R->rs[Rs_backgroundPixmap]); 1313 rxvt_set_bgPixmap (this, rs[Rs_backgroundPixmap]);
1303 rxvt_scr_touch(aR_ True); 1314 rxvt_scr_touch (this, True);
1304 } 1315 }
1305#endif 1316#endif
1306 1317
1307 /* graphics context for the vt window */ 1318 /* graphics context for the vt window */
1308 gcvalue.foreground = R->PixColors[Color_fg]; 1319 gcvalue.foreground = PixColors[Color_fg];
1309 gcvalue.background = R->PixColors[Color_bg]; 1320 gcvalue.background = PixColors[Color_bg];
1310 gcvalue.graphics_exposures = 1; 1321 gcvalue.graphics_exposures = 1;
1311 R->TermWin.gc = XCreateGC(R->Xdisplay, R->TermWin.vt, 1322 TermWin.gc = XCreateGC(Xdisplay, TermWin.vt,
1312 GCForeground | GCBackground 1323 GCForeground | GCBackground
1313 | GCGraphicsExposures, &gcvalue); 1324 | GCGraphicsExposures, &gcvalue);
1314 1325
1315#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1326#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
1316 1327
1317 gcvalue.foreground = R->PixColors[Color_topShadow]; 1328 gcvalue.foreground = PixColors[Color_topShadow];
1318 R->topShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1329 topShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1319 GCForeground, &gcvalue); 1330 GCForeground, &gcvalue);
1320 gcvalue.foreground = R->PixColors[Color_bottomShadow]; 1331 gcvalue.foreground = PixColors[Color_bottomShadow];
1321 R->botShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1332 botShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1322 GCForeground, &gcvalue); 1333 GCForeground, &gcvalue);
1323 gcvalue.foreground = R->PixColors[(XDEPTH <= 2 ? Color_fg 1334 gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg
1324 : Color_scroll)]; 1335 : Color_scroll)];
1325 R->scrollbarGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1336 scrollbarGC = XCreateGC(Xdisplay, TermWin.vt,
1326 GCForeground, &gcvalue); 1337 GCForeground, &gcvalue);
1327#endif 1338#endif
1328} 1339}
1329 1340
1330/*----------------------------------------------------------------------*/ 1341/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines