Esempio n. 1
0
        private void HandleXConfigure(XConfigureEvent *xconfigure)
        {
            if (xconfigure->send_event == False)
            {
                // The coordinates for non synthetic events are supposed
                // to be relative to the parent window but gives incorrect
                // coordinates when translated. We'll explicitly query
                // the location of our own origin for this case instead.

                nuint child;

                ThrowForLastErrorIfZero(XTranslateCoordinates(
                                            xconfigure->display,
                                            xconfigure->window,
                                            XlibDispatchService.Instance.DefaultRootWindow,
                                            0,
                                            0,
                                            &xconfigure->x,
                                            &xconfigure->y,
                                            &child
                                            ), nameof(XTranslateCoordinates));
            }

            var currentClientLocation = new Vector2(xconfigure->x, xconfigure->y);
            var currentClientSize     = new Vector2(xconfigure->width, xconfigure->height);

            var previousClientLocation = _clientBounds.Location;
            var previousClientSize     = _clientBounds.Size;

            _clientBounds = new Rectangle(currentClientLocation, currentClientSize);

            OnClientLocationChanged(previousClientLocation, currentClientLocation);
            OnClientSizeChanged(previousClientSize, currentClientSize);

            var previousLocation = _bounds.Location;
            var previousSize     = _bounds.Size;

            var currentLocation = currentClientLocation + _frameExtents.Location;
            var currentSize     = currentClientSize + _frameExtents.Size;

            _bounds = new Rectangle(currentLocation, currentSize);

            OnLocationChanged(previousLocation, currentLocation);
            OnSizeChanged(previousSize, currentSize);
        }
Esempio n. 2
0
        private void HandleXConfigure(XConfigureEvent *xconfigure)
        {
            var previousLocation = _bounds.Location;
            var currentLocation  = new Vector2(xconfigure->x, xconfigure->y);

            if (currentLocation != previousLocation)
            {
                _bounds = _bounds.WithLocation(currentLocation);
                OnLocationChanged(previousLocation, currentLocation);
            }

            var previousSize = _bounds.Size;
            var currentSize  = new Vector2(xconfigure->width, xconfigure->height);

            if (currentSize != previousSize)
            {
                _bounds = _bounds.WithSize(currentSize);
                OnSizeChanged(previousSize, currentSize);
            }

            _bounds = new Rectangle(xconfigure->x, xconfigure->y, xconfigure->width, xconfigure->height);
        }