From a65f840b68aabf79df22aedc729c53c8ebd0fbe6 Mon Sep 17 00:00:00 2001 From: mathias Date: Mon, 22 Nov 2004 20:10:26 +0000 Subject: dont overlap with screenborder added xinerama-support --- util/fbrun/main.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/util/fbrun/main.cc b/util/fbrun/main.cc index f032486..c808628 100644 --- a/util/fbrun/main.cc +++ b/util/fbrun/main.cc @@ -26,6 +26,12 @@ #include "StringUtil.hh" #include "Color.hh" +#ifdef XINERAMA +extern "C" { +#include +} +#endif // XINERAMA + #include #include @@ -158,10 +164,44 @@ int main(int argc, char **argv) { &ret_win, &child_win, &x, &y, &wx, &wy, &mask)) { - if ( x - (fbrun.width()/2) > 0 ) - x-= fbrun.width()/2; - if ( y - (fbrun.height()/2) > 0 ) - y-= fbrun.height()/2; + int root_x = 0; + int root_y = 0; + unsigned int root_w = WidthOfScreen(DefaultScreenOfDisplay(dpy)); + unsigned int root_h = HeightOfScreen(DefaultScreenOfDisplay(dpy)); +#ifdef XINERAMA + if(XineramaIsActive(dpy)) { + XineramaScreenInfo* screen_info = 0; + int number = 0; + screen_info = XineramaQueryScreens(dpy, &number); + if (screen_info) { + for(int i= 0; i < number; i++) { + if (x >= screen_info[i].x_org && + x < screen_info[i].x_org + screen_info[i].width && + y >= screen_info[i].y_org && + y < screen_info[i].y_org + screen_info[i].height) { + root_x = screen_info[i].x_org; + root_y = screen_info[i].y_org; + root_w = screen_info[i].width; + root_h = screen_info[i].height; + break; + } + } + + XFree(screen_info); + } + } +#endif // XINERAMA + x-= fbrun.width()/2; + y-= fbrun.height()/2; + + if (x < root_x) + x = root_x; + if (x + fbrun.width() > root_x + root_w) + x = root_x + root_w - fbrun.width(); + if (y < root_y) + y = root_y; + if (y + fbrun.height() > root_y + root_h) + y = root_y + root_h - fbrun.height(); } } -- cgit v0.11.2