示例#1
0
        private static unsafe void HandleDragRequest(GuiRequest *aRequest)
        {
            var DragRequest = (DragRequest *)aRequest;
            int id          = DragRequest->WindowID;

            if (id < 0 || id >= Windows.Count)
            {
                aRequest->Error = ErrorType.BadParameters;
            }

            if (ActiveWindow == null || ActiveWindow.ID != id)
            {
                aRequest->Error = ErrorType.BadRequest;
            }

            if (aRequest->Error != ErrorType.None)
            {
                ReplyClient(aRequest);
                return;
            }

            var win = Windows[id];

            MouseWindow = win;
        }
示例#2
0
        private static unsafe void HandleNewWindow(GuiRequest *aRequest)
        {
            var WindowRequest = (NewWindow *)aRequest;

            int x      = WindowRequest->X;
            int y      = WindowRequest->Y;
            int width  = WindowRequest->Width;
            int height = WindowRequest->Height;

            if (width <= 0 || height <= 0)
            {
                aRequest->Error = ErrorType.BadParameters;
            }

            if (aRequest->Error != ErrorType.None)
            {
                ReplyClient(aRequest);
                return;
            }

            var window = new Window(aRequest->ClientID, x, y, width, height);

            Marshal.Copy(window.HashID, WindowRequest->Buffer, window.HashID.Length);

            Monitor.AcquireLock(ref WindowsLock);

            int id = Windows.Count;

            window.ID = id;
            WindowRequest->WindowID = id;
            Windows.Add(window);

            Monitor.ReleaseLock(ref WindowsLock);
            ActiveWindow = window;

            Monitor.AcquireLock(ref StackingLock);
            Stacking.Add(window);
            Monitor.ReleaseLock(ref StackingLock);

            ReplyClient(aRequest);
        }
示例#3
0
        private static unsafe void HandleRedraw(GuiRequest *aRequest)
        {
            var RedrawRequest = (Redraw *)aRequest;

            int id     = RedrawRequest->WindowID;
            int width  = RedrawRequest->Width;
            int height = RedrawRequest->Height;

            if (id < 0 || id >= Windows.Count || width <= 0 || height <= 0)
            {
                aRequest->Error = ErrorType.BadParameters;
            }

            if (aRequest->Error != ErrorType.None)
            {
                ReplyClient(aRequest);
                return;
            }

            var Window = Windows[id];

            MarkRectange(RedrawRequest->X + Window.X, RedrawRequest->Y + Window.Y, width, height);
        }
示例#4
0
        private static unsafe void HandleWindowMove(GuiRequest *aRequest)
        {
            var WindowRequest = (WindowMove *)aRequest;
            int id            = WindowRequest->WindowID;

            if (id < 0 || id >= Windows.Count)
            {
                aRequest->Error = ErrorType.BadParameters;
            }

            if (aRequest->Error != ErrorType.None)
            {
                ReplyClient(aRequest);
                return;
            }

            var win = Windows[id];

            MarkRectange(win.X, win.Y, win.Width, win.Height);
            win.X += WindowRequest->RelX;
            win.Y += WindowRequest->RelY;
            MarkRectange(win.X, win.Y, win.Width, win.Height);
        }
示例#5
0
        private static unsafe void HandleInfoRequest(GuiRequest *aRequest)
        {
            var InfoRequest = (InfoRequest *)aRequest;
            int id          = InfoRequest->WindowID;

            if (id < 0 || id >= Windows.Count)
            {
                aRequest->Error = ErrorType.BadParameters;
            }

            if (aRequest->Error != ErrorType.None)
            {
                ReplyClient(aRequest);
                return;
            }

            var win = Windows[id];

            InfoRequest->X      = win.X;
            InfoRequest->Y      = win.Y;
            InfoRequest->Width  = win.Width;
            InfoRequest->Height = win.Height;
            ReplyClient(aRequest);
        }
