func (w *Window) Stack(o *Window, mode uint32) { xproto.ConfigureWindowChecked( w.Conn, w.Window, (xproto.ConfigWindowSibling | xproto.ConfigWindowStackMode), []uint32{uint32(o.Window), mode}, ) }
func (w *window) configure() { mask, values := uint16(0), []uint32(nil) r := xp.Rectangle{X: offscreenXY, Y: offscreenXY, Width: w.rect.Width, Height: w.rect.Height} if w.frame != nil && w.frame.workspace.screen != nil { k := w.frame.workspace if k.listing == listWorkspaces || (k.listing == listWindows && k.focusedFrame == w.frame) { // No-op; r is offscreen. } else if k.fullscreen { if k.focusedFrame == w.frame { r.X = k.mainFrame.rect.X r.Y = k.mainFrame.rect.Y r.Width = k.mainFrame.rect.Width + 1 r.Height = k.mainFrame.rect.Height + 1 } } else { r.X = w.frame.rect.X + 2 r.Y = w.frame.rect.Y + 2 r.Width = w.frame.rect.Width - 3 r.Height = w.frame.rect.Height - 3 } } if w.seen && w.rect == r { return } w.rect = r if r.X != offscreenXY { w.seen = true mask = xp.ConfigWindowX | xp.ConfigWindowY | xp.ConfigWindowWidth | xp.ConfigWindowHeight | xp.ConfigWindowBorderWidth values = []uint32{ uint32(uint16(r.X)), uint32(uint16(r.Y)), uint32(r.Width), uint32(r.Height), 0, } } else { w.offscreenSeqNum = nextOffscreenSeqNum nextOffscreenSeqNum++ mask = xp.ConfigWindowX | xp.ConfigWindowY values = []uint32{ uint32(uint16(r.X)), uint32(uint16(r.Y)), } } check(xp.ConfigureWindowChecked(xConn, w.xWin, mask, values)) }
func handleConfigureRequest(e xp.ConfigureRequestEvent) { mask, values := uint16(0), []uint32(nil) if w := findWindow(func(w *window) bool { return w.xWin == e.Window }); w != nil { cne := xp.ConfigureNotifyEvent{ Event: w.xWin, Window: w.xWin, X: w.rect.X, Y: w.rect.Y, Width: w.rect.Width, Height: w.rect.Height, } check(xp.SendEventChecked(xConn, false, w.xWin, xp.EventMaskStructureNotify, string(cne.Bytes()))) return } if e.ValueMask&xp.ConfigWindowX != 0 { mask |= xp.ConfigWindowX values = append(values, uint32(e.X)) } if e.ValueMask&xp.ConfigWindowY != 0 { mask |= xp.ConfigWindowY values = append(values, uint32(e.Y)) } if e.ValueMask&xp.ConfigWindowWidth != 0 { mask |= xp.ConfigWindowWidth values = append(values, uint32(e.Width)) } if e.ValueMask&xp.ConfigWindowHeight != 0 { mask |= xp.ConfigWindowHeight values = append(values, uint32(e.Height)) } if e.ValueMask&xp.ConfigWindowBorderWidth != 0 { mask |= xp.ConfigWindowBorderWidth values = append(values, uint32(e.BorderWidth)) } if e.ValueMask&xp.ConfigWindowSibling != 0 { mask |= xp.ConfigWindowSibling values = append(values, uint32(e.Sibling)) } if e.ValueMask&xp.ConfigWindowStackMode != 0 { mask |= xp.ConfigWindowStackMode values = append(values, uint32(e.StackMode)) } check(xp.ConfigureWindowChecked(xConn, e.Window, mask, values)) }
func initDesktop(xScreen *xp.ScreenInfo) { xFont, err := xp.NewFontId(xConn) if err != nil { log.Fatal(err) } xCursor, err := xp.NewCursorId(xConn) if err != nil { log.Fatal(err) } err = xp.OpenFontChecked(xConn, xFont, uint16(len("cursor")), "cursor").Check() if err != nil { log.Fatal(err) } const xcLeftPtr = 68 // XC_left_ptr from cursorfont.h. err = xp.CreateGlyphCursorChecked( xConn, xCursor, xFont, xFont, xcLeftPtr, xcLeftPtr+1, 0xffff, 0xffff, 0xffff, 0, 0, 0).Check() if err != nil { log.Fatal(err) } err = xp.CloseFontChecked(xConn, xFont).Check() if err != nil { log.Fatal(err) } desktopXWin, err = xp.NewWindowId(xConn) if err != nil { log.Fatal(err) } desktopXGC, err = xp.NewGcontextId(xConn) if err != nil { log.Fatal(err) } desktopWidth = xScreen.WidthInPixels desktopHeight = xScreen.HeightInPixels if err := xp.CreateWindowChecked( xConn, xScreen.RootDepth, desktopXWin, xScreen.Root, 0, 0, desktopWidth, desktopHeight, 0, xp.WindowClassInputOutput, xScreen.RootVisual, xp.CwOverrideRedirect|xp.CwEventMask, []uint32{ 1, xp.EventMaskExposure, }, ).Check(); err != nil { log.Fatal(err) } if len(xSettings) != 0 { initXSettings() } if err := xp.ConfigureWindowChecked( xConn, desktopXWin, xp.ConfigWindowStackMode, []uint32{ xp.StackModeBelow, }, ).Check(); err != nil { log.Fatal(err) } if err := xp.ChangeWindowAttributesChecked( xConn, desktopXWin, xp.CwBackPixel|xp.CwCursor, []uint32{ xScreen.BlackPixel, uint32(xCursor), }, ).Check(); err != nil { log.Fatal(err) } if err := xp.CreateGCChecked( xConn, desktopXGC, xp.Drawable(xScreen.Root), 0, nil, ).Check(); err != nil { log.Fatal(err) } if err := xp.MapWindowChecked(xConn, desktopXWin).Check(); err != nil { log.Fatal(err) } }
func (w *Window) Lower() { xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowStackMode, []uint32{xproto.StackModeBelow}) }
func (w *Window) Raise() { xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowStackMode, []uint32{xproto.StackModeAbove}) }
func (w *Window) Resize(hght, wdth uint16) { xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowHeight, []uint32{uint32(hght)}) xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowWidth, []uint32{uint32(wdth)}) }
func (w *Window) Move(x, y int16) { xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowX, []uint32{uint32(x)}) xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowY, []uint32{uint32(y)}) }
func (w *Window) BorderWidth(bw uint32) { xproto.ConfigureWindowChecked(w.Conn, w.Window, xproto.ConfigWindowBorderWidth, []uint32{bw}) }