--- rxvt-unicode/src/rxvtcolor.C 2004/03/30 14:45:13 1.11 +++ rxvt-unicode/src/rxvtcolor.C 2004/07/29 14:05:27 1.16 @@ -1,3 +1,25 @@ +/*--------------------------------*-C-*---------------------------------* + * File: rxvtcolor.C + *----------------------------------------------------------------------* + * + * All portions of code are copyright by their respective author/s. + * Copyright (c) 2003-2004 Marc Lehmann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *----------------------------------------------------------------------*/ + #include "../config.h" #include #include @@ -35,7 +57,7 @@ template T *refcache::get (const char *id) { - for (T **i = begin (); i < end (); ++i) + for (T **i = this->begin (); i < this->end (); ++i) { if (!strcmp (id, (*i)->id)) { @@ -50,7 +72,7 @@ if (obj && obj->init ()) { - push_back (obj); + this->push_back (obj); return obj; } else @@ -68,7 +90,7 @@ if (!--obj->referenced) { - erase (find (begin (), end (), obj)); + this->erase (find (this->begin (), this->end (), obj)); delete obj; } } @@ -76,12 +98,13 @@ template refcache::~refcache () { - while (size ()) - put (*begin ()); + while (this->size ()) + put (*this->begin ()); } ///////////////////////////////////////////////////////////////////////////// +#ifdef USE_XIM static void im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) { @@ -116,6 +139,7 @@ if (xim) XCloseIM (xim); } +#endif ///////////////////////////////////////////////////////////////////////////// @@ -160,10 +184,12 @@ 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); +#ifdef USE_XIM xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); +#endif flush (); @@ -178,11 +204,13 @@ XCloseDisplay (display); } +#ifdef USE_XIM void rxvt_display::im_change_cb () { for (im_watcher **i = imw.begin (); i != imw.end (); ++i) (*i)->call (); } +#endif void rxvt_display::x_cb (io_watcher &w, short revents) { @@ -193,10 +221,12 @@ //printf ("T %d w %lx\n", xev.type, xev.xany.window);//D +#ifdef USE_XIM if (xev.type == PropertyNotify && xev.xany.window == root && xev.xproperty.atom == xa_xim_servers) im_change_cb (); +#endif for (int i = xw.size (); i--; ) { @@ -236,6 +266,15 @@ xw[w->active - 1] = 0; } +void rxvt_display::set_selection_owner (rxvt_term *owner) +{ + if (selection_owner && selection_owner != owner) + selection_owner->selection_clear (); + + selection_owner = owner; +} + +#ifdef USE_XIM void rxvt_display::reg (im_watcher *w) { imw.push_back (w); @@ -246,22 +285,20 @@ imw.erase (find (imw.begin (), imw.end (), w)); } -void rxvt_display::set_selection_owner (rxvt_term *owner) -{ - if (selection_owner && selection_owner != owner) - selection_owner->selection_clear (); - - selection_owner = owner; -} - 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; - if (asprintf (&id, "%s\n%s", locale, modifiers) < 0) + l = strlen (locale); + m = strlen (modifiers); + + 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); @@ -273,6 +310,7 @@ { xims.put (xim); } +#endif Atom rxvt_display::atom (const char *name) { @@ -281,7 +319,7 @@ ///////////////////////////////////////////////////////////////////////////// -template refcache; +template class refcache; refcache displays; /////////////////////////////////////////////////////////////////////////////