Beispiel #1
0
func (par *Parent) Deparent(cid xproto.Window) {
	err := xproto.ReparentWindowChecked(
		par.X.Conn(), cid, par.X.RootWin(), 0, 0).Check()
	if err != nil {
		logger.Warning.Printf("Could not deparent client window: %s", err)
	}
}
Beispiel #2
0
func newParent(X *xgbutil.XUtil, cid xproto.Window) (*Parent, error) {
	parent, err := xwindow.Generate(X)
	if err != nil {
		logger.Error.Printf("Could not create a parent window for client "+
			"with id '%d' because: %s", cid, err)
		logger.Error.Fatalf("In a state where no new windows can be created. " +
			"Unfortunately, we must exit.")
	}

	err = parent.CreateChecked(X.RootWin(), 0, 0, 1, 1,
		xproto.CwEventMask,
		xproto.EventMaskSubstructureRedirect|
			xproto.EventMaskButtonPress|xproto.EventMaskButtonRelease)
	if err != nil {
		return nil, err
	}

	err = xproto.ReparentWindowChecked(X.Conn(),
		cid, parent.Id, 0, 0).Check()
	if err != nil {
		return nil, err
	}

	return &Parent{parent}, nil
}
Beispiel #3
0
func (sock *XEmbedSocket) Eject() error {
	if err := xproto.UnmapWindowChecked(sock.X.Conn(), sock.id).Check(); err != nil {
		return err
	}

	return xproto.ReparentWindowChecked(sock.X.Conn(), sock.id, sock.X.RootWin(), 1, 1).Check()
}
Beispiel #4
0
func (sock *XEmbedSocket) Embed(x, y int16, window xproto.Window) error {
	if err := xproto.ReparentWindowChecked(sock.X.Conn(), sock.id, window, x, y).Check(); err != nil {
		return err
	}

	sock.sendMessage(MsgEmbeddedNotify, 0, int(window), 0)

	sock.parent = window

	return nil
}
Beispiel #5
0
// Destroy will check if the client window is still a sub-window of this frame,
// and reparent it to the root window if so.
//
// Destroy does *not* destroy the parent window! The caller must do that, since
// the parent window is shared across many frames.
func (f *frame) Destroy() {
	// Only re-parent if the current parent is this frame window.
	parent, err := f.client.Win().Parent()
	if err != nil {
		// We don't care about this error
		return
	}
	if parent.Id == f.parent.Id {
		err := xproto.ReparentWindowChecked(f.X.Conn(), f.client.Id(),
			f.X.RootWin(), 0, 0).Check()
		if err != nil {
			logger.Warning.Println(err)
		}
	}
}
Beispiel #6
0
func newParent(X *xgbutil.XUtil, cid xproto.Window) (*Parent, error) {
	parent, err := xwindow.Generate(X)
	if err != nil {
		logger.Error.Printf("Could not create a parent window for client "+
			"with id '%d' because: %s", cid, err)
		logger.Error.Fatalf("In a state where no new windows can be created. " +
			"Unfortunately, we must exit.")
	}

	// clientAttrs, err := xproto.GetWindowAttributes(X.Conn(), cid).Reply()
	// if err != nil {
	// return nil, fmt.Errorf("Could not get window attributes: %s", err)
	// }

	// visual := clientAttrs.Visual
	// vdepth := getVisualDepth(X, visual)
	visual := X.Screen().RootVisual
	vdepth := X.Screen().RootDepth
	// logger.Debug.Printf("Visualid: %x, Depth: %d", visual, vdepth)
	err = xproto.CreateWindowChecked(X.Conn(),
		vdepth, parent.Id, X.RootWin(),
		0, 0, 1, 1, 0, xproto.WindowClassInputOutput, visual,
		xproto.CwEventMask,
		[]uint32{
			xproto.EventMaskSubstructureRedirect |
				xproto.EventMaskButtonPress |
				xproto.EventMaskButtonRelease |
				xproto.EventMaskFocusChange,
		}).Check()
	if err != nil {
		return nil, fmt.Errorf("Could not create window: %s", err)
	}

	err = xproto.ReparentWindowChecked(X.Conn(),
		cid, parent.Id, 0, 0).Check()
	if err != nil {
		return nil, fmt.Errorf("Could not reparent window: %s", err)
	}

	return &Parent{
		Window:      parent,
		MoveState:   &MoveState{},
		ResizeState: &ResizeState{},
		isMapped:    false,
	}, nil
}