diff --git a/rainbow/Framebuffer/Ctrl.h b/rainbow/Framebuffer/Ctrl.h index ac2f22117..2fdcf6097 100644 --- a/rainbow/Framebuffer/Ctrl.h +++ b/rainbow/Framebuffer/Ctrl.h @@ -41,6 +41,8 @@ private: static void MouseEventFB(Ptr t, int event, Point p, int zdelta); Vector GetPaintRects(); + static void DoMouseFB(int event, Point p, int zdelta); + static void DrawLine(const Vector& clip, int x, int y, int cx, int cy, bool horz, const byte *pattern, int animation); static void DragRectDraw0(const Vector& clip, const Rect& rect, int n, @@ -57,7 +59,6 @@ protected: static int PaintLock; public: - static void DoMouseFB(int event, Point p, int zdelta = 0); static bool DoKeyFB(dword key, int cnt); static void InitFB(); diff --git a/rainbow/Telpp/Ctrl.h b/rainbow/Telpp/Ctrl.h index 98ad6ab8e..ba0c5135c 100644 --- a/rainbow/Telpp/Ctrl.h +++ b/rainbow/Telpp/Ctrl.h @@ -36,7 +36,8 @@ private: const byte *pattern, int animation); static void DoMouseButton(int event, CParser& p); - static void ReadMouseButtons(CParser& p); + + static void DoMouseFB(int event, Point p, int zdelta, CParser& cp); static void Reply(); @@ -51,7 +52,6 @@ protected: static int PaintLock; public: - static void DoMouseFB(int event, Point p, int zdelta = 0); static bool DoKeyFB(dword key, int cnt); static void InitTelpp(); diff --git a/rainbow/Telpp/Event.cpp b/rainbow/Telpp/Event.cpp index 07300c461..cf11e66c4 100644 --- a/rainbow/Telpp/Event.cpp +++ b/rainbow/Telpp/Event.cpp @@ -133,36 +133,6 @@ Ctrl *Ctrl::FindMouseTopCtrl() return desktop->IsEnabled() ? desktop : NULL; } -void Ctrl::DoMouseFB(int event, Point p, int zdelta) -{ - MousePos = p; - int a = event & Ctrl::ACTION; - if(a == Ctrl::UP && Ctrl::ignoreclick) { - EndIgnore(); - return; - } - else - if(a == Ctrl::DOWN && ignoreclick) - return; - LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl)); - if(captureCtrl) - MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta); - else - for(int i = topctrl.GetCount() - 1; i >= 0; i--) { - Ptr t = topctrl[i]; - Rect rr = t->GetRect(); - if(rr.Contains(p)) { - MouseEventFB(t, event, p, zdelta); - return; - } - } - Ctrl *desktop = GetDesktop(); - if(desktop) { - desktop->DispatchMouse(event, p, zdelta); - desktop->PostInput(); - } -} - bool Ctrl::DoKeyFB(dword key, int cnt) { DLOG("DoKeyFB " << GetKeyDesc(key) << ", " << cnt); @@ -244,7 +214,7 @@ void Ctrl::PaintCaretCursor(SystemDraw& draw) } void Ctrl::DoPaint() -{ +{ if(!PaintLock) { if(invalid && desktop) { invalid = false; @@ -256,17 +226,43 @@ void Ctrl::DoPaint() } } +void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp) +{ + mouseButtons = cp.ReadInt(); + MousePos = p; + int a = event & ACTION; + if(a == UP && Ctrl::ignoreclick) { + EndIgnore(); + return; + } + else + if(a == DOWN && ignoreclick) + return; + DLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl)); + if(captureCtrl) + MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta); + else + for(int i = topctrl.GetCount() - 1; i >= 0; i--) { + Ptr t = topctrl[i]; + Rect rr = t->GetRect(); + if(rr.Contains(p)) { + MouseEventFB(t, event, p, zdelta); + return; + } + } + Ctrl *desktop = GetDesktop(); + if(desktop) { + desktop->DispatchMouse(event, p, zdelta); + desktop->PostInput(); + } +} + void Ctrl::DoMouseButton(int event, CParser& p) { int button = p.ReadInt(); int x = p.ReadInt(); int y = p.ReadInt(); - DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, Point(x, y)); -} - -void Ctrl::ReadMouseButtons(CParser& p) -{ - mouseButtons = p.ReadInt(); + DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, Point(x, y), 0, p); } bool Ctrl::ProcessEventQueue(const String& event_queue) @@ -282,17 +278,14 @@ bool Ctrl::ProcessEventQueue(const String& event_queue) if(p.Id("M")) { int x = p.ReadInt(); int y = p.ReadInt(); - ReadMouseButtons(p); - DoMouseFB(MOUSEMOVE, Point(x, y), 0); + DoMouseFB(MOUSEMOVE, Point(x, y), 0, p); } else if(p.Id("D")) { - ReadMouseButtons(p); DoMouseButton(DOWN, p); } else if(p.Id("U")) { - ReadMouseButtons(p); DoMouseButton(UP, p); } else @@ -332,9 +325,12 @@ void Ctrl::Reply() SweepMkImageCache(); DoPaint(); if(http.GetURI().GetCount() < 2) - HttpResponse(socket, http.scgi, 200, "OK", "text/html", String(telpp_html, telpp_html_length)); - else - HttpResponse(socket, http.scgi, 200, "OK", "text/plain; charset=x-user-defined", content); + HttpResponse(socket, http.scgi, 200, "OK", "text/html", String(telpp_html, telpp_html_length)); // This is weird place, but whatever + else { + String s = GZCompress(content); + HttpResponse(socket, http.scgi, 200, "OK", "text/plain; charset=x-user-defined", + s, "U++ Tel++ server", true); + } socket.Close(); } } diff --git a/rainbow/Telpp/Telpp.html b/rainbow/Telpp/Telpp.html index cd36a35e3..cf545efbb 100644 --- a/rainbow/Telpp/Telpp.html +++ b/rainbow/Telpp/Telpp.html @@ -112,7 +112,7 @@ var canvas = document.getElementById("myCanvas"); function key_flags(event) { - return " " + 1*event.shiftKey + ' ' + 1*event.ctrlKey + ' ' + 1*event.altKey + "\n"; + return " " + 1*event.shiftKey + 1*event.ctrlKey + 1*event.altKey + "\n"; } function mouse_event(event) @@ -134,14 +134,14 @@ canvas.onmousedown = function(event) canvas.onmouseup = function(event) { - event_queue += "U " + event.button + mouse_event(event) + "\n"; + event_queue += "U " + event.button + mouse_event(event); Ping(); } document.onkeydown = function(event) { event_queue += "K " + event.keyCode + " " + event.which + key_flags(event); - event.preventDefault(); +// event.preventDefault(); Ping(); } @@ -152,6 +152,7 @@ document.onkeypress = function(event) Ping(); } + document.onkeyup = function(event) { event_queue += "k " + event.keyCode + " " + event.which + key_flags(event); diff --git a/rainbow/Telpp/Telpp.upp b/rainbow/Telpp/Telpp.upp index e483f4af9..3e4297bb2 100644 --- a/rainbow/Telpp/Telpp.upp +++ b/rainbow/Telpp/Telpp.upp @@ -4,8 +4,6 @@ uses Painter, CtrlLib; -library(POSIX) "SDL2 SDL2main GL"; - file Telpp.h, Keys.h,