Ejemplo n.º 1
0
func (c *Client) refreshState() {
	atoms := make([]string, 0, 4)

	// ignoring _NET_WM_STATE_MODAL
	if c.sticky {
		atoms = append(atoms, "_NET_WM_STATE_STICKY")
	}
	if c.maximized {
		atoms = append(atoms, "_NET_WM_STATE_MAXIMIZED_VERT")
		atoms = append(atoms, "_NET_WM_STATE_MAXIMIZED_HORZ")
	}
	// ignoring _NET_WM_STATE_SHADED
	if c.skipTaskbar {
		atoms = append(atoms, "_NET_WM_STATE_SKIP_TASKBAR")
	}
	if c.skipPager {
		atoms = append(atoms, "_NET_WM_STATE_SKIP_PAGER")
	}
	if c.Iconified() {
		atoms = append(atoms, "_NET_WM_STATE_HIDDEN")
	}
	if c.fullscreen {
		atoms = append(atoms, "_NET_WM_STATE_FULLSCREEN")
	}
	switch c.layer {
	case stack.LayerAbove:
		atoms = append(atoms, "_NET_WM_STATE_ABOVE")
	case stack.LayerBelow:
		atoms = append(atoms, "_NET_WM_STATE_BELOW")
	}
	// ignoring _NET_WM_STATE_DEMANDS_ATTENTION
	// ignoring _NET_WM_STATE_FOCUSED

	ewmh.WmStateSet(wm.X, c.Id(), atoms)
}
Ejemplo n.º 2
0
// create creates the window, initializes the keybind and mousebind packages
// and sets up the window to act like a real top-level client.
func (w *window) create() {
	keybind.Initialize(w.X)
	mousebind.Initialize(w.X)

	err := w.CreateChecked(w.X.RootWin(), 0, 0, flagWidth, flagHeight,
		xproto.CwBackPixel, 0xffffff)
	if err != nil {
		errLg.Fatalf("Could not create window: %s", err)
	}

	// Make the window close gracefully using the WM_DELETE_WINDOW protocol.
	w.WMGracefulClose(func(w *xwindow.Window) {
		xevent.Detach(w.X, w.Id)
		keybind.Detach(w.X, w.Id)
		mousebind.Detach(w.X, w.Id)
		w.Destroy()
		xevent.Quit(w.X)
	})

	// Set WM_STATE so it is interpreted as top-level and is mapped.
	err = icccm.WmStateSet(w.X, w.Id, &icccm.WmState{
		State: icccm.StateNormal,
	})
	if err != nil { // not a fatal error
		lg("Could not set WM_STATE: %s", err)
	}

	// _NET_WM_STATE = _NET_WM_STATE_NORMAL
	ewmh.WmStateSet(w.X, w.Id, []string{"_NET_WM_STATE_NORMAL"})

	// Set the name to something.
	w.nameSet("Decoding all images...")

	w.Map()
}
Ejemplo n.º 3
0
func (self *SessionModule) removeState(id xproto.Window, state string) error {
	states, _ := ewmh.WmStateGet(self.X, id)

	for i, s := range states {
		if s == state {
			states = append(states[:i], states[i+1:]...)

			if err := ewmh.WmStateSet(self.X, id, states); err != nil {
				return err
			}
		}
	}

	return nil
}
Ejemplo n.º 4
0
func (c *Client) removeState(name string) {
	if i := strIndex(name, c.winStates); i > -1 {
		c.winStates = append(c.winStates[:i], c.winStates[i+1:]...)
		ewmh.WmStateSet(wm.X, c.Id(), c.winStates)
	}
}
Ejemplo n.º 5
0
func (c *Client) addState(name string) {
	if strIndex(name, c.winStates) == -1 {
		c.winStates = append(c.winStates, name)
		ewmh.WmStateSet(wm.X, c.Id(), c.winStates)
	}
}
Ejemplo n.º 6
0
func (c *Client) fetchXProperties() {
	var err error

	c.hints, err = icccm.WmHintsGet(wm.X, c.Id())
	if err != nil {
		logger.Warning.Println(err)
		logger.Message.Printf("Using reasonable defaults for WM_HINTS for %X",
			c.Id())
		c.hints = &icccm.Hints{
			Flags:        icccm.HintInput | icccm.HintState,
			Input:        1,
			InitialState: icccm.StateNormal,
		}
	}

	c.nhints, err = icccm.WmNormalHintsGet(wm.X, c.Id())
	if err != nil {
		logger.Warning.Println(err)
		logger.Message.Printf("Using reasonable defaults for WM_NORMAL_HINTS "+
			"for %X", c.Id())
		c.nhints = &icccm.NormalHints{}
	}

	c.protocols, err = icccm.WmProtocolsGet(wm.X, c.Id())
	if err != nil {
		logger.Warning.Printf(
			"Window %X does not have WM_PROTOCOLS set.", c.Id())
	}

	c.winTypes, err = ewmh.WmWindowTypeGet(wm.X, c.Id())
	if err != nil {
		logger.Warning.Printf("Could not find window type for window %X, "+
			"using 'normal'.", c.Id())
		c.winTypes = []string{"_NET_WM_WINDOW_TYPE_NORMAL"}
	}

	c.winStates, err = ewmh.WmStateGet(wm.X, c.Id())
	if err != nil {
		c.winStates = []string{}
		ewmh.WmStateSet(wm.X, c.Id(), c.winStates)
	}

	c.class, err = icccm.WmClassGet(wm.X, c.Id())
	if err != nil {
		logger.Warning.Printf("Could not find window class for window %X: %s",
			c.Id(), err)
		c.class = &icccm.WmClass{
			Instance: "",
			Class:    "",
		}
	}

	trans, _ := icccm.WmTransientForGet(wm.X, c.Id())
	if trans == 0 {
		for _, c2_ := range wm.Clients {
			c2 := c2_.(*Client)
			if c2.transient(c) {
				c.transientFor = c2
				break
			}
		}
	} else if transCli := wm.FindManagedClient(trans); transCli != nil {
		c.transientFor = transCli.(*Client)
	}

	c.setShaped()
}