private void UpdateFrameExtents(XlibDispatchService dispatchService, IntPtr display, nuint window) { if (dispatchService.GetAtomIsSupported(_NET_FRAME_EXTENTS)) { nuint actualType; int actualFormat; nuint itemCount; nuint bytesRemaining; nint *cardinals; _ = XGetWindowProperty( display, window, dispatchService.GetAtom(_NET_FRAME_EXTENTS), 0, 4, False, XA_CARDINAL, &actualType, &actualFormat, &itemCount, &bytesRemaining, (byte **)&cardinals ); if ((actualType == XA_CARDINAL) && (actualFormat == 32) && (itemCount == 4) && (bytesRemaining == 0)) { // The cardinals given are left, right, top and bottom; respectively // Using these, we construct a rectangle that specifies the adjustments // made to a given client rectangle to compute the non-client size and // location. _frameExtents = new Rectangle( -cardinals[0], -cardinals[2], cardinals[1] + cardinals[0], cardinals[3] + cardinals[2] ); } else { _frameExtents = default; } } else { throw new NotImplementedException(); } }
private void UpdateWindowTitle(XlibDispatchService dispatchService, IntPtr display, nuint window) { if (dispatchService.GetAtomIsSupported(_NET_WM_NAME)) { nuint actualType; int actualFormat; nuint itemCount; nuint bytesRemaining; sbyte *wmName; _ = XGetWindowProperty( display, window, dispatchService.GetAtom(_NET_WM_NAME), 0, nint.MaxValue, False, dispatchService.GetAtom(UTF8_STRING), &actualType, &actualFormat, &itemCount, &bytesRemaining, (byte **)&wmName ); if ((actualType == dispatchService.GetAtom(UTF8_STRING)) && (actualFormat == 8) && (bytesRemaining == 0)) { _title = GetUtf8Span(wmName, checked ((int)itemCount)).GetString() ?? string.Empty; } else { _title = string.Empty; } } else { throw new NotImplementedException(); } }
private void UpdateWindowState(XlibDispatchService dispatchService, IntPtr display, nuint window) { if (dispatchService.GetAtomIsSupported(_NET_WM_STATE)) { nuint actualType; int actualFormat; nuint itemCount; nuint bytesRemaining; nuint *netWmState; _ = XGetWindowProperty( display, window, dispatchService.GetAtom(_NET_WM_STATE), 0, nint.MaxValue, False, XA_ATOM, &actualType, &actualFormat, &itemCount, &bytesRemaining, (byte **)&netWmState ); if ((actualType == XA_ATOM) && (actualFormat == 32) && (bytesRemaining == 0)) { var foundNetWmStateFocused = false; var foundNetWmStateHidden = false; var foundNetWmStateMaximizedHorz = false; var foundNetWmStateMaximizedVert = false; for (nuint i = 0; i < itemCount; i++) { if (netWmState[i] == dispatchService.GetAtom(_NET_WM_STATE_FOCUSED)) { foundNetWmStateFocused = true; } else if (netWmState[i] == dispatchService.GetAtom(_NET_WM_STATE_HIDDEN)) { foundNetWmStateHidden = true; } else if (netWmState[i] == dispatchService.GetAtom(_NET_WM_STATE_MAXIMIZED_HORZ)) { foundNetWmStateMaximizedHorz = true; } else if (netWmState[i] == dispatchService.GetAtom(_NET_WM_STATE_MAXIMIZED_VERT)) { foundNetWmStateMaximizedVert = true; } } _isActive = foundNetWmStateFocused; if (foundNetWmStateHidden) { _windowState = WindowState.Minimized; } else if (foundNetWmStateMaximizedHorz && foundNetWmStateMaximizedVert) { _windowState = WindowState.Maximized; } else { _windowState = WindowState.Normal; } } else { _isActive = false; _windowState = WindowState.Hidden; } } else { throw new NotImplementedException(); } }