diff --git a/src/E.h b/src/E.h index 7865890d..20ec45eb 100644 --- a/src/E.h +++ b/src/E.h @@ -795,18 +795,6 @@ void ProgressbarHide(Progressbar * p); /* regex.c */ int matchregexp(const char *rx, const char *s); -/* screen.c */ -void ScreenInit(void); -void ScreenShowInfo(void); -int ScreenGetGeometry(int x, int y, int *px, int *py, - int *pw, int *ph); -int ScreenGetAvailableArea(int x, int y, int *px, int *py, - int *pw, int *ph); -int GetPointerScreenGeometry(int *px, int *py, - int *pw, int *ph); -int GetPointerScreenAvailableArea(int *px, int *py, - int *pw, int *ph); - /* settings.c */ void SettingsMoveResize(void); void SettingsPlacement(void); diff --git a/src/Makefile.am b/src/Makefile.am index ab3a04f0..2b6b25dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -96,6 +96,7 @@ e16_SOURCES = \ progress.c \ regex.c \ screen.c \ + screen.h \ session.c \ session.h \ settings.c \ diff --git a/src/arrange.c b/src/arrange.c index 3e1bff1b..a2bfcef6 100644 --- a/src/arrange.c +++ b/src/arrange.c @@ -26,6 +26,7 @@ #include "desktops.h" #include "ewins.h" #include "groups.h" +#include "screen.h" static int ArrangeAddToList(int **array, int current_size, int value) diff --git a/src/ewin-ops.c b/src/ewin-ops.c index 3a457c71..28e39def 100644 --- a/src/ewin-ops.c +++ b/src/ewin-ops.c @@ -31,6 +31,7 @@ #include "groups.h" #include "hints.h" #include "iclass.h" /* FIXME - Should not be here */ +#include "screen.h" #include "snaps.h" #include "xwin.h" diff --git a/src/ipc.c b/src/ipc.c index c80fc349..2b90eb8a 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -30,6 +30,7 @@ #include "ewins.h" #include "ewin-ops.h" #include "hints.h" /* FIXME - Should not be here */ +#include "screen.h" #include "session.h" #include "snaps.h" #include "timers.h" @@ -133,9 +134,36 @@ SetEwinBoolean(const char *txt, char *item, const char *value, int set) /* The IPC functions */ static void -IPC_Screen(const char *params __UNUSED__, Client * c __UNUSED__) +IPC_Screen(const char *params, Client * c __UNUSED__) { - ScreenShowInfo(); + char param[1024]; + int l; + const char *p; + + p = params; + if (p) + { + l = 0; + sscanf(p, "%1000s %n", param, &l); + p += l; + } + + if (!p || !strncmp(param, "list", 2)) + { + ScreenShowInfo(p); + } + else if (!strcmp(param, "split")) + { + int i, j, nx, ny; + + nx = 2; + ny = 1; + sscanf(p, "%i %i\n", &nx, &ny); + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) + ScreenAdd(1, VRoot.scr, i * VRoot.w / nx, j * VRoot.h / ny, + VRoot.w / nx, VRoot.h / ny); + } } static void diff --git a/src/menus.c b/src/menus.c index e3968bef..b8653637 100644 --- a/src/menus.c +++ b/src/menus.c @@ -32,6 +32,7 @@ #include "hints.h" #include "iclass.h" #include "menus.h" +#include "screen.h" #include "tclass.h" #include "timers.h" #include "tooltips.h" diff --git a/src/screen.c b/src/screen.c index 625d5c4b..71b02757 100644 --- a/src/screen.c +++ b/src/screen.c @@ -23,51 +23,83 @@ */ #include "E.h" #include "ewins.h" +#include "screen.h" #include "xwin.h" #ifdef HAS_XINERAMA #include #endif -#ifdef HAS_XINERAMA -static XineramaScreenInfo *screens = NULL; -static int num_screens = 0; -#endif +typedef struct +{ + int type; + int head; + int x, y; + int w, h; +} EScreen; + +static EScreen *p_screens = NULL; +static int n_screens = 0; + +void +ScreenAdd(int type, int head, int x, int y, unsigned int w, unsigned int h) +{ + EScreen *es; + + n_screens++; + p_screens = Erealloc(p_screens, n_screens * sizeof(EScreen)); + + es = p_screens + n_screens - 1; + es->type = type; + es->head = head; + es->x = x; + es->y = y; + es->w = w; + es->h = h; +} void ScreenInit(void) { +#ifdef HAS_XINERAMA + XineramaScreenInfo *screens = NULL; + int num_screens = 0; + int i; + if (Mode.wm.window) return; -#ifdef HAS_XINERAMA + Mode.display.xinerama_active = XineramaIsActive(disp); Conf.extra_head = 0; if (Mode.display.xinerama_active) screens = XineramaQueryScreens(disp, &num_screens); + + for (i = 0; i < num_screens; i++) + ScreenAdd(0, screens[i].screen_number, screens[i].x_org, + screens[i].y_org, screens[i].width, screens[i].height); #endif } void -ScreenShowInfo(void) +ScreenShowInfo(const char *prm __UNUSED__) { + int i; + #ifdef HAS_XINERAMA - if (Mode.display.xinerama_active) + if (XineramaIsActive(disp)) { XineramaScreenInfo *scrns; - int num, i; + int num; scrns = XineramaQueryScreens(disp, &num); - IpcPrintf("Xinerama active:\n"); + IpcPrintf("Xinerama screens:\n"); IpcPrintf("Head Screen X-Origin Y-Origin Width Height\n"); for (i = 0; i < num; i++) - { - IpcPrintf(" %2d %2d %5d %5d %5d %5d\n", - i, scrns[i].screen_number, - scrns[i].x_org, scrns[i].y_org, scrns[i].width, - scrns[i].height); - } + IpcPrintf(" %2d %2d %5d %5d %5d %5d\n", + i, scrns[i].screen_number, + scrns[i].x_org, scrns[i].y_org, scrns[i].width, + scrns[i].height); XFree(scrns); - return; } else { @@ -75,9 +107,23 @@ ScreenShowInfo(void) } #endif + IpcPrintf("E-screens:\n"); IpcPrintf("Head Screen X-Origin Y-Origin Width Height\n"); - IpcPrintf(" %2d %2d %5d %5d %5d %5d\n", - 0, VRoot.scr, 0, 0, VRoot.w, VRoot.h); + if (n_screens) + { + for (i = 0; i < n_screens; i++) + { + EScreen *ps = p_screens + i; + + IpcPrintf(" %2d %2d %5d %5d %5d %5d\n", + i, ps->head, ps->x, ps->y, ps->w, ps->h); + } + } + else + { + IpcPrintf(" %2d %2d %5d %5d %5d %5d\n", + 0, VRoot.scr, 0, 0, VRoot.w, VRoot.h); + } } int @@ -92,29 +138,27 @@ ScreenGetGeometry(int xi, int yi, int *px, int *py, int *pw, int *ph) w = VRoot.w; h = VRoot.h; -#ifdef HAS_XINERAMA - if (Mode.display.xinerama_active) + if (n_screens > 1) { int i; - for (i = 0; i < num_screens; i++) + for (i = 0; i < n_screens; i++) { - XineramaScreenInfo *ps = &screens[i]; + EScreen *ps = p_screens + i; - if (xi >= ps->x_org && xi < ps->x_org + ps->width && - yi >= ps->y_org && yi < ps->y_org + ps->height) + if (xi >= ps->x && xi < ps->x + ps->w && + yi >= ps->y && yi < ps->y + ps->h) { - x = ps->x_org; - y = ps->y_org; - w = ps->width; - h = ps->height; - head = i; + x = ps->x; + y = ps->y; + w = ps->w; + h = ps->h; + head = ps->head; /* NB! *First* matching head is used */ break; } } } -#endif if (px) *px = x; diff --git a/src/screen.h b/src/screen.h new file mode 100644 index 00000000..bf25ed7c --- /dev/null +++ b/src/screen.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2006 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _SCREEN_H_ +#define _SCREEN_H_ + +/* screen.c */ +void ScreenInit(void); +void ScreenAdd(int type, int head, int x, int y, unsigned int w, + unsigned int h); +void ScreenShowInfo(const char *prm); +int ScreenGetGeometry(int x, int y, int *px, int *py, + int *pw, int *ph); +int ScreenGetAvailableArea(int x, int y, int *px, int *py, + int *pw, int *ph); +int GetPointerScreenGeometry(int *px, int *py, + int *pw, int *ph); +int GetPointerScreenAvailableArea(int *px, int *py, + int *pw, int *ph); + +#endif /* _SCREEN_H_ */ diff --git a/src/setup.c b/src/setup.c index 6b9f3e1b..d7cf1eb0 100644 --- a/src/setup.c +++ b/src/setup.c @@ -24,6 +24,7 @@ #include "E.h" #include "eimage.h" #include "ewins.h" +#include "screen.h" #include "xwin.h" #include #include diff --git a/src/size.c b/src/size.c index 4b6903df..1d1a3c1a 100644 --- a/src/size.c +++ b/src/size.c @@ -24,6 +24,7 @@ #include "E.h" #include "ewins.h" #include "hints.h" +#include "screen.h" #define MAX_HOR 0x1 #define MAX_VER 0x2 diff --git a/src/warp.c b/src/warp.c index c73e893c..8014570c 100644 --- a/src/warp.c +++ b/src/warp.c @@ -36,6 +36,7 @@ #include "ewins.h" #include "iclass.h" #include "icons.h" +#include "screen.h" #include "tclass.h" #include "tooltips.h" #include "xwin.h"