// works for new deepin wm.
func checkCurrentDesktop(xid xproto.Window) (bool, error) {
	num, err := xprop.PropValNum(xprop.GetProperty(XU, xid, "_NET_WM_DESKTOP"))
	if err != nil {
		return false, err
	}

	currentDesktop, err := xprop.PropValNum(xprop.GetProperty(XU, XU.RootWin(), "_NET_CURRENT_DESKTOP"))
	if err != nil {
		return false, err
	}

	return num == currentDesktop, nil
}
func changeWorkspaceIfNeeded(xid xproto.Window) error {
	desktopNum, err := xprop.PropValNum(xprop.GetProperty(XU, xid, "_NET_WM_DESKTOP"))
	if err != nil {
		return fmt.Errorf("Get _NET_WM_DESKTOP failed: %s", err)
	}

	currentDesktop, err := ewmh.CurrentDesktopGet(XU)
	if err != nil {
		return fmt.Errorf("Get _NET_CURRENT_DESKTOP failed: %v", err)
	}

	if currentDesktop == desktopNum {
		return fmt.Errorf("No need to change workspace, the current desktop is already %v", currentDesktop)
	}

	timeStamp, err := ewmh.WmUserTimeGet(XU, xid)
	if err != nil {
		logger.Warningf("Get timestamp of 0x%x failed: %v", uint32(xid), err)
	}

	err = ewmh.ClientEvent(XU, XU.RootWin(), "_NET_CURRENT_DESKTOP", int(desktopNum), int(timeStamp))
	if err != nil {
		return fmt.Errorf("Send ClientMessage Failed: %v", err)
	}

	return nil
}
// _NET_WM_WINDOW_OPACITY get
// This isn't part of the EWMH spec, but is widely used by drop in
// compositing managers (i.e., xcompmgr, cairo-compmgr, etc.).
// This property is typically set not on a client window, but the *parent*
// of a client window in reparenting window managers.
// The float returned will be in the range [0.0, 1.0] where 0.0 is completely
// transparent and 1.0 is completely opaque.
func WmWindowOpacityGet(xu *xgbutil.XUtil, win xproto.Window) (float64, error) {
	intOpacity, err := xprop.PropValNum(
		xprop.GetProperty(xu, win, "_NET_WM_WINDOW_OPACITY"))
	if err != nil {
		return 0, err
	}

	return float64(uint(intOpacity)) / float64(0xffffffff), nil
}
// _NET_WM_HANDLED_ICONS get
func WmHandledIconsGet(xu *xgbutil.XUtil, win xproto.Window) (bool, error) {
	reply, err := xprop.GetProperty(xu, win, "_NET_WM_HANDLED_ICONS")
	if err != nil {
		return false, err
	}

	val, err := xprop.PropValNum(reply, nil)
	if err != nil {
		return false, err
	}

	return val == 1, nil
}
// _NET_SHOWING_DESKTOP get
func ShowingDesktopGet(xu *xgbutil.XUtil) (bool, error) {
	reply, err := xprop.GetProperty(xu, xu.RootWin(), "_NET_SHOWING_DESKTOP")
	if err != nil {
		return false, err
	}

	val, err := xprop.PropValNum(reply, nil)
	if err != nil {
		return false, err
	}

	return val == 1, nil
}
func (wa *fullScreenWorkaround) detectTarget(w xproto.Window) {
	pid, _ := xprop.PropValNum(xprop.GetProperty(wa.xu, w, "_NET_WM_PID"))

	contents, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid))
	if err != nil {
		return
	}

	if wa.isFullScreen(w) {
		for _, target := range wa.targets {
			if strings.Contains(string(contents), target) {
				wa.inhibit(target, string(contents))
				return
			}
		}
	}
	wa.isHintingTarget = false
}
Exemple #7
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)
	}

	tmp, err := xprop.PropValNum(
		xprop.GetProperty(wm.X, c.Id(), "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"))
	if err == nil {
		c.gtkMaximizeNada = (tmp == 1)
	} else {
		c.gtkMaximizeNada = false
	}

	c.setShaped()
}
// _NET_CURRENT_DESKTOP get
func CurrentDesktopGet(xu *xgbutil.XUtil) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_CURRENT_DESKTOP"))
}
// _NET_WM_PID get
func WmPidGet(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win, "_NET_WM_PID"))
}
Exemple #10
0
// _NET_WM_DESKTOP get
func WmDesktopGet(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win, "_NET_WM_DESKTOP"))
}
Exemple #11
0
// _NET_NUMBER_OF_DESKTOPS get
func NumberOfDesktopsGet(xu *xgbutil.XUtil) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_NUMBER_OF_DESKTOPS"))
}
Exemple #12
0
// _NET_WM_USER_TIME get
func WmUserTimeGet(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win, "_NET_WM_USER_TIME"))
}
Exemple #13
0
// _NET_WM_SYNC_REQUEST_COUNTER get
// I'm pretty sure this needs 64 bit integers, but I'm not quite sure
// how to go about that yet. Any ideas?
func WmSyncRequestCounter(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win,
		"_NET_WM_SYNC_REQUEST_COUNTER"))
}