10 /* Array of array of monitors of edges: edge[monitor 2][top edge] */
11 ObEdge ***edge = NULL;
12 #warning put in config.c and parse configs of course
13 gboolean config_edge_enabled[OB_NUM_EDGES] = {1, 1, 1, 1, 1, 1, 1, 1};
14 /* this could change at runtime, we should hook into that, but for now
15 * don't crash on reconfigure/shutdown */
16 static guint edge_monitors;
20 #define CORNER_SIZE 20
25 static void get_position(ObEdgeLocation edge, Rect screen, Rect *rect)
29 RECT_SET(*rect, CORNER_SIZE, 0,
30 screen.width - 2 * CORNER_SIZE, EDGE_WIDTH);
32 case OB_EDGE_TOPRIGHT:
33 RECT_SET(*rect, screen.width - CORNER_SIZE, 0,
34 CORNER_SIZE, CORNER_SIZE);
37 RECT_SET(*rect, screen.width - EDGE_WIDTH, CORNER_SIZE,
38 EDGE_WIDTH, screen.height - 2 * CORNER_SIZE);
40 case OB_EDGE_BOTTOMRIGHT:
41 RECT_SET(*rect, screen.width - CORNER_SIZE,
42 screen.height - CORNER_SIZE,
43 CORNER_SIZE, CORNER_SIZE);
46 RECT_SET(*rect, CORNER_SIZE, screen.height - EDGE_WIDTH,
47 screen.width - 2 * CORNER_SIZE, EDGE_WIDTH);
49 case OB_EDGE_BOTTOMLEFT:
50 RECT_SET(*rect, 0, screen.height - CORNER_SIZE,
51 CORNER_SIZE, CORNER_SIZE);
54 RECT_SET(*rect, 0, CORNER_SIZE,
55 EDGE_WIDTH, screen.height - 2 * CORNER_SIZE);
58 RECT_SET(*rect, 0, 0, CORNER_SIZE, CORNER_SIZE);
65 void edges_startup(gboolean reconfigure)
70 XSetWindowAttributes xswa;
72 xswa.override_redirect = True;
74 edge_monitors = screen_num_monitors;
76 edge = g_slice_alloc(sizeof(ObEdge**) * edge_monitors);
77 for (m = 0; m < edge_monitors; m++) {
78 const Rect *monitor = screen_physical_area_monitor(m);
79 edge[m] = g_slice_alloc(sizeof(ObEdge*) * OB_NUM_EDGES);
80 for (i=0; i < OB_NUM_EDGES; i++) {
81 if (!config_edge_enabled[i])
84 edge[m][i] = g_slice_new(ObEdge);
85 edge[m][i]->obwin.type = OB_WINDOW_CLASS_EDGE;
86 edge[m][i]->location = i;
88 get_position(i, *monitor, &r);
89 edge[m][i]->win = XCreateWindow(obt_display, obt_root(ob_screen),
90 r.x, r.y, r.width, r.height, 0, 0, InputOnly,
91 CopyFromParent, CWOverrideRedirect, &xswa);
92 XSelectInput(obt_display, edge[m][i]->win, ButtonPressMask | ButtonReleaseMask
93 | EnterWindowMask | LeaveWindowMask);
94 XMapWindow(obt_display, edge[m][i]->win);
96 stacking_add(EDGE_AS_WINDOW(edge[m][i]));
97 window_add(&edge[m][i]->win, EDGE_AS_WINDOW(edge[m][i]));
100 ob_debug("mapped edge window %i at %03i %03i %02i %02i", i, r.x, r.y, r.width, r.height);
108 void edges_shutdown(gboolean reconfigure)
112 /* This is in case we get called before startup by screen_resize() */
116 for (m = 0; m < edge_monitors; m++) {
117 for (i = 0; i < OB_NUM_EDGES; i++) {
118 if (!config_edge_enabled[i])
121 window_remove(edge[m][i]->win);
122 stacking_remove(EDGE_AS_WINDOW(edge[m][i]));
123 XDestroyWindow(obt_display, edge[m][i]->win);
124 g_slice_free(ObEdge, edge[m][i]);
126 g_slice_free1(sizeof(ObEdge*) * OB_NUM_EDGES, edge[m]);
128 g_slice_free1(sizeof(ObEdge**) * edge_monitors, edge);
131 void edges_configure()
133 edges_shutdown(TRUE);