-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCWM_window.c
More file actions
105 lines (88 loc) · 2.36 KB
/
CWM_window.c
File metadata and controls
105 lines (88 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "BasicWindow.h"
#include "CWM.h"
#include "CWM_internal.h"
#include "Conscreen/List/List.h"
#include "RR.h"
#include "BasicWindow_internal.h"
#include "R_dwm.h"
#include "R_info.h"
CWM_window CWM_internal_create()
{
CWM_window w = malloc(sizeof(_CWM_window));
BW_create(&w->window);
w->parent=NULL;
w->children=LIST_create(CWM_window);
w->frame=DWM_window_create();
DWM_window_renderer_set(w->frame, BW_get_context(&w->window));
return w;
}
BasicWindow CWM_root_get()
{
CWM_internal_init_check();
return root_window;
}
void CWM_internal_push(CWM_window parent, CWM_window w)
{
CWM_internal_init_check();
w->parent=parent;
DWM_register(BW_get_renderer(&parent->window, "DWM"), w->frame, 0);
List_push(parent->children, &w);
}
BasicWindow CWM_push(BasicWindow parent)
{
CWM_window w = CWM_internal_create();
CWM_internal_push((CWM_window)parent, w);
return (BasicWindow)w;
}
void CWM_move(BasicWindow w, BasicWindow target)
{
CWM_internal_remove((CWM_window)w);
CWM_internal_push((CWM_window)target, (CWM_window)w);
}
void CWM_internal_remove(CWM_window w)
{
// remove from parent
if(!w->parent) return;
DWM_unregister(BW_get_renderer(&w->parent->window, "DWM"), w->frame);
DWM_window_free(w->frame);
List_rme(w->parent->children, w);
}
void CWM_remove(BasicWindow _w)
{
CWM_window w = (CWM_window)_w;
CWM_internal_remove(w);
// recursively free child_windows
LIST_FORWARD(BasicWindow, w->children, CWM_remove);
BW_internal_free(&w->window);
free(w);
}
void CWM_pos_set_absolute(BasicWindow w, uint16_t x, uint16_t y)
{
DWM_window_pos_set_abs(((CWM_window)w)->frame, x, y);
}
void CWM_pos_set_relative(BasicWindow w, float x, float y)
{
DWM_window_pos_set_rel (((CWM_window)w)->frame, x, y);
}
void CWM_size_set_absolute(BasicWindow w, uint16_t x, uint16_t y)
{
DWM_window_size_set_abs (((CWM_window)w)->frame, x, y);
}
void CWM_size_set_relative(BasicWindow w, float x, float y)
{
DWM_window_size_set_rel (((CWM_window)w)->frame, x, y);
}
void CWM_depth_set(BasicWindow _w, int depth)
{
CWM_window w = (CWM_window)_w;
if(!w->parent) return;
RR_renderer dwm = BW_get_renderer(&w->parent->window, "DWM");
DWM_unregister(dwm, ((CWM_window)w)->frame);
DWM_register(dwm, ((CWM_window)w)->frame, depth);
}
void CWM_gen_chains(BasicWindow _w)
{
CWM_window w = (CWM_window)_w;
BW_gen_chain(_w);
LIST_FORWARD(BasicWindow, w->children, CWM_gen_chains);
}