From e04a8fdc3a0cf0c562242344717fc6b67903829d Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 19 Jul 2011 23:56:16 -0500 Subject: MAEMO: fix task switcher window title --- backends/platform/maemo/maemo.cpp | 40 +++++++++++++++++++++++++++++++++++++++ backends/platform/maemo/maemo.h | 6 +++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 81a7ebb1b7..8362c0785e 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -28,6 +28,9 @@ #include "backends/events/maemosdl/maemosdl-events.h" #include "common/textconsole.h" +#include +#include + OSystem_SDL_Maemo::OSystem_SDL_Maemo() : OSystem_POSIX() { @@ -50,4 +53,41 @@ void OSystem_SDL_Maemo::fatalError() { delete this; } +void OSystem_SDL_Maemo::setXWindowName(const char *caption) { + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) { + Display *dpy = info.info.x11.display; + Window win; + win = info.info.x11.fswindow; + if (win) XStoreName(dpy, win, caption); + win = info.info.x11.wmwindow; + if (win) XStoreName(dpy, win, caption); + } +} + +void OSystem_SDL_Maemo::setWindowCaption(const char *caption) { + Common::String cap; + byte c; + + // The string caption is supposed to be in LATIN-1 encoding. + // SDL expects UTF-8. So we perform the conversion here. + while ((c = *(const byte *)caption++)) { + if (c < 0x80) + cap += c; + else { + cap += 0xC0 | (c >> 6); + cap += 0x80 | (c & 0x3F); + } + } + + SDL_WM_SetCaption(cap.c_str(), cap.c_str()); + + Common::String cap2("ScummVM - "); // 2 lines in OS2008 task switcher, set first line + cap = cap2 + cap; + setXWindowName(cap.c_str()); +} + + + #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index dd8ba325ab..a7f2ec35bb 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -34,8 +34,12 @@ public: virtual void initBackend(); virtual void quit(); virtual void fatalError(); -}; + virtual void setWindowCaption(const char *caption); + +private: + virtual void setXWindowName(const char *caption); +}; #endif #endif -- cgit v1.2.3