~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to xparsegeometry.c

  • Committer: Matthew Fuller
  • Author(s): Maxime Soulé
  • Date: 2018-03-26 16:44:54 UTC
  • mto: (614.1.31 randr)
  • mto: This revision was merged to the branch mainline in revision 644.
  • Revision ID: fullermd@over-yonder.net-20180326164454-ytjak60vrgyqexwb
Some geometries can be relative to a monitor

It's the case for:
- f.moveresize `geometry`
- WindowBox
- WindowGeometries
- WorkSpaceManagerGeometry


git: 29a214153ebe2e7f12bc8bc227cbd65c5b4416fb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright notice...
 
3
 */
 
4
 
 
5
#include "xparsegeometry.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
 
 
14
 
 
15
int RLayoutXParseGeometry(RLayout *layout, const char *geometry, int *x, int *y,
 
16
                          unsigned int *width, unsigned int *height)
 
17
{
 
18
        char *sep;
 
19
 
 
20
        sep = strchr(geometry, ':');
 
21
        if(sep != NULL) {
 
22
                if(layout != NULL) {
 
23
                        RArea mon = RLayoutGetAreaByName(layout, geometry, sep - geometry);
 
24
                        if(RAreaIsValid(&mon)) {
 
25
                                int mask = XParseGeometry(sep + 1, x, y, width, height);
 
26
                                RArea big = RLayoutBigArea(layout);
 
27
 
 
28
                                if(mask & XValue) {
 
29
                                        if(mask & XNegative) {
 
30
                                                *x -= big.width - mon.width - (mon.x - big.x);
 
31
                                        }
 
32
                                        else {
 
33
                                                *x += mon.x - big.x;
 
34
                                        }
 
35
                                }
 
36
 
 
37
                                if(mask & YValue) {
 
38
                                        if(mask & YNegative) {
 
39
                                                *y -= big.height - mon.height - (mon.y - big.y);
 
40
                                        }
 
41
                                        else {
 
42
                                                *y += mon.y - big.y;
 
43
                                        }
 
44
                                }
 
45
 
 
46
                                return mask;
 
47
                        }
 
48
                }
 
49
 
 
50
                // Name not found, keep the geometry part as-is
 
51
                geometry = sep + 1;
 
52
        }
 
53
 
 
54
        return XParseGeometry(geometry, x, y, width, height);
 
55
}