CTWM
Toggle main menu visibility
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
*/
24
int
25
RLayoutXParseGeometry
(
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);
38
RArea
big =
RLayoutBigArea
(layout);
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
}
ctwm.h
RAreaIsValid
bool RAreaIsValid(const RArea *self)
Is an RArea facially valid?
Definition
r_area.c:63
r_area.h
RLayoutGetAreaByName
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
RLayoutBigArea
RArea RLayoutBigArea(const RLayout *self)
Generate maximal spanning RArea.
Definition
r_layout.c:1010
r_layout.h
RArea
A particular extent of space.
Definition
r_structs.h:16
RArea::y
int y
Y position.
Definition
r_structs.h:18
RArea::width
int width
X dimension.
Definition
r_structs.h:19
RArea::height
int height
Y dimension.
Definition
r_structs.h:20
RArea::x
int x
X position.
Definition
r_structs.h:17
RLayout
The layout of our display.
Definition
r_structs.h:45
RLayoutXParseGeometry
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.
Definition
xparsegeometry.c:25
xparsegeometry.h
xparsegeometry.c
Generated by
1.18.0