~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to r_layout.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:
4
4
 
5
5
#include <stdlib.h>
6
6
#include <stdio.h>
 
7
#include <string.h>
7
8
 
8
9
#include "r_layout.h"
9
10
#include "r_area_list.h"
20
21
        layout->monitors = monitors;
21
22
        layout->horiz = RAreaListHorizontalUnion(monitors);
22
23
        layout->vert = RAreaListVerticalUnion(monitors);
 
24
        layout->names = NULL;
23
25
 
24
26
        return layout;
25
27
}
37
39
        return RLayoutNew(cropped_monitors);
38
40
}
39
41
 
 
42
static void _RLayoutFreeNames(RLayout *self)
 
43
{
 
44
        if(self->names != NULL) {
 
45
                free(self->names);
 
46
                self->names = NULL;
 
47
        }
 
48
}
 
49
 
40
50
void RLayoutFree(RLayout *self)
41
51
{
42
52
        RAreaListFree(self->monitors);
43
53
        RAreaListFree(self->horiz);
44
54
        RAreaListFree(self->vert);
 
55
        _RLayoutFreeNames(self);
45
56
        free(self);
46
57
}
47
58
 
 
59
RLayout *RLayoutSetMonitorsNames(RLayout *self, char **names)
 
60
{
 
61
        _RLayoutFreeNames(self);
 
62
        self->names = names;
 
63
        return self;
 
64
}
 
65
 
48
66
static RAreaList *_RLayoutRecenterVertically(RLayout *self, RArea *far_area)
49
67
{
50
68
        //  |_V_|
237
255
        return self->monitors->areas[index];
238
256
}
239
257
 
 
258
RArea RLayoutGetAreaByName(RLayout *self, const char *name, int len)
 
259
{
 
260
        if(self->names != NULL) {
 
261
                int index;
 
262
 
 
263
                if(len < 0) {
 
264
                        len = strlen(name);
 
265
                }
 
266
 
 
267
                for(index = 0; index < self->monitors->len
 
268
                                && self->names[index] != NULL; index++) {
 
269
                        if(strncmp(self->names[index], name, len) == 0) {
 
270
                                return self->monitors->areas[index];
 
271
                        }
 
272
                }
 
273
        }
 
274
 
 
275
        return RAreaInvalid();
 
276
}
 
277
 
 
278
RArea RLayoutBigArea(RLayout *self)
 
279
{
 
280
        return RAreaListBigArea(self->monitors);
 
281
}
 
282
 
240
283
struct monitor_edge_finder {
241
284
        RArea *area;
242
285
        union {