Exemplo n.º 1
0
func (c *Client) Unfocused() {
	c.frame.Inactive()
	c.state = frame.Inactive
	ewmh.ActiveWindowSet(wm.X, 0)
	c.removeState("_NET_WM_STATE_FOCUSED")

	c.FireHook(hook.Unfocused)
}
Exemplo n.º 2
0
func (c *Client) Focused() {
	c.attnStop()
	c.frame.Active()
	c.state = frame.Active
	focus.SetFocus(c)
	ewmh.ActiveWindowSet(wm.X, c.Id())
	c.addState("_NET_WM_STATE_FOCUSED")

	c.FireHook(hook.Focused)
}
Exemplo n.º 3
0
func (c *Client) Unfocused() {
	wasFocused := c.state == frame.Active

	c.frame.Inactive()
	c.state = frame.Inactive
	ewmh.ActiveWindowSet(wm.X, 0)
	c.removeState("_NET_WM_STATE_FOCUSED")

	if wasFocused {
		event.Notify(event.UnfocusedClient{c.Id()})
		event.Notify(event.ChangedActiveClient{0})
		c.FireHook(hook.Unfocused)
	}
}
Exemplo n.º 4
0
func (s *Setting) init() bool {
	s.core = gio.NewSettings(SchemaId)
	if s.core == nil {
		return false
	}

	s.listenSettingChange(HideModeKey, func(g *gio.Settings, key string) {
		s.hideModeLock.Lock()
		defer s.hideModeLock.Unlock()

		value := HideModeType(g.GetEnum(key))
		s.hideMode = value
		logger.Debug(key, "changed to", key)
		dbus.Emit(s, "HideModeChanged", int32(value))
	})

	s.listenSettingChange(DisplayModeKey, func(g *gio.Settings, key string) {
		s.displayModeLock.Lock()
		defer s.displayModeLock.Unlock()

		value := DisplayModeType(g.GetEnum(key))
		logger.Debug(key, "changed to", value)

		s.displayMode = value

		for _, rApp := range ENTRY_MANAGER.runtimeApps {
			rebuildXids := []xproto.Window{}
			for xid, _ := range rApp.xids {
				if _, err := xprop.PropValStr(
					xprop.GetProperty(
						XU,
						xid,
						"_DDE_DOCK_APP_ID",
					),
				); err != nil {
					continue
				}

				rebuildXids = append(rebuildXids, xid)
				rApp.detachXid(xid)
			}

			l := len(rebuildXids)
			if l == 0 {
				continue
			}

			if len(rApp.xids) == 0 {
				ENTRY_MANAGER.destroyRuntimeApp(rApp)
			}

			newApp := ENTRY_MANAGER.createRuntimeApp(rebuildXids[0])
			for i := 0; i < l; i++ {
				newApp.attachXid(rebuildXids[i])
			}

			activeXid, err := ewmh.ActiveWindowGet(XU)
			if err != nil {
				continue
			}

			for xid, _ := range newApp.xids {
				logger.Debugf("through new app xids")
				if activeXid == xid {
					logger.Debugf("0x%x(a), 0x%x(x)",
						activeXid, xid)
					newApp.setLeader(xid)
					newApp.updateState(xid)
					ewmh.ActiveWindowSet(XU, xid)
					break
				}
			}
		}

		dockProperty.updateDockHeight(value)
		dbus.Emit(s, "DisplayModeChanged", int32(value))
	})
	s.listenSettingChange(ClockTypeKey, func(*gio.Settings, string) {
		s.clockTypeLock.Lock()
		defer s.clockTypeLock.Unlock()
		s.clockType = ClockType(s.core.GetEnum(ClockTypeKey))
		dbus.Emit(s, "ClockTypeChanged", int32(s.clockType))
	})

	s.listenSettingChange(DisplayDateKey, func(*gio.Settings, string) {
		s.displayDateLock.Lock()
		defer s.displayDateLock.Unlock()
		s.displayDate = s.core.GetBoolean(DisplayDateKey)
		dbus.Emit(s, "DisplayDateChanged", s.displayDate)
	})
	s.listenSettingChange(DisplayWeekKey, func(*gio.Settings, string) {
		s.displayWeekLock.Lock()
		defer s.displayWeekLock.Unlock()
		s.displayWeek = s.core.GetBoolean(DisplayWeekKey)
		dbus.Emit(s, "DisplayWeekChanged", s.displayWeek)
	})

	// at least one read operation must be called after signal connected, otherwise,
	// the signal connection won't work from glib 2.43.
	// NB: https://github.com/GNOME/glib/commit/8ff5668a458344da22d30491e3ce726d861b3619
	s.displayMode = DisplayModeType(s.core.GetEnum(DisplayModeKey))
	s.hideMode = HideModeType(s.core.GetEnum(HideModeKey))
	if s.hideMode == HideModeAutoHide {
		s.hideMode = HideModeSmartHide
		s.core.SetEnum(HideModeKey, int32(HideModeSmartHide))
	}
	s.clockType = ClockType(s.core.GetEnum(ClockTypeKey))
	s.displayDate = s.core.GetBoolean(DisplayDateKey)
	s.displayWeek = s.core.GetBoolean(DisplayWeekKey)

	return true
}