--- rxvt-unicode/src/rxvtcolor.C 2004/02/21 20:33:40 1.8 +++ rxvt-unicode/src/rxvtcolor.C 2004/04/04 23:47:29 1.13 @@ -5,6 +5,23 @@ #include #include +class byteorder byteorder; + +byteorder::byteorder () +{ + union { + uint32_t u; + uint8_t b[4]; + } w; + + w.b[0] = 0x11; + w.b[1] = 0x22; + w.b[2] = 0x33; + w.b[3] = 0x44; + + e = w.u; +} + refcounted::refcounted (const char *id) { this->id = STRDUP (id); @@ -113,6 +130,9 @@ { display = XOpenDisplay (id); + if (!display) + return false; + screen = DefaultScreen (display); root = DefaultRootWindow (display); visual = DefaultVisual (display, screen); @@ -140,7 +160,7 @@ int fd = XConnectionNumber (display); x_ev.start (fd, EVENT_READ); - fcntl (fd, F_SETFL, FD_CLOEXEC); + fcntl (fd, F_SETFD, FD_CLOEXEC); XSelectInput (display, root, PropertyChangeMask); xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); @@ -154,7 +174,8 @@ { x_ev.stop (); - XCloseDisplay (display); + if (display) + XCloseDisplay (display); } void rxvt_display::im_change_cb () @@ -235,12 +256,18 @@ rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) { - // asprintf is a GNU and *BSD extension.. sorry... char *id; + int l, m; + + l = strlen (locale); + m = strlen (modifiers); - if (asprintf (&id, "%s\n%s", locale, modifiers) < 0) + if (!(id = (char *)malloc (l + m + 2))) return 0; + memcpy (id, locale, l); id[l] = '\n'; + memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; + rxvt_xim *xim = xims.get (id); free (id); @@ -253,6 +280,11 @@ xims.put (xim); } +Atom rxvt_display::atom (const char *name) +{ + return XInternAtom (display, name, False); +} + ///////////////////////////////////////////////////////////////////////////// template refcache;