summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/windowmanager-sdl.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2010-10-18 22:22:50 +0200
committerRaphael Langella <raphael.langella@gmail.com>2010-10-18 22:22:50 +0200
commit0abe7ac4eaed3c056b1ef6dbf8af1e8ed13e87fb (patch)
tree90e7a0ef9330f78fd75aaf365c76b36b4f8d9ec9 /crawl-ref/source/windowmanager-sdl.cc
parentcb4e4dcd0f90cdab2e8f67d9b18e306f9439053c (diff)
downloadcrawl-ref-0abe7ac4eaed3c056b1ef6dbf8af1e8ed13e87fb.tar.gz
crawl-ref-0abe7ac4eaed3c056b1ef6dbf8af1e8ed13e87fb.zip
remove tile_align_at_top option (much better taskbar overlap fix)
taskbar overlap is now automatically detected, and the window is placed just above it.
Diffstat (limited to 'crawl-ref/source/windowmanager-sdl.cc')
-rw-r--r--crawl-ref/source/windowmanager-sdl.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/crawl-ref/source/windowmanager-sdl.cc b/crawl-ref/source/windowmanager-sdl.cc
index 61de5f5f57..2d05d053e1 100644
--- a/crawl-ref/source/windowmanager-sdl.cc
+++ b/crawl-ref/source/windowmanager-sdl.cc
@@ -11,6 +11,7 @@
#include "cio.h"
#include "files.h"
#include "glwrapper.h"
+#include "libutil.h"
#include "options.h"
#include "windowmanager.h"
@@ -246,6 +247,7 @@ int SDLWrapper::init(coord_def *m_windowsz)
video_info = SDL_GetVideoInfo();
_desktop_width = video_info->current_w;
+ _desktop_height = video_info->current_h;
SDL_EnableUNICODE(true);
@@ -293,6 +295,26 @@ int SDLWrapper::init(coord_def *m_windowsz)
m_windowsz->y = std::max(480, y);
}
+#ifdef TARGET_OS_WINDOWS
+ // We check if the window overlap the taskbar. If it does, we place the
+ // window just above the taskbar.
+ int delta_x = (wm->desktop_width() - m_windowsz->x) / 2;
+ int taskbar_height = get_taskbar_height();
+ taskbar_height += 8; // Some margin for the window border.
+ if ((wm->desktop_height() - m_windowsz->y) / 2 < taskbar_height)
+ {
+ char env_str[50];
+ sprintf(env_str, "SDL_VIDEO_WINDOW_POS=%d,%d", delta_x,
+ wm->desktop_height() - m_windowsz->y - taskbar_height);
+ putenv(env_str);
+ }
+ else
+ {
+ putenv("SDL_VIDEO_WINDOW_POS=center");
+ putenv("SDL_VIDEO_CENTERED=1");
+ }
+#endif
+
m_context = SDL_SetVideoMode(m_windowsz->x, m_windowsz->y, 0, flags);
if (!m_context)
{
@@ -318,6 +340,11 @@ int SDLWrapper::desktop_width() const
return (_desktop_width);
}
+int SDLWrapper::desktop_height() const
+{
+ return (_desktop_height);
+}
+
void SDLWrapper::set_window_title(const char *title)
{
SDL_WM_SetCaption(title, CRAWL);