/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/*
 * 2005/01/04 Kristian Mueller (Kristian-M@Kristian-M.de)
 *   thanking Peer Georgi for supporting development!
 */

#include "cEWMHVDesktopTools.h"
#include <sstream>
#include <iostream>

int main(int iArguments, char *sArguments[]){
	cEWMHVDesktopTools aEWMHVDesktopTools;
	int iVDesktopNumber = 0;

	std::cout << "Trying to request number of desktops by using an EWMH message..." << std::endl;
	if (aEWMHVDesktopTools.probeWM()){	// we should have an EWMH-Environment	
		std::cout << "actualDestopCount = " << aEWMHVDesktopTools.getDesktopCount() << std::endl;
		std::cout << "actualCurrentDesktopID = " << aEWMHVDesktopTools.getCurrentDesktopID() << std::endl;
	}
	
	if (iArguments == 2){
		std::string sCmdLine(sArguments[1]);
		std::stringstream ssTemp(sCmdLine);
		ssTemp >> iVDesktopNumber;
		if (iVDesktopNumber < 0) iVDesktopNumber = 0;
		std::cout << "Switching to the desktop provided at commandline. (" << iVDesktopNumber << ")." << std::endl;
		aEWMHVDesktopTools.setCurrentDesktop(iVDesktopNumber);
	}
	
	return 1;
}