uploaded original spice-server-0.12.4 and celt-0.5.1.3
[sdk/emulator/libs/spice-server.git] / client / screen_layer.h
1 /*
2    Copyright (C) 2009 Red Hat, Inc.
3
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef _H_SCREEN_LAYER
19 #define _H_SCREEN_LAYER
20
21 #include "common/region.h"
22 #include "threads.h"
23
24 class RedScreen;
25 class Application;
26
27 class ScreenLayer {
28 public:
29     ScreenLayer(int z_order, bool opaque);
30     virtual ~ScreenLayer();
31
32     void attach_to_screen(Application& application, int screen_id);
33     void detach_from_screen(Application& application);
34
35     void set_screen(RedScreen* screen) { _screen = screen;}
36     RedScreen* screen() { return _screen; }
37     int z_order() { return _z_order;}
38     void set_area(const QRegion& area);
39     void offset_area(int dx, int dy);
40     void clear_area();
41     void set_rect_area(const SpiceRect& r);
42     void add_rect_area(const SpiceRect& r);
43     void remove_rect_area(const SpiceRect& r);
44     void begin_update(QRegion& direct_rgn, QRegion& composit_rgn);
45     void invalidate();
46     uint64_t invalidate(const SpiceRect& r, bool urgent = false);
47     void invalidate(const QRegion& r);
48     bool contains_point(int x, int y);
49
50     virtual void copy_pixels(const QRegion& dest_region, RedDrawable& dest_dc) {}
51
52     void set_using_ogl(bool val) {_using_ogl = val;}
53     bool using_ogl() {return _using_ogl;}
54     virtual void on_size_changed() {}
55
56     virtual void pre_migrate() { }
57     virtual void post_migrate() { }
58
59     QRegion& area() { return _area;}
60     QRegion& direct_area() { return _direct_area;}
61     QRegion& composit_area() { return _composit_area;}
62
63     virtual void on_update_completion(uint64_t mark) {}
64
65     virtual bool pointer_test(int x, int y) { return false;}
66     virtual void on_pointer_enter(int x, int y, unsigned int buttons_state) {}
67     virtual void on_pointer_motion(int x, int y, unsigned int buttons_state) {}
68     virtual void on_pointer_leave() {}
69     virtual void on_mouse_button_press(int button, int buttons_state) {}
70     virtual void on_mouse_button_release(int button, int buttons_state) {}
71
72 private:
73     uint64_t invalidate_rect(const SpiceRect& r, bool urgent);
74     void notify_changed();
75
76 private:
77     RedScreen* _screen;
78     int _z_order;
79     bool _opaque;
80     bool _using_ogl;
81     Mutex _area_lock;
82     QRegion _area;
83     QRegion _direct_area;
84     QRegion _composit_area;
85 };
86
87 #endif