示例#1
0
//DispatchKeys interface method
func (sw *Switcher) DispatchKeys(t *sdl.KeyDownEvent) int {
	app := sw.App
	T := app.Widget
	key := sdl.GetScancodeName(t.Keysym.Scancode)
	if (key == "N" && t.Keysym.Mod == 64) || key == "Down" {
		T.SetLine(sw.Selected, sw.getLine(sw.Selected, sw.Clients[sw.Selected], false))
		if sw.Selected < len(sw.Clients)-1 {
			sw.Selected++
		} else {
			sw.Selected = 0
		}
		T.SetLine(sw.Selected, sw.getLine(sw.Selected, sw.Clients[sw.Selected], true))
		return 1
	}
	if (key == "P" && t.Keysym.Mod == 64) || key == "Up" {
		T.SetLine(sw.Selected, sw.getLine(sw.Selected, sw.Clients[sw.Selected], false))
		if sw.Selected > 0 {
			sw.Selected--
		} else {
			sw.Selected = len(sw.Clients) - 1
		}
		T.SetLine(sw.Selected, sw.getLine(sw.Selected, sw.Clients[sw.Selected], true))
		return 1
	}
	if key == "X" && t.Keysym.Mod == 64 {
		wid := sw.Clients[sw.Selected].WID
		ewmh.CloseWindow(X, wid)
		sdl.Delay(500)
		sw.Clients = GetClients()
		sw.Draw()
		return 1
	}
	if (key == "J" && t.Keysym.Mod == 64) || key == "Return" {
		wid := sw.Clients[sw.Selected].WID
		ewmh.ActiveWindowReq(X, wid)
		return 0
	}
	if strings.Index("0123456789", key) > -1 {
		i, err := strconv.Atoi(key)
		if err == nil && len(sw.Clients) > i {
			sw.Selected = i
			if t.Keysym.Mod == 64 {
				wid := sw.Clients[sw.Selected].WID
				ewmh.ActiveWindowReq(X, wid)
				return 0
			}
			sw.Draw()
			return 1
		}
	}
	if t.Keysym.Sym == sdl.K_ESCAPE || t.Keysym.Sym == sdl.K_CAPSLOCK {
		return 0
	}
	return 1
}
示例#2
0
func activateWindow(xid xproto.Window) error {
	err := changeWorkspaceIfNeeded(xid)
	if err != nil {
		logger.Warning(err)
	}
	return ewmh.ActiveWindowReq(XU, xid)
}
示例#3
0
func (app *RuntimeApp) Activate(x, y int32) error {
	//TODO: handle multiple xids
	switch {
	case !contains(app.state, "_NET_WM_STATE_FOCUSED"):
		activateWindow(app.CurrentInfo.Xid)
	case contains(app.state, "_NET_WM_STATE_FOCUSED"):
		s, err := icccm.WmStateGet(XU, app.CurrentInfo.Xid)
		if err != nil {
			logger.Info("WmStateGetError:", s, err)
			return err
		}
		switch s.State {
		case icccm.StateIconic:
			s.State = icccm.StateNormal
			icccm.WmStateSet(XU, app.CurrentInfo.Xid, s)
		case icccm.StateNormal:
			activeXid, _ := ewmh.ActiveWindowGet(XU)
			logger.Debugf("%s, 0x%x(c), 0x%x(a), %v", app.Id,
				app.CurrentInfo.Xid, activeXid, app.state)
			if len(app.xids) == 1 {
				s.State = icccm.StateIconic
				iconifyWindow(app.CurrentInfo.Xid)
			} else {
				logger.Warningf("activeXid is 0x%x, current is 0x%x", activeXid,
					app.CurrentInfo.Xid)
				if activeXid == app.CurrentInfo.Xid {
					x := app.findNextLeader()
					ewmh.ActiveWindowReq(XU, x)
				}
			}
		}
	}
	return nil
}
示例#4
0
//DispatchEvents interface method
func (sw *Switcher) DispatchEvents(event sdl.Event) int {
	switch t := event.(type) {
	case *sdl.WindowEvent:
		if t.Event == sdl.WINDOWEVENT_FOCUS_GAINED {
			sw.Clients = GetClients()
			sw.Draw()
		}
		if t.Event == sdl.WINDOWEVENT_FOCUS_LOST {
			ewmh.ActiveWindowReq(X, SHADOW)
		}
	}
	return 1
}
示例#5
0
func (self *SessionModule) RaiseWindow(window_id string) error {
	if id, err := self.toX11WindowId(window_id); err == nil {
		//  unhide the window
		self.removeState(id, `_NET_WM_STATE_HIDDEN`)

		//  move the window to the stop of the stacking order
		ewmh.RestackWindow(self.X, id)

		//  activate the window
		ewmh.ActiveWindowReq(self.X, id)
	} else {
		return err
	}

	return nil
}
示例#6
0
func (Cmd *TasksCommand) task(line string) int {
	// wid := client.WID
	tokens := strings.Split(strings.ToLower(line), " ")
	name := tokens[len(tokens)-1]
	var client Client
	for _, client = range Cmd.Clients {
		if strings.ToLower(client.Class) == name {
			break
		}
	}
	if strings.ToLower(client.Class) != name {
		return 1
	}
	if strings.HasPrefix(line, "x ") {
		ewmh.CloseWindow(X, client.WID)
		return 0
	}
	ewmh.ActiveWindowReq(X, client.WID)
	return 0
}
示例#7
0
func (w *window) CycleSelected() {
	fatal(ewmh.ActiveWindowReq(w.X, w.id))
}
示例#8
0
func (rc RunningCommand) Run() {
	ewmh.ActiveWindowReq(rc.X, rc.win)
}