1/* swc: libswc/screen.h
2 *
3 * Copyright (c) 2013, 2014 Michael Forney
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#ifndef SWC_SCREEN_H
25#define SWC_SCREEN_H
26
27#include "primary_plane.h"
28#include "swc.h"
29
30#include <wayland-util.h>
31
32struct output;
33struct pixman_region32;
34
35struct screen_modifier {
36 /**
37 * Takes the screen geometry and sets 'usable' to the usable region of the
38 * screen. 'usable' is an already initialized pixman region.
39 */
40 void (*modify)(struct screen_modifier *modifier,
41 const struct swc_rectangle *geometry,
42 struct pixman_region32 *usable);
43
44 struct wl_list link;
45};
46
47struct screen {
48 struct swc_screen base;
49 const struct swc_screen_handler *handler;
50 void *handler_data;
51
52 struct wl_signal destroy_signal;
53 uint8_t id;
54 uint32_t crtc;
55
56 struct {
57 struct primary_plane primary;
58 struct plane *cursor;
59 } planes;
60
61 struct wl_global *global;
62 struct wl_list resources;
63
64 struct wl_list outputs;
65 struct wl_list modifiers;
66 struct wl_list link;
67};
68
69bool
70screens_initialize(void);
71void
72screens_finalize(void);
73
74struct screen *
75screen_new(uint32_t crtc, struct output *output, struct plane *cursor_plane);
76void
77screen_destroy(struct screen *screen);
78
79static inline uint32_t
80screen_mask(struct screen *screen)
81{
82 return 1 << screen->id;
83}
84
85void
86screen_update_usable_geometry(struct screen *screen);
87
88#endif