From a51d8843b27c0fe59d999900354fdae44648db86 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 12 Jan 2004 17:30:09 +0000 Subject: [PATCH] * src/graphics.c: + Implemented caca_set_title() for X11 and Win32. * examples/cacaview.c: + Use caca_set_title() to set the window title to "cacaview". --- NOTES | 3 +++ examples/cacaview.c | 3 +++ src/caca.h | 1 + src/graphics.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/NOTES b/NOTES index 160df04..e02448e 100644 --- a/NOTES +++ b/NOTES @@ -196,3 +196,6 @@ $Id$ o Win32: we use GetConsoleScreenBufferInfo etc. There is an interesting tutorial here: http://www.adrianxw.dk/SoftwareSite/index.html + o Set terminal window title: + http://mail.gnome.org/archives/mc-devel/2003-January/msg00101.html + diff --git a/examples/cacaview.c b/examples/cacaview.c index a8b70d3..8d11e3d 100644 --- a/examples/cacaview.c +++ b/examples/cacaview.c @@ -84,6 +84,9 @@ int main(int argc, char **argv) return 1; } + /* Set the window title */ + caca_set_title("cacaview"); + /* Load items into playlist */ for(i = 1; i < argc; i++) { diff --git a/src/caca.h b/src/caca.h index a8617c5..aff667d 100644 --- a/src/caca.h +++ b/src/caca.h @@ -245,6 +245,7 @@ char const *caca_get_feature_name(enum caca_feature); unsigned int caca_get_rendertime(void); unsigned int caca_get_width(void); unsigned int caca_get_height(void); +int caca_set_title(char const *); void caca_refresh(void); void caca_end(void); /* @} */ diff --git a/src/graphics.c b/src/graphics.c index 1bd29af..1d61c8a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -937,6 +937,38 @@ int _caca_end_graphics(void) } #endif /* _DOXYGEN_SKIP_ME */ +/** \brief Set the window title. + * + * If libcaca runs in a window, try to change its title. This works with + * the X11 and Win32 drivers. + * + * \param title The desired window title. + * \return 0 upon success, a non-zero value if an error occurs. + */ +int caca_set_title(char const *title) +{ +#if defined(USE_X11) + if(_caca_driver == CACA_DRIVER_X11) + { + XStoreName(x11_dpy, x11_window, title); + } + else +#endif +#if defined(USE_WIN32) + if(_caca_driver == CACA_DRIVER_WIN32) + { + SetConsoleTitle(title); + } + else +#endif + { + /* Not supported */ + return -1; + } + + return 0; +} + /** \brief Set the refresh delay. * * This function sets the refresh delay in microseconds. The refresh delay