2010-07-05 23:44:22 +00:00
|
|
|
/*
|
2011-03-27 18:04:11 +00:00
|
|
|
Copyright (C) 2010-2011 Patrick Dubbert
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
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 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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-07-05 23:44:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
VirtualDesktops Plugin
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
This plugin aims to give Rainmeter skins access to various virtual desktop
|
|
|
|
managers through a common interface. The following VDMs are supported:
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
* Dexpot
|
|
|
|
* VirtuaWin
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
To add support for another virtual desktop manager,
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
1) implement a new class derived from VDMeasure
|
|
|
|
2) include its header file below
|
|
|
|
3) add a new case for the "VDManager" config string in the Initialize
|
|
|
|
funtion below
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
Different types of measures are identified using the "VDMeasureType" config
|
|
|
|
string, i.e.
|
2011-03-29 19:21:57 +00:00
|
|
|
|
|
|
|
[VirtualDesktopsMeasure]
|
|
|
|
Measure=Plugin
|
|
|
|
Plugin=VirtualDesktops.dll
|
|
|
|
VDManager=SomeVDM
|
|
|
|
VDMeasureType=...
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
The following basic measure types have to be implemented:
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
2010-07-05 23:44:22 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
* DesktopCount: returns the number of virtual desktops available; when
|
|
|
|
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
|
|
|
the number of columns or rows, respectively, in a grid of
|
|
|
|
desktops
|
2010-07-05 23:44:22 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
* CurrentDesktop: returns the number of the currently active desktop
|
2010-07-05 23:44:22 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
|
|
|
corresponding desktop
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
You're welcome to add any other measure types that suit the feature set of
|
|
|
|
the virtual desktop manager in question. Examples can be found in the
|
|
|
|
existing implementations.
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2010-07-05 23:44:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DexpotMeasure.h"
|
|
|
|
#include "VirtuaWinMeasure.h"
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "../../Library/Export.h"
|
|
|
|
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
2011-01-30 09:31:41 +00:00
|
|
|
|
2010-07-05 23:44:22 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
__declspec(dllexport) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
|
|
|
__declspec(dllexport) void Finalize(HMODULE instance, UINT id);
|
|
|
|
__declspec(dllexport) UINT Update(UINT id);
|
|
|
|
__declspec(dllexport) LPCTSTR GetString(UINT id, UINT flags);
|
|
|
|
__declspec(dllexport) void ExecuteBang(LPCTSTR args, UINT id);
|
|
|
|
__declspec(dllexport) UINT GetPluginVersion();
|
|
|
|
__declspec(dllexport) LPCTSTR GetPluginAuthor();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<UINT, VDMeasure*> Measures;
|
|
|
|
HMODULE VDMeasure::hInstance;
|
|
|
|
|
|
|
|
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
|
|
|
{
|
|
|
|
VDMeasure *Measure = NULL;
|
|
|
|
LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));
|
2011-03-29 19:21:57 +00:00
|
|
|
|
|
|
|
if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
Measure = new VirtuaWinMeasure(instance, id);
|
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (Measure)
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
Measures.insert(std::make_pair(id, Measure));
|
|
|
|
return Measure->Initialize(iniFile, section);
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2010-07-05 23:44:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT Update(UINT id)
|
|
|
|
{
|
|
|
|
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (i != Measures.end())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
return i->second->Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPCTSTR GetString(UINT id, UINT flags)
|
|
|
|
{
|
|
|
|
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (i != Measures.end())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
return i->second->GetString(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _T("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExecuteBang(LPCTSTR args, UINT id)
|
|
|
|
{
|
|
|
|
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (i != Measures.end())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
i->second->ExecuteBang(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Finalize(HMODULE instance, UINT id)
|
|
|
|
{
|
|
|
|
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (i != Measures.end())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
i->second->Finalize();
|
|
|
|
delete i->second;
|
|
|
|
Measures.erase(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT GetPluginVersion()
|
|
|
|
{
|
2011-03-27 18:04:11 +00:00
|
|
|
return 1001;
|
2010-07-05 23:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LPCTSTR GetPluginAuthor()
|
|
|
|
{
|
|
|
|
return _T("Dexpot GbR (info@dexpot.de)");
|
|
|
|
}
|