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.15 by pcg, Thu Dec 18 07:31:19 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.15 2003/12/18 07:31:19 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>
1127 R->ModMetaMask = modmasks[i - 1]; 1127 R->ModMetaMask = modmasks[i - 1];
1128} 1128}
1129 1129
1130/*----------------------------------------------------------------------*/ 1130/*----------------------------------------------------------------------*/
1131/* rxvt_Create_Windows() - Open and map the window */ 1131/* rxvt_Create_Windows() - Open and map the window */
1132/* EXTPROTO */
1133void 1132void
1134rxvt_Create_Windows(pR_ int argc, const char *const *argv) 1133rxvt_term::create_windows (int argc, const char *const *argv)
1135{ 1134{
1136 XClassHint classHint; 1135 XClassHint classHint;
1137 XWMHints wmHint; 1136 XWMHints wmHint;
1138 XGCValues gcvalue; 1137 XGCValues gcvalue;
1139 long vt_emask; 1138 long vt_emask;
1140 1139
1141#ifdef PREFER_24BIT 1140#ifdef PREFER_24BIT
1142 XSetWindowAttributes attributes; 1141 XSetWindowAttributes attributes;
1143 XWindowAttributes gattr; 1142 XWindowAttributes gattr;
1144 1143
1145 XCMAP = DefaultColormap(R->Xdisplay, Xscreen); 1144 XCMAP = DefaultColormap(Xdisplay, Xscreen);
1146 XVISUAL = DefaultVisual(R->Xdisplay, Xscreen); 1145 XVISUAL = DefaultVisual(Xdisplay, Xscreen);
1147 1146
1148 if (R->Options & Opt_transparent) 1147 if (Options & Opt_transparent)
1149 { 1148 {
1150 XGetWindowAttributes(R->Xdisplay, RootWindow(R->Xdisplay, Xscreen), 1149 XGetWindowAttributes(Xdisplay, RootWindow(Xdisplay, Xscreen),
1151 &gattr); 1150 &gattr);
1152 XDEPTH = gattr.depth; 1151 XDEPTH = gattr.depth;
1153 } 1152 }
1154 else 1153 else
1155 { 1154 {
1156 XDEPTH = DefaultDepth(R->Xdisplay, Xscreen); 1155 XDEPTH = DefaultDepth(Xdisplay, Xscreen);
1157 /* 1156 /*
1158 * If depth is not 24, look for a 24bit visual. 1157 * If depth is not 24, look for a 24bit visual.
1159 */ 1158 */
1160 if (XDEPTH != 24) 1159 if (XDEPTH != 24)
1161 { 1160 {
1162 XVisualInfo vinfo; 1161 XVisualInfo vinfo;
1163 1162
1164 if (XMatchVisualInfo(R->Xdisplay, Xscreen, 24, TrueColor, &vinfo)) 1163 if (XMatchVisualInfo(Xdisplay, Xscreen, 24, TrueColor, &vinfo))
1165 { 1164 {
1166 XDEPTH = 24; 1165 XDEPTH = 24;
1167 XVISUAL = vinfo.visual; 1166 XVISUAL = vinfo.visual;
1168 XCMAP = XCreateColormap(R->Xdisplay, 1167 XCMAP = XCreateColormap(Xdisplay,
1169 RootWindow(R->Xdisplay, Xscreen), 1168 RootWindow(Xdisplay, Xscreen),
1170 XVISUAL, AllocNone); 1169 XVISUAL, AllocNone);
1171 } 1170 }
1172 } 1171 }
1173 } 1172 }
1174#endif 1173#endif
1175 1174
1176 /* grab colors before netscape does */ 1175 /* grab colors before netscape does */
1177 rxvt_Get_Colours(aR); 1176 rxvt_Get_Colours (this);
1178 1177
1179 rxvt_change_font(aR_ 1, NULL); 1178 rxvt_change_font (this, 1, NULL);
1180 rxvt_window_calc(aR_ 0, 0); 1179 window_calc (0, 0);
1181 R->old_width = R->szHint.width; 1180 old_width = szHint.width;
1182 R->old_height = R->szHint.height; 1181 old_height = szHint.height;
1183 1182
1184 /* parent window - reverse video so we can see placement errors 1183 /* parent window - reverse video so we can see placement errors
1185 * sub-window placement & size in rxvt_resize_subwindows() 1184 * sub-window placement & size in rxvt_resize_subwindows()
1186 */ 1185 */
1187 1186
1188#ifdef PREFER_24BIT 1187#ifdef PREFER_24BIT
1189
1190 attributes.background_pixel = R->PixColors[Color_fg]; 1188 attributes.background_pixel = PixColors[Color_fg];
1191 attributes.border_pixel = R->PixColors[Color_border]; 1189 attributes.border_pixel = PixColors[Color_border];
1192 attributes.colormap = XCMAP; 1190 attributes.colormap = XCMAP;
1193 R->TermWin.parent[0] = XCreateWindow(R->Xdisplay, Xroot, 1191 TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1194 R->szHint.x, R->szHint.y, 1192 szHint.x, szHint.y,
1195 R->szHint.width, R->szHint.height, 1193 szHint.width, szHint.height,
1196 R->TermWin.ext_bwidth, 1194 TermWin.ext_bwidth,
1197 XDEPTH, InputOutput, 1195 XDEPTH, InputOutput,
1198 XVISUAL, 1196 XVISUAL,
1199 CWBackPixel | CWBorderPixel 1197 CWBackPixel | CWBorderPixel
1200 | CWColormap, &attributes); 1198 | CWColormap, &attributes);
1201#else 1199#else
1202
1203 R->TermWin.parent[0] = XCreateSimpleWindow(R->Xdisplay, Xroot, 1200 TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1204 R->szHint.x, R->szHint.y, 1201 szHint.x, szHint.y,
1205 R->szHint.width, 1202 szHint.width,
1206 R->szHint.height, 1203 szHint.height,
1207 R->TermWin.ext_bwidth, 1204 TermWin.ext_bwidth,
1208 R->PixColors[Color_border], 1205 PixColors[Color_border],
1209 R->PixColors[Color_fg]); 1206 PixColors[Color_fg]);
1210#endif 1207#endif
1211 1208
1212 rxvt_xterm_seq(aR_ XTerm_title, R->rs[Rs_title], CHAR_ST); 1209 rxvt_xterm_seq (this, XTerm_title, rs[Rs_title], CHAR_ST);
1213 rxvt_xterm_seq(aR_ XTerm_iconName, R->rs[Rs_iconName], CHAR_ST); 1210 rxvt_xterm_seq (this, XTerm_iconName, rs[Rs_iconName], CHAR_ST);
1214 1211
1215 classHint.res_name = (char *)R->rs[Rs_name]; 1212 classHint.res_name = (char *)rs[Rs_name];
1216 classHint.res_class = (char *)APL_CLASS; 1213 classHint.res_class = (char *)APL_CLASS;
1217 1214
1218 wmHint.flags = (InputHint | StateHint | WindowGroupHint); 1215 wmHint.flags = (InputHint | StateHint | WindowGroupHint);
1219 wmHint.input = True; 1216 wmHint.input = True;
1220 wmHint.initial_state = (R->Options & Opt_iconic ? IconicState 1217 wmHint.initial_state = (Options & Opt_iconic ? IconicState
1221 : NormalState); 1218 : NormalState);
1222 wmHint.window_group = R->TermWin.parent[0]; 1219 wmHint.window_group = TermWin.parent[0];
1223 1220
1224 XSetWMProperties(R->Xdisplay, R->TermWin.parent[0], NULL, NULL, 1221 XSetWMProperties(Xdisplay, TermWin.parent[0], NULL, NULL,
1225 (char **)argv, argc, &R->szHint, &wmHint, &classHint); 1222 (char **)argv, argc, &szHint, &wmHint, &classHint);
1226 XSelectInput(R->Xdisplay, R->TermWin.parent[0], 1223 XSelectInput(Xdisplay, TermWin.parent[0],
1227 (KeyPressMask 1224 (KeyPressMask
1228#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1225#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1229 | KeyReleaseMask 1226 | KeyReleaseMask
1230#endif 1227#endif
1231 | FocusChangeMask | VisibilityChangeMask 1228 | FocusChangeMask | VisibilityChangeMask
1232 | StructureNotifyMask)); 1229 | StructureNotifyMask));
1233 1230
1234 /* 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 */
1235 R->TermWin_cursor = XCreateFontCursor(R->Xdisplay, XC_xterm); 1232 TermWin_cursor = XCreateFontCursor(Xdisplay, XC_xterm);
1236 1233
1237#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 1234#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
1238 /* cursor (menuBar/scrollBar): Black-on-White */ 1235 /* cursor (menuBar/scrollBar): Black-on-White */
1239 R->leftptr_cursor = XCreateFontCursor(R->Xdisplay, XC_left_ptr); 1236 leftptr_cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
1240#endif 1237#endif
1241 1238
1242#ifdef POINTER_BLANK 1239#ifdef POINTER_BLANK
1243 1240
1244 { 1241 {
1245 XColor blackcolour; 1242 XColor blackcolour;
1246 blackcolour.red = 0; 1243 blackcolour.red = 0;
1247 blackcolour.green = 0; 1244 blackcolour.green = 0;
1248 blackcolour.blue = 0; 1245 blackcolour.blue = 0;
1249 Font f = XLoadFont (R->Xdisplay, "fixed"); 1246 Font f = XLoadFont (Xdisplay, "fixed");
1250 R->blank_cursor = XCreateGlyphCursor (R->Xdisplay, f, f, ' ', ' ', 1247 blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ',
1251 &blackcolour, &blackcolour); 1248 &blackcolour, &blackcolour);
1252 XUnloadFont (R->Xdisplay, f); 1249 XUnloadFont (Xdisplay, f);
1253 } 1250 }
1254#endif 1251#endif
1255 1252
1256 /* the vt window */ 1253 /* the vt window */
1257 R->TermWin.vt = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], 1254 TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1258 R->window_vt_x, R->window_vt_y, 1255 window_vt_x, window_vt_y,
1259 TermWin_TotalWidth(), 1256 TermWin_TotalWidth(),
1260 TermWin_TotalHeight(), 1257 TermWin_TotalHeight(),
1261 0, 1258 0,
1262 R->PixColors[Color_fg], 1259 PixColors[Color_fg],
1263 R->PixColors[Color_bg]); 1260 PixColors[Color_bg]);
1264#ifdef DEBUG_X 1261#ifdef DEBUG_X
1265 1262
1266 XStoreName(R->Xdisplay, R->TermWin.vt, "vt window"); 1263 XStoreName(Xdisplay, TermWin.vt, "vt window");
1267#endif 1264#endif
1268 1265
1269 R->pointer_unblank (); 1266 pointer_unblank ();
1270 1267
1271 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask 1268 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask
1272 | PropertyChangeMask); 1269 | PropertyChangeMask);
1273#ifdef POINTER_BLANK 1270#ifdef POINTER_BLANK
1274 1271
1275 if ((R->Options & Opt_pointerBlank)) 1272 if ((Options & Opt_pointerBlank))
1276 vt_emask |= PointerMotionMask; 1273 vt_emask |= PointerMotionMask;
1277 else 1274 else
1278#endif 1275#endif
1279 1276
1280 vt_emask |= (Button1MotionMask | Button3MotionMask); 1277 vt_emask |= (Button1MotionMask | Button3MotionMask);
1281 XSelectInput(R->Xdisplay, R->TermWin.vt, vt_emask); 1278 XSelectInput(Xdisplay, TermWin.vt, vt_emask);
1282 1279
1283#if defined(MENUBAR) && (MENUBAR_MAX > 1) 1280#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1284 1281
1285 if (menuBar_height()) 1282 if (menuBar_height())
1286 { 1283 {
1287 R->menuBar.win = XCreateSimpleWindow(R->Xdisplay, R->TermWin.parent[0], 1284 menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1288 R->window_vt_x, 0, 1285 window_vt_x, 0,
1289 TermWin_TotalWidth(), 1286 TermWin_TotalWidth(),
1290 menuBar_TotalHeight(), 1287 menuBar_TotalHeight(),
1291 0, 1288 0,
1292 R->PixColors[Color_fg], 1289 PixColors[Color_fg],
1293 R->PixColors[Color_scroll]); 1290 PixColors[Color_scroll]);
1294#ifdef DEBUG_X 1291#ifdef DEBUG_X
1295 1292
1296 XStoreName(R->Xdisplay, R->menuBar.win, "menubar"); 1293 XStoreName(Xdisplay, menuBar.win, "menubar");
1297#endif 1294#endif
1298 1295
1299 XDefineCursor(R->Xdisplay, R->menuBar.win, R->pointer_leftptr); 1296 XDefineCursor(Xdisplay, menuBar.win, pointer_leftptr);
1300 XSelectInput(R->Xdisplay, R->menuBar.win, 1297 XSelectInput(Xdisplay, menuBar.win,
1301 (ExposureMask | ButtonPressMask | ButtonReleaseMask 1298 (ExposureMask | ButtonPressMask | ButtonReleaseMask
1302 | Button1MotionMask)); 1299 | Button1MotionMask));
1303 } 1300 }
1304#endif 1301#endif
1305#ifdef XPM_BACKGROUND 1302#ifdef XPM_BACKGROUND
1306 if (R->rs[Rs_backgroundPixmap] != NULL 1303 if (rs[Rs_backgroundPixmap] != NULL
1307 && !(R->Options & Opt_transparent)) 1304 && !(Options & Opt_transparent))
1308 { 1305 {
1309 const char *p = R->rs[Rs_backgroundPixmap]; 1306 const char *p = rs[Rs_backgroundPixmap];
1310 1307
1311 if ((p = STRCHR(p, ';')) != NULL) 1308 if ((p = STRCHR(p, ';')) != NULL)
1312 { 1309 {
1313 p++; 1310 p++;
1314 rxvt_scale_pixmap(aR_ p); 1311 rxvt_scale_pixmap (this, p);
1315 } 1312 }
1316 rxvt_set_bgPixmap(aR_ R->rs[Rs_backgroundPixmap]); 1313 rxvt_set_bgPixmap (this, rs[Rs_backgroundPixmap]);
1317 rxvt_scr_touch(aR_ True); 1314 rxvt_scr_touch (this, True);
1318 } 1315 }
1319#endif 1316#endif
1320 1317
1321 /* graphics context for the vt window */ 1318 /* graphics context for the vt window */
1322 gcvalue.foreground = R->PixColors[Color_fg]; 1319 gcvalue.foreground = PixColors[Color_fg];
1323 gcvalue.background = R->PixColors[Color_bg]; 1320 gcvalue.background = PixColors[Color_bg];
1324 gcvalue.graphics_exposures = 1; 1321 gcvalue.graphics_exposures = 1;
1325 R->TermWin.gc = XCreateGC(R->Xdisplay, R->TermWin.vt, 1322 TermWin.gc = XCreateGC(Xdisplay, TermWin.vt,
1326 GCForeground | GCBackground 1323 GCForeground | GCBackground
1327 | GCGraphicsExposures, &gcvalue); 1324 | GCGraphicsExposures, &gcvalue);
1328 1325
1329#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1326#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
1330 1327
1331 gcvalue.foreground = R->PixColors[Color_topShadow]; 1328 gcvalue.foreground = PixColors[Color_topShadow];
1332 R->topShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1329 topShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1333 GCForeground, &gcvalue); 1330 GCForeground, &gcvalue);
1334 gcvalue.foreground = R->PixColors[Color_bottomShadow]; 1331 gcvalue.foreground = PixColors[Color_bottomShadow];
1335 R->botShadowGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1332 botShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1336 GCForeground, &gcvalue); 1333 GCForeground, &gcvalue);
1337 gcvalue.foreground = R->PixColors[(XDEPTH <= 2 ? Color_fg 1334 gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg
1338 : Color_scroll)]; 1335 : Color_scroll)];
1339 R->scrollbarGC = XCreateGC(R->Xdisplay, R->TermWin.vt, 1336 scrollbarGC = XCreateGC(Xdisplay, TermWin.vt,
1340 GCForeground, &gcvalue); 1337 GCForeground, &gcvalue);
1341#endif 1338#endif
1342} 1339}
1343 1340
1344/*----------------------------------------------------------------------*/ 1341/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines