예제 #1
0
파일: parent.go 프로젝트: mkrull/wingo
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)
	}
}
예제 #2
0
파일: parent.go 프로젝트: dlintw/wingo
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
}
예제 #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()
}
예제 #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
}
예제 #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)
		}
	}
}
예제 #6
0
파일: parent.go 프로젝트: mkrull/wingo
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
}