3 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
12 #include <l4/mag-gfx/geometry>
13 #include <l4/mag/server/view_stack>
15 #include <l4/re/video/view>
16 #include <l4/re/event>
17 #include <l4/mag/server/hid_report>
22 namespace Mag_server {
24 using namespace Mag_gfx;
31 friend class User_state;
33 View_proxy(View_proxy const &);
34 void operator = (View_proxy const &);
41 explicit View_proxy(User_state *ust);
49 View *view() const { return _v; }
50 void view(View *v) { _v = v; }
51 void forget(View *v) { if (_v == v) _v = 0; }
58 friend class View_proxy;
63 View *_keyboard_focus;
64 View_proxy *_view_proxies;
70 static char const *const _class;
71 static luaL_Reg const _ops[];
73 User_state(lua_State *lua, View_stack *_vstack, View *cursor);
74 virtual ~User_state();
76 void forget_view(View *v);
78 View_stack *vstack() { return _vstack; }
79 View_stack const *vstack() const { return _vstack; }
81 void set_mode(Mode::Mode_flag m, bool on = true)
82 { vstack()->set_mode(m, on); }
84 void toggle_mode(Mode::Mode_flag m)
85 { vstack()->toggle_mode(m); }
87 bool set_focus(View *v);
88 View *kbd_focus() const { return _keyboard_focus; }
90 typedef L4Re::Event_buffer::Event Event;
91 typedef L4Re::Event_stream_info Input_info;
92 typedef L4Re::Event_absinfo Input_absinfo;
94 void set_pointer(int x, int y, bool hide);
95 void move_pointer(int x, int y)
96 { set_pointer(_mouse_pos.x() + x, _mouse_pos.y() + y, false); }
97 Point const &mouse_pos() const { return _mouse_pos; }
99 int get_input_stream_info_for_id(l4_umword_t id, Input_info *info) const;
100 int get_input_axis_info(l4_umword_t id, unsigned naxes, unsigned const *axis,
101 Input_absinfo *info, unsigned char *ax_mode) const;
105 View_proxy::View_proxy(User_state *ust)
106 : _v(0), _pn(&ust->_view_proxies), _n(ust->_view_proxies)
108 ust->_view_proxies = this;