Usermode/AxWin4 - Send mouse/keyboard events to client
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / CWindow.cpp
1 /*
2  * Acess2 GUI v4
3  * - By John Hodge (thePowersGang)
4  *
5  * CWindow.cpp
6  * - Window
7  */
8 #include <CWindow.hpp>
9 #include <CCompositor.hpp>
10 #include <assert.h>
11 #include <ipc.hpp>
12
13 namespace AxWin {
14
15 CWindow::CWindow(CCompositor& compositor, CClient& client, const ::std::string& name, unsigned int id):
16         m_surface(0,0,0,0),
17         m_compositor(compositor),
18         m_client(client),
19         m_id(id),
20         m_name(name),
21         m_is_shown(false)
22 {
23         _SysDebug("CWindow::CWindow()");
24 }
25
26 CWindow::~CWindow()
27 {
28 }
29
30 void CWindow::Repaint(const CRect& rect)
31 {
32         if( m_is_shown )
33         {
34                 CRect   outrect(
35                         m_surface.m_rect.m_x + rect.m_x, 
36                         m_surface.m_rect.m_y + rect.m_y, 
37                         rect.m_w, rect.m_h
38                         );
39                 m_compositor.DamageArea(outrect);
40         }
41 }
42
43 void CWindow::Show(bool bShow)
44 {
45         if( m_is_shown == bShow )
46                 return;
47         
48         if( bShow )
49                 m_compositor.ShowWindow( this );
50         else
51                 m_compositor.HideWindow( this );
52         m_is_shown = bShow;
53 }
54
55 void CWindow::Move(int X, int Y)
56 {
57         m_surface.m_rect.Move(X, Y);
58 }
59 void CWindow::Resize(unsigned int W, unsigned int H)
60 {
61         m_surface.Resize(W, H);
62         IPC::SendMessage_NotifyDims(m_client, m_id, W, H);
63 }
64 void CWindow::SetFlags(uint32_t Flags)
65 {
66         // TODO: CWindow::SetFlags
67         _SysDebug("TOOD: CWindow::SetFlags");
68 }
69 uint64_t CWindow::ShareSurface()
70 {
71         assert(!"TODO: CWindow::ShareSurface");
72         return 0;
73 }
74
75 void CWindow::MouseButton(int ButtonID, int X, int Y, bool Down)
76 {
77         IPC::SendMessage_MouseButton(m_client, m_id, X, Y, ButtonID, Down);
78 }
79
80 void CWindow::MouseMove(int NewX, int NewY)
81 {
82         // TODO: Only enable move events if client requests them
83         //IPC::SendMessage_MouseMove(m_client, m_id, NewX, NewY);
84 }
85
86 void CWindow::KeyEvent(::uint32_t Scancode, const ::std::string &Translated, bool Down)
87 {
88         IPC::SendMessage_KeyEvent(m_client, m_id, Scancode, Down, Translated.c_str());
89 }
90
91
92 void CWindow::DrawScanline(unsigned int row, unsigned int x, unsigned int w, const uint8_t *data)
93 {
94         m_surface.DrawScanline(row, x, w, data);
95         CRect   damaged( m_surface.m_rect.m_x+x, m_surface.m_rect.m_y+row, w, 1 );
96         m_compositor.DamageArea(damaged);
97 }
98
99 };
100

UCC git Repository :: git.ucc.asn.au