示例#6
0
文件: Boot.cs 项目: vdt/AtomOS
        private static unsafe void DrawWindow(GuiRequest *request, byte[] xData)
        {
            request->Type  = RequestType.NewWindow;
            request->Error = ErrorType.None;
            var window = (NewWindow *)request;

            window->X      = 340;
            window->Y      = 159;
            window->Width  = 600;
            window->Height = 450;

            Compositor.Server.Write(xData);

            SystemClient.Read(xData);
            if (request->Error != ErrorType.None)
            {
                Debug.Write("Error5: %d\n", (int)request->Error);
                return;
            }

            string HashCode = new string(window->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);
            int    winID    = window->WindowID;

            Debug.Write("winID: %d\n", winID);

            uint surface = Cairo.ImageSurfaceCreateForData(600 * 4, 450, 600, ColorFormat.ARGB32, aBuffer);
            uint cr      = Cairo.Create(surface);

            Cairo.SetOperator(Operator.Over, cr);

            Cairo.Rectangle(450, 600, 0, 0, cr);
            Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr);
            Cairo.Fill(cr);
            Cairo.Rectangle(446, 596, 2, 2, cr);
            Cairo.SetSourceRGBA(1, 0.87, 0.87, 0.87, cr);
            Cairo.Fill(cr);
            Cairo.Rectangle(410, 580, 30, 10, cr);
            Cairo.SetSourceRGBA(1, 1, 1, 1, cr);
            Cairo.Fill(cr);

            Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr);
            Cairo.SelectFontFace(FontWeight.Normal, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.SetFontSize(15, cr);
            Cairo.MoveTo(18, 215, cr);
            Cairo.ShowText(Marshal.C_String("Atom OS : Installation Guide"), cr);

            Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.MoveTo(18, 580, cr);
            Cairo.ShowText(Marshal.C_String("X"), cr);

            Cairo.SurfaceFlush(surface);
            Cairo.Destroy(cr);
            Cairo.SurfaceDestroy(surface);

            request->Type = RequestType.Redraw;
            var req = (Redraw *)request;

            req->WindowID = winID;
            req->X        = 0;
            req->Y        = 0;
            req->Width    = 600;
            req->Height   = 450;
            Compositor.Server.Write(xData);

            Debug.Write("Time: %d\n", Timer.TicksFromStart);
            while (true)
            {
                SystemClient.Read(xData);
                if (request->Error != ErrorType.None)
                {
                    continue;
                }
                if (request->Type != RequestType.MouseEvent)
                {
                    continue;
                }
                var mreq = (MouseEvent *)request;
                if (mreq->WindowID != winID)
                {
                    continue;
                }
                if ((mreq->Function & MouseFunction.Click) != 0)
                {
                    int x = mreq->Xpos;
                    int y = mreq->Ypos;
                    if (y < 40)
                    {
                        request->Type = RequestType.DragRequest;
                        var mv = (DragRequest *)request;
                        mv->WindowID = winID;
                        Compositor.Server.Write(xData);
                    }
                }
            }
        }
示例#7
0
文件: Boot.cs 项目: vdt/AtomOS
        private static unsafe void DrawTaskbar(GuiRequest *request, byte[] xData)
        {
            request->Type  = RequestType.NewWindow;
            request->Error = ErrorType.None;
            var taskbar = (NewWindow *)request;
            int height  = 30;

            taskbar->X      = 0;
            taskbar->Y      = 0;
            taskbar->Width  = VBE.Xres;
            taskbar->Height = height;

            Compositor.Server.Write(xData);

            SystemClient.Read(xData);
            if (request->Error != ErrorType.None)
            {
                Debug.Write("Error4: %d\n", (int)request->Error);
                return;
            }

            string HashCode = new string(taskbar->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);
            int    winID    = taskbar->WindowID;

            Debug.Write("winID: %d\n", winID);

            uint surface = Cairo.ImageSurfaceCreateForData(VBE.Xres * 4, height, VBE.Xres, ColorFormat.ARGB32, aBuffer);
            uint cr      = Cairo.Create(surface);

            uint pattern = Cairo.PatternCreateLinear(height, 0, 0, 0);

            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern);
            Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern);
            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern);

            Cairo.SetOperator(Operator.Over, cr);
            Cairo.Rectangle(height, VBE.Xres, 0, 0, cr);
            Cairo.SetSource(pattern, cr);
            Cairo.Fill(cr);

            Cairo.Rectangle(2, VBE.Xres, height - 2, 0, cr);
            Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, cr);
            Cairo.Fill(cr);

            Cairo.SetSourceRGBA(1, 1, 1, 1, cr);
            Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.SetFontSize(20, cr);
            Cairo.MoveTo(20, 1215, cr);
            Cairo.ShowText(Marshal.C_String("20:10"), cr);

            Cairo.PatternDestroy(pattern);
            Cairo.Destroy(cr);
            Cairo.SurfaceDestroy(surface);

            request->Type = RequestType.Redraw;
            var req = (Redraw *)request;

            req->WindowID = winID;
            req->X        = 0;
            req->Y        = 0;
            req->Width    = VBE.Xres;
            req->Height   = height;
            Compositor.Server.Write(xData);
        }
示例#8
0
 private static unsafe void ReplyClient(GuiRequest *aRequest)
 {
     aRequest->HashID = 0;
     Clients[aRequest->ClientID].Write((byte *)aRequest, false);
 }
示例#9
0
        private static unsafe void HandleMouseEvent(GuiRequest *aRequest)
        {
            var MouseRequest = (MouseEvent *)aRequest;

            MouseRequest->Function = MouseFunction.None;

            MouseFunction function = 0;

            if (MouseRequest->Xpos != 0 || MouseRequest->Ypos != 0)
            {
                function = MouseFunction.Move;
            }

            /* calculate new mouse position */
            int x = Mouse_X + (MouseRequest->Xpos << 1);
            int y = Mouse_Y - (MouseRequest->Ypos << 1);

            /* bound mouse position */
            if (x < 0)
            {
                x = 0;
            }
            if (x > VBE.Xres)
            {
                x = VBE.Xres;
            }

            if (y < 0)
            {
                y = 0;
            }
            if (y > VBE.Yres)
            {
                y = VBE.Yres;
            }

            /* Button Status */
            int  Button   = MouseRequest->Button;
            bool LeftBtn  = (Button & 0x1) != 0;
            bool RightBtn = (Button & 0x2) != 0;

            /* stop window movement */
            if (LeftBtn)
            {
                if (MouseWindow != null)
                {
                    var win = MouseWindow;
                    MarkRectange(win.X, win.Y, win.Width, win.Height);
                    MouseWindow.X += x - Mouse_X;
                    MouseWindow.Y += y - Mouse_Y;
                    MarkRectange(win.X, win.Y, win.Width, win.Height);
                }
            }
            else
            {
                MouseWindow = null;
            }

            /* Update Coordinates */
            Mouse_X = x;
            Mouse_Y = y;

            /* Mouse Events to Client */
            if ((LeftBtn && !MouseLeftBtn) || (RightBtn && !MouseRightBtn))
            {
                function |= MouseFunction.KeyDown;
            }

            if ((!LeftBtn && MouseLeftBtn) || (!RightBtn && MouseRightBtn))
            {
                function |= MouseFunction.KeyUp;
            }

            /* button details */
            MouseLeftBtn   = LeftBtn;
            MouseRightBtn  = RightBtn;
            MouseMiddleBtn = (Button & 0x4) != 0;

            if ((function & MouseFunction.KeyDown) != 0)
            {
                Monitor.AcquireLock(ref StackingLock);

                var list  = Stacking;
                int count = list.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    var win = list[i];
                    if (x < win.X ||
                        y < win.Y ||
                        x > win.X + win.Width ||
                        y > win.Y + win.Height)
                    {
                        continue;
                    }

                    if (ActiveWindow == win)
                    {
                        function |= MouseFunction.Click;
                        break;
                    }

                    ActiveWindow = win;
                    function    |= MouseFunction.Enter;

                    if (i != 0)
                    {
                        for (int j = i + 1; j < count; j++)
                        {
                            list[j - 1] = list[j];
                        }
                        list[count - 1] = win;

                        MarkRectange(win.X, win.Y, win.Width, win.Height);
                    }
                    break;
                }

                Monitor.ReleaseLock(ref StackingLock);
            }

            if (ActiveWindow == null)
            {
                return;
            }

            var Window = ActiveWindow;

            if (x < Window.X ||
                y < Window.Y ||
                x > Window.X + Window.Width ||
                y > Window.Y + Window.Height)
            {
                return;
            }

            MouseRequest->WindowID = Window.ID;
            MouseRequest->Xpos     = x - Window.X;
            MouseRequest->Ypos     = y - Window.Y;
            MouseRequest->Function = function;
            aRequest->ClientID     = Window.ClientID;
            ReplyClient(aRequest);
        }