Add feature to subdivide screen (xinerama style).

SVN revision: 22307
This commit is contained in:
Kim Woelders 2006-04-22 22:00:02 +00:00
parent f3ccd1aef0
commit 31f912bc83
11 changed files with 152 additions and 44 deletions

12
src/E.h
View File

@ -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);

View File

@ -96,6 +96,7 @@ e16_SOURCES = \
progress.c \
regex.c \
screen.c \
screen.h \
session.c \
session.h \
settings.c \

View File

@ -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)

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -23,51 +23,83 @@
*/
#include "E.h"
#include "ewins.h"
#include "screen.h"
#include "xwin.h"
#ifdef HAS_XINERAMA
#include <X11/extensions/Xinerama.h>
#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;

41
src/screen.h Normal file
View File

@ -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_ */

View File

@ -24,6 +24,7 @@
#include "E.h"
#include "eimage.h"
#include "ewins.h"
#include "screen.h"
#include "xwin.h"
#include <signal.h>
#include <X11/keysym.h>

View File

@ -24,6 +24,7 @@
#include "E.h"
#include "ewins.h"
#include "hints.h"
#include "screen.h"
#define MAX_HOR 0x1
#define MAX_VER 0x2

View File

@ -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"