CTWM
Loading...
Searching...
No Matches
/usr/src/RPM/BUILD/ctwm-4.1.0/xparsegeometry.c
Go to the documentation of this file.
1/*
2 * Copyright notice...
3 */
4
5#include "ctwm.h"
6
7#include <string.h>
8#include <X11/Xlib.h>
9#include <X11/Xutil.h>
10
11#include "r_layout.h"
12#include "r_area.h"
13#include "xparsegeometry.h"
14
15
16/**
17 * Parse an X Geometry out to get the positions and sizes.
18 *
19 * This generally wraps and replaces our uses of XParseGeometry in order
20 * to allow positioning relative to a XRANDR output name. This allows
21 * specifying a geometry relative to a particular monitor, rather than on
22 * the whole composite multi-screen output meta-display.
23 */
24int
25RLayoutXParseGeometry(RLayout *layout, const char *geometry, int *x, int *y,
26 unsigned int *width, unsigned int *height)
27{
28 char *sep;
29
30 // Got something that looks like a display?
31 sep = strchr(geometry, ':');
32 if(sep != NULL) {
33 RArea mon = RLayoutGetAreaByName(layout, geometry, sep - geometry);
34 if(RAreaIsValid(&mon)) {
35 // Yep, one of our monitors; figure the placement on our
36 // whole root where that part of this monitor lies.
37 int mask = XParseGeometry(sep + 1, x, y, width, height);
39
40 if(mask & XValue) {
41 if(mask & XNegative) {
42 *x -= big.width - mon.width - (mon.x - big.x);
43 }
44 else {
45 *x += mon.x - big.x;
46 }
47 }
48
49 if(mask & YValue) {
50 if(mask & YNegative) {
51 *y -= big.height - mon.height - (mon.y - big.y);
52 }
53 else {
54 *y += mon.y - big.y;
55 }
56 }
57
58 return mask;
59 }
60
61 // Name not found, keep the geometry part as-is
62 geometry = sep + 1;
63 }
64
65 return XParseGeometry(geometry, x, y, width, height);
66}
static int PlaceX
Definition add_window.c:82
int y
Definition menus.c:70
int x
Definition menus.c:69
bool RAreaIsValid(const RArea *self)
Is an RArea facially valid?
Definition r_area.c:63
RArea RLayoutGetAreaByName(const RLayout *self, const char *name, int len)
Return the RArea in self with the name given by the string of length len at name.
Definition r_layout.c:576
RArea RLayoutBigArea(const RLayout *self)
Generate maximal spanning RArea.
Definition r_layout.c:1010
A particular extent of space.
Definition r_structs.h:16
The layout of our display.
Definition r_structs.h:45
int RLayoutXParseGeometry(RLayout *layout, const char *geometry, int *x, int *y, unsigned int *width, unsigned int *height)
Parse an X Geometry out to get the positions and sizes.