├── Icons ├── 10.ico ├── 11.ico ├── 12.ico ├── 13.ico ├── 14.ico ├── 15.ico ├── 16.ico ├── 17.ico ├── 18.ico ├── 19.ico ├── 20.ico ├── check.ico ├── st_0.ico ├── st_1.ico ├── st_2.ico ├── st_3.ico ├── st_4.ico ├── st_5.ico ├── st_6.ico ├── st_7.ico ├── st_8.ico ├── st_9.ico ├── st_dis_1.ico ├── st_dis_2.ico ├── st_ne_1.ico ├── st_ne_2.ico ├── st_nw_1.ico ├── st_nw_2.ico ├── st_se_1.ico ├── st_se_2.ico ├── st_sw_1.ico ├── st_sw_2.ico └── virtuawin.ico ├── bin ├── Module.exe ├── WinList.exe ├── vwHook.dll └── VirtuaWin.exe ├── Source ├── VirtuaWin.rc ├── vwHook │ ├── vwHook.rc │ ├── vwHook.h │ └── vwHook.c ├── WinList │ ├── winlistres.h │ ├── winlist.rc │ └── winlist.c ├── targetver.h ├── stdafx.h ├── VirtuaWin.exe.manifest ├── DiskRoutines.h ├── Module │ ├── Module.txt │ ├── Module.c │ ├── Defines.h │ └── Messages.h ├── vwCommands.def ├── ConfigParameters.h ├── VirtuaWin.h ├── ModuleRoutines.c ├── Defines.h ├── Messages.h ├── WinRuleDialog.c └── DiskRoutines.c ├── Release └── WinList.tlog │ └── cl.command.1.tlog ├── README.md ├── Module.vcxproj ├── vwHook.vcxproj ├── VirtuaWin.sln ├── WinList.vcxproj ├── VirtuaWin.vcxproj └── COPYING.TXT /Icons/10.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/10.ico -------------------------------------------------------------------------------- /Icons/11.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/11.ico -------------------------------------------------------------------------------- /Icons/12.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/12.ico -------------------------------------------------------------------------------- /Icons/13.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/13.ico -------------------------------------------------------------------------------- /Icons/14.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/14.ico -------------------------------------------------------------------------------- /Icons/15.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/15.ico -------------------------------------------------------------------------------- /Icons/16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/16.ico -------------------------------------------------------------------------------- /Icons/17.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/17.ico -------------------------------------------------------------------------------- /Icons/18.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/18.ico -------------------------------------------------------------------------------- /Icons/19.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/19.ico -------------------------------------------------------------------------------- /Icons/20.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/20.ico -------------------------------------------------------------------------------- /Icons/check.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/check.ico -------------------------------------------------------------------------------- /Icons/st_0.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_0.ico -------------------------------------------------------------------------------- /Icons/st_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_1.ico -------------------------------------------------------------------------------- /Icons/st_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_2.ico -------------------------------------------------------------------------------- /Icons/st_3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_3.ico -------------------------------------------------------------------------------- /Icons/st_4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_4.ico -------------------------------------------------------------------------------- /Icons/st_5.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_5.ico -------------------------------------------------------------------------------- /Icons/st_6.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_6.ico -------------------------------------------------------------------------------- /Icons/st_7.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_7.ico -------------------------------------------------------------------------------- /Icons/st_8.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_8.ico -------------------------------------------------------------------------------- /Icons/st_9.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_9.ico -------------------------------------------------------------------------------- /bin/Module.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/bin/Module.exe -------------------------------------------------------------------------------- /bin/WinList.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/bin/WinList.exe -------------------------------------------------------------------------------- /bin/vwHook.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/bin/vwHook.dll -------------------------------------------------------------------------------- /Icons/st_dis_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_dis_1.ico -------------------------------------------------------------------------------- /Icons/st_dis_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_dis_2.ico -------------------------------------------------------------------------------- /Icons/st_ne_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_ne_1.ico -------------------------------------------------------------------------------- /Icons/st_ne_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_ne_2.ico -------------------------------------------------------------------------------- /Icons/st_nw_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_nw_1.ico -------------------------------------------------------------------------------- /Icons/st_nw_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_nw_2.ico -------------------------------------------------------------------------------- /Icons/st_se_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_se_1.ico -------------------------------------------------------------------------------- /Icons/st_se_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_se_2.ico -------------------------------------------------------------------------------- /Icons/st_sw_1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_sw_1.ico -------------------------------------------------------------------------------- /Icons/st_sw_2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/st_sw_2.ico -------------------------------------------------------------------------------- /bin/VirtuaWin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/bin/VirtuaWin.exe -------------------------------------------------------------------------------- /Icons/virtuawin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Icons/virtuawin.ico -------------------------------------------------------------------------------- /Source/VirtuaWin.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Source/VirtuaWin.rc -------------------------------------------------------------------------------- /Source/vwHook/vwHook.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Source/vwHook/vwHook.rc -------------------------------------------------------------------------------- /Release/WinList.tlog/cl.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miabrahams/VirtuaWin/HEAD/Release/WinList.tlog/cl.command.1.tlog -------------------------------------------------------------------------------- /Source/WinList/winlistres.h: -------------------------------------------------------------------------------- 1 | /* Weditres generated include file. Do NOT edit */ 2 | #define IDD_MAINDIALOG 100 3 | #define ID_WINLIST 101 4 | #define IDUNDO 103 5 | #define IDSAVE 104 6 | #define IDREFRESH 105 7 | -------------------------------------------------------------------------------- /Source/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Source/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | // C RunTime Header Files 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // TODO: reference additional headers your program requires here 22 | #define _CRT_SECURE_NO_WARNINGS -------------------------------------------------------------------------------- /Source/WinList/winlist.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "winlistres.h" 3 | 4 | 5 | IDD_MAINDIALOG DIALOG 79, 25, 377, 226 6 | STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 7 | CAPTION "WinList v4.4" 8 | FONT 8, "Helv" 9 | BEGIN 10 | LTEXT "Use this module to restore windows that might have been lost. Mark the window that you want to restore and press the Restore button. Press Undo if you accidently restored the wrong window.", 11 | 102, 6, 6, 364, 21 12 | CONTROL "WList",ID_WINLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, 13 | 6, 31, 365, 169, WS_EX_CLIENTEDGE 14 | DEFPUSHBUTTON "Done", IDCANCEL, 305, 206, 40, 14 15 | PUSHBUTTON "Refresh", IDREFRESH, 129, 206, 40, 14 16 | PUSHBUTTON "Restore", IDOK, 173, 206, 40, 14 17 | PUSHBUTTON "Undo", IDUNDO, 217, 206, 40, 14 18 | PUSHBUTTON "Save", IDSAVE, 261, 206, 40, 14 19 | END 20 | -------------------------------------------------------------------------------- /Source/VirtuaWin.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | VirtuaWin 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Source/vwHook/vwHook.h: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // vwHook.h - Windows Hook for sending window activation events. 4 | // 5 | // Copyright (c) 2007-2012 VirtuaWin (VirtuaWin@home.se) 6 | // 7 | // This program is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 2 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | // 22 | 23 | #ifndef __VWHOOK_H 24 | #define __VWHOOK_H 25 | 26 | #ifdef vwHOOK_BUILD 27 | #define vwHOOK_EXPORT __declspec(dllexport) extern 28 | #else 29 | #define vwHOOK_EXPORT __declspec(dllimport) extern 30 | #endif 31 | 32 | vwHOOK_EXPORT void 33 | vwHookSetup(HWND ivwHWnd, int ivwHookUse) ; 34 | vwHOOK_EXPORT int 35 | vwHookInstall(void) ; 36 | vwHOOK_EXPORT void 37 | vwHookUninstall(void) ; 38 | 39 | #if defined(__cplusplus) || defined(c_plusplus) 40 | } 41 | #endif 42 | #endif /* __VWHOOK_H */ 43 | -------------------------------------------------------------------------------- /Source/DiskRoutines.h: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // DiskRoutines.h - Disk routine function definitions. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | 24 | #ifndef _DISKROUTINES_H_ 25 | #define _DISKROUTINES_H_ 26 | 27 | #include 28 | 29 | typedef enum { vwMODULES, vwVIRTUAWIN_HLP, vwVIRTUAWIN_CFG, vwWINDOW_CFG, vwMODULE_CFG, vwFILE_COUNT } eFileNames; 30 | 31 | extern TCHAR *VirtuaWinPath ; 32 | extern TCHAR *UserAppPath ; 33 | #ifdef _UNICODE 34 | extern char *VirtuaWinPathStr ; 35 | extern char *UserAppPathStr ; 36 | #else 37 | #define VirtuaWinPathStr VirtuaWinPath 38 | #define UserAppPathStr UserAppPath 39 | #endif 40 | 41 | void GetFilename(eFileNames filetype, int location, TCHAR *outStr); 42 | int loadDisabledModules(vwDisModule *theDisList); 43 | void saveDisabledList(int theNOfModules, vwModule *theModList); 44 | void loadWindowConfig(void); 45 | void saveWindowConfig(void); 46 | void loadVirtuawinConfig(void); 47 | void saveVirtuawinConfig(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | VirtuaWin 3 | 4 | 5 | by Johan Piculell 6 | 7 | 8 | Updates by Michael Abrahams 9 | miabraha@gmail.com 10 | https://github.com/miabrahams/VirtuaWin/ 11 | 12 | 13 | Description 14 | -------------------------------------------------------------- 15 | VirtuaWin is a small, fast and easy to use virtual desktop manager for Windows 8. The current desktop is indicated by a small icon in the system tray to conserve space. There are many configuration possibilities for both mouse and keyboard control. VirtuaWin also supports modules for adding features without decreasing the performance in VirtuaWin itself. 16 | 17 | Code comments 18 | -------------------------------------------------------------- 19 | This version is updated to build with MSVC 2013 and the latest Windows binaries. The first feature change was to allow scaling for monitors using multiple DPI settings. If you want to try building this software, please let me know. 20 | 21 | You can check the original website for info on module development. 22 | 23 | 24 | Files 25 | -------------------------------------------------------------- 26 | + README.md This file. 27 | + HISTORY.TXT Description of changes. 28 | + COPYING.TXT GNU General Public License Version 2. 29 | + *.c *.h Source files. 30 | + *.rc *.manifest Executable description files. 31 | + *.vcxproj *.sln Visual Studio 2013 project files. 32 | + *.ico Icons for .exe and system tray. 33 | 34 | 35 | Contributing 36 | -------------------------------------------------------------- 37 | Please feel free to contribute patches at the GitHub repo at: 38 | 39 | https://github.com/miabrahams/VirtuaWin 40 | 41 | Copyright 42 | -------------------------------------------------------------- 43 | VirtuaWin is a freely distributed program and is licensed under the GNU 44 | General Public License. 45 | 46 | Copyright (c) 1999-2005 Johan Piculell 47 | 48 | Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 49 | 50 | Copyright (c) 2015 Michael Abrahams (miabraha@gmail.com) 51 | -------------------------------------------------------------------------------- /Source/Module/Module.txt: -------------------------------------------------------------------------------- 1 | ---- VirtuaWin Module Mini-Manual ---- 2 | 3 | A VirtuaWin module consists of an ordinary windows executable that 4 | communicates with VirtuaWin by message passing. 5 | 6 | The header file "Messages.h" defines all possible messages that can be sent to 7 | and from VirtuaWin. A module that shall be loaded by VirtuaWin must be placed 8 | in the "modules" directory in the VirtuaWin directory. 9 | 10 | VirtuaWin uses PostMessage() for sending info to the modules, except from 11 | sending the WM_COPYDATA. In this way the dependency between modules and 12 | VirtuaWin is as small as possible and a crashed module should not affect 13 | VirtuaWin. 14 | 15 | The class name of the module MUST be the same as the filename including the 16 | .exe extension since VirtuaWin uses this for locating the handle of the 17 | module. Do not call the module something like explorer.exe, since you might 18 | end up with VirtuaWin trying to load the windows shell as a module, be a 19 | little more origninal :) 20 | 21 | VirtuaWin will send a MOD_INIT upon startup with its handle as wParam, which 22 | can be used for communication with VirtuaWin. 23 | 24 | All modules shall handle the MOD_QUIT message since VirtuaWin uses this for 25 | shutting down the module. 26 | 27 | The MOD_SETUP is optional if you want to show a configuration dialog from your 28 | module. 29 | 30 | If the module needs the window list that VirtuaWin keeps window status in, 31 | VW_WINLIST is sent. VirtuaWin will the reply with WM_COPYDATA (see win32 32 | documentation). VirtuaWin holds this data in a fixed structure array of type 33 | windowType, the list is upto MAXWIN Long. The C definition for this is as 34 | follows: 35 | 36 | ---------------------------- 37 | #define MAXWIN 128 // max number of windows to handle 38 | #define MAXDESK 11 // max number of desktops (0 - not used, 1 - 9 - normal, 10 private) 39 | typedef struct { // Holds the windows in the list 40 | HWND Handle; 41 | HWND Owner; 42 | long Style; 43 | long ExStyle; 44 | unsigned long ZOrder[MAXDESK] ; 45 | unsigned short Desk; 46 | unsigned short menuId ; 47 | unsigned char Sticky; 48 | unsigned char Tricky; 49 | unsigned char Visible; 50 | unsigned char State; 51 | } windowType; 52 | ---------------------------- 53 | 54 | The following is an example of processing the WM_COPYDATA message: 55 | 56 | ---------------------------- 57 | // definitions 58 | windowType winList[MAXWIN]; 59 | int nOfWin; 60 | // ... 61 | switch(msg) 62 | { 63 | // ... 64 | case WM_COPYDATA: 65 | { 66 | // The data should be considered read-only and _must_ be copied to 67 | // local buffer if to be used after the message is processed 68 | COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)lParam; 69 | const windowType* winP = (const windowType*)pcds->lpData; // Window list 70 | DWORD len = pcds->cbData; // Size of data 71 | nOfWin = pcds->dwData; // number of windows in the window list 72 | memcpy(winList, winP, len); // copy the data to local buffer, if to be used later 73 | break; 74 | } 75 | ---------------------------- 76 | 77 | Check example files for additional info on how to use and handle the different 78 | messages and mail any requests or questions to the SourceForge Questions forum 79 | or to VirtuaWin@home.se 80 | 81 | -------------------------------------------------------------------------------- /Module.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474} 15 | Module 16 | 17 | 18 | 19 | Application 20 | true 21 | v120 22 | MultiByte 23 | 24 | 25 | Application 26 | false 27 | v120 28 | true 29 | MultiByte 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | $(Configuration)\Module\ 43 | 44 | 45 | 46 | Level3 47 | Disabled 48 | true 49 | _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 50 | /FS %(AdditionalOptions) 51 | 52 | 53 | true 54 | /FS %(AdditionalOptions) 55 | 56 | 57 | 58 | 59 | Level3 60 | MaxSpeed 61 | true 62 | true 63 | true 64 | /FS %(AdditionalOptions) 65 | 66 | 67 | true 68 | true 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /vwHook.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE} 15 | vwHook 16 | vwHook 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v120 23 | MultiByte 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v120 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | .dll 44 | 45 | 46 | $(Configuration)\vwHook\ 47 | .dll 48 | 49 | 50 | 51 | Level3 52 | Disabled 53 | true 54 | /FS %(AdditionalOptions) 55 | 56 | 57 | true 58 | 59 | 60 | 61 | 62 | Level3 63 | MaxSpeed 64 | true 65 | true 66 | true 67 | /FS %(AdditionalOptions) 68 | 69 | 70 | true 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /VirtuaWin.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VirtuaWin", "VirtuaWin.vcxproj", "{3517D8E1-A68F-4EB4-8B87-D3474AE599C8}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B} = {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B} 9 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474} = {B7BA9773-E9AF-4306-BCC1-7B5827AA5474} 10 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE} = {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinList", "WinList.vcxproj", "{7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE} = {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE} 16 | EndProjectSection 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vwHook", "vwHook.vcxproj", "{354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Module", "Module.vcxproj", "{B7BA9773-E9AF-4306-BCC1-7B5827AA5474}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|ARM = Debug|ARM 25 | Debug|Win32 = Debug|Win32 26 | Debug|x64 = Debug|x64 27 | Release|ARM = Release|ARM 28 | Release|Win32 = Release|Win32 29 | Release|x64 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Debug|ARM.ActiveCfg = Debug|Win32 33 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Debug|Win32.Build.0 = Debug|Win32 35 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Debug|x64.ActiveCfg = Debug|Win32 36 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Release|ARM.ActiveCfg = Release|Win32 37 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Release|Win32.ActiveCfg = Release|Win32 38 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Release|Win32.Build.0 = Release|Win32 39 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8}.Release|x64.ActiveCfg = Release|Win32 40 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Debug|ARM.ActiveCfg = Debug|Win32 41 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Debug|Win32.ActiveCfg = Debug|Win32 42 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Debug|Win32.Build.0 = Debug|Win32 43 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Debug|x64.ActiveCfg = Debug|Win32 44 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Release|ARM.ActiveCfg = Release|Win32 45 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Release|Win32.ActiveCfg = Release|Win32 46 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Release|Win32.Build.0 = Release|Win32 47 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B}.Release|x64.ActiveCfg = Release|Win32 48 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Debug|ARM.ActiveCfg = Debug|Win32 49 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Debug|Win32.ActiveCfg = Debug|Win32 50 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Debug|Win32.Build.0 = Debug|Win32 51 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Debug|x64.ActiveCfg = Debug|Win32 52 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Release|ARM.ActiveCfg = Release|Win32 53 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Release|Win32.ActiveCfg = Release|Win32 54 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Release|Win32.Build.0 = Release|Win32 55 | {354E2FA3-0DC5-4F1B-9905-5B938EDBB9DE}.Release|x64.ActiveCfg = Release|Win32 56 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Debug|ARM.ActiveCfg = Debug|Win32 57 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Debug|Win32.ActiveCfg = Debug|Win32 58 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Debug|Win32.Build.0 = Debug|Win32 59 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Debug|x64.ActiveCfg = Debug|Win32 60 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Release|ARM.ActiveCfg = Release|Win32 61 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Release|Win32.ActiveCfg = Release|Win32 62 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Release|Win32.Build.0 = Release|Win32 63 | {B7BA9773-E9AF-4306-BCC1-7B5827AA5474}.Release|x64.ActiveCfg = Release|Win32 64 | EndGlobalSection 65 | GlobalSection(SolutionProperties) = preSolution 66 | HideSolutionNode = FALSE 67 | EndGlobalSection 68 | EndGlobal 69 | -------------------------------------------------------------------------------- /Source/vwCommands.def: -------------------------------------------------------------------------------- 1 | /* 2 | * VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | * vwCommands.def - List of hotkey commands. 4 | * 5 | * Copyright (c) 2007-2012 VirtuaWin (VirtuaWin@home.se) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | * USA. 21 | */ 22 | 23 | VW_COMMAND (vwCMD_NAV_MOVE_LEFT, 1, 0, "NAV: Move left") 24 | VW_COMMAND (vwCMD_NAV_MOVE_RIGHT, 2, 0, "NAV: Move right") 25 | VW_COMMAND (vwCMD_NAV_MOVE_UP, 3, 0, "NAV: Move up") 26 | VW_COMMAND (vwCMD_NAV_MOVE_DOWN, 4, 0, "NAV: Move down") 27 | VW_COMMAND (vwCMD_NAV_MOVE_NEXT, 6, 0, "NAV: Move to next") 28 | VW_COMMAND (vwCMD_NAV_MOVE_PREV, 5, 0, "NAV: Move to previous") 29 | VW_COMMAND (vwCMD_NAV_MOVE_DESKTOP, 7, 1, "NAV: Move to desktop #") 30 | VW_COMMAND (vwCMD_NAV_MOVE_LAST, 39, 0, "NAV: Return to last desktop") 31 | VW_COMMAND (vwCMD_WIN_STICKY, 8, 2, "WIN: Toggle always show") 32 | VW_COMMAND (vwCMD_WIN_ALWAYSONTOP, 25, 2, "WIN: Always on top") 33 | VW_COMMAND (vwCMD_WIN_BRINGTOTOP, 42, 4, "WIN: Bring to top") 34 | VW_COMMAND (vwCMD_WIN_PUSHTOBOTTOM, 24, 2, "WIN: Push to bottom") 35 | VW_COMMAND (vwCMD_WIN_DISMISS, 9, 2, "WIN: Dismiss window") 36 | VW_COMMAND (vwCMD_WIN_GATHER, 29, 2, "WIN: Gather process windows") 37 | VW_COMMAND (vwCMD_WIN_MOVE_LEFT, 30, 2, "WIN: Move left") 38 | VW_COMMAND (vwCMD_WIN_MOVE_RIGHT, 32, 2, "WIN: Move right") 39 | VW_COMMAND (vwCMD_WIN_MOVE_UP, 34, 2, "WIN: Move up") 40 | VW_COMMAND (vwCMD_WIN_MOVE_DOWN, 36, 2, "WIN: Move down") 41 | VW_COMMAND (vwCMD_WIN_MOVE_NEXT, 14, 2, "WIN: Move to next desktop") 42 | VW_COMMAND (vwCMD_WIN_MOVE_PREV, 12, 2, "WIN: Move to previous desktop") 43 | VW_COMMAND (vwCMD_WIN_MOVE_DESKTOP, 10, 3, "WIN: Move to desktop #") 44 | VW_COMMAND (vwCMD_WIN_MOVE_LEFT_FOL, 31, 2, "WIN: Move left and follow") 45 | VW_COMMAND (vwCMD_WIN_MOVE_RIGHT_FOL,33, 2, "WIN: Move right and follow") 46 | VW_COMMAND (vwCMD_WIN_MOVE_UP_FOL, 35, 2, "WIN: Move up and follow") 47 | VW_COMMAND (vwCMD_WIN_MOVE_DOWN_FOL, 37, 2, "WIN: Move down and follow") 48 | VW_COMMAND (vwCMD_WIN_MOVE_NEXT_FOL, 15, 2, "WIN: Move to next desktop and follow") 49 | VW_COMMAND (vwCMD_WIN_MOVE_PREV_FOL, 13, 2, "WIN: Move to prev desktop and follow") 50 | VW_COMMAND (vwCMD_WIN_MOVE_DESK_FOL, 11, 3, "WIN: Move to desktop # and follow") 51 | VW_COMMAND (vwCMD_WIN_GATHER_ALL, 26, 0, "WIN: Gather all windows") 52 | VW_COMMAND (vwCMD_WIN_REAPPLY_RULES, 46, 0, "WIN: Reapply window rules") 53 | VW_COMMAND (vwCMD_UI_CTLMENU_STD, 43, 0, "UI: Open standard control menu") 54 | VW_COMMAND (vwCMD_UI_CTLMENU_CMP, 28, 0, "UI: Open compact control menu") 55 | VW_COMMAND (vwCMD_UI_WINMENU_STD, 18, 0, "UI: Open standard window menu") 56 | VW_COMMAND (vwCMD_UI_WINMENU_CMP, 19, 0, "UI: Open compact window menu") 57 | VW_COMMAND (vwCMD_UI_WINLIST_STD, 20, 0, "UI: Open standard window list") 58 | VW_COMMAND (vwCMD_UI_WINLIST_CMP, 21, 0, "UI: Open compact window list") 59 | VW_COMMAND (vwCMD_UI_WINLIST_MRU, 22, 0, "UI: Open most recently used window list") 60 | VW_COMMAND (vwCMD_UI_WTYPE_SETUP, 27, 0, "UI: Open window rule setup") 61 | VW_COMMAND (vwCMD_UI_SETUP, 23, 0, "UI: Open VirtuaWin setup") 62 | VW_COMMAND (vwCMD_UI_ENABLESTATE, 38, 0, "UI: Toggle enable state") 63 | VW_COMMAND (vwCMD_UI_SYSTRAYICON, 40, 0, "UI: Toggle display of system tray icon") 64 | VW_COMMAND (vwCMD_UI_BOSS_KEY, 44, 0, "UI: Boss key") 65 | VW_COMMAND (vwCMD_UI_UNBOSS_KEY, 45, 0, "UI: Un-Boss key") 66 | VW_COMMAND (vwCMD_UI_EXIT, 41, 0, "UI: Exit VirtuaWin") 67 | VW_COMMAND (vwCMD_END, 0, 0, "Unsupported command") 68 | -------------------------------------------------------------------------------- /WinList.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {7F6B8F62-4366-47E2-9C5A-43E9630B0F3B} 24 | WinList 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | v120 37 | true 38 | MultiByte 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | $(Configuration)\winList\ 52 | 53 | 54 | 55 | Level3 56 | Disabled 57 | true 58 | _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 59 | /FS %(AdditionalOptions) 60 | 61 | 62 | true 63 | "Comctl32.lib" %(AdditionalOptions) 64 | 65 | 66 | 67 | 68 | Level3 69 | MaxSpeed 70 | true 71 | true 72 | true 73 | /FS %(AdditionalOptions) 74 | 75 | 76 | true 77 | true 78 | true 79 | "Comctl32.lib" %(AdditionalOptions) 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Source/ConfigParameters.h: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // ConfigParameters.h - Declaration of configured variables 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | 24 | #ifndef _CONFIGPARAMETERS_H_ 25 | #define _CONFIGPARAMETERS_H_ 26 | 27 | #define vwWINLIST_ACCESS 0x01 28 | #define vwWINLIST_ASSIGN 0x02 29 | #define vwWINLIST_SHOW 0x04 30 | #define vwWINLIST_STICKY 0x08 31 | #define vwWINLIST_TITLELN 0x40 32 | 33 | extern HWND dialogHWnd; // handle to the setup dialog, NULL if not open 34 | extern int dialogPos[2]; // Where to place the dialog 35 | extern vwUByte dialogOpen; // Flags whether a dialog is open 36 | 37 | extern int hotkeyCount; // Number of hotkeys 38 | extern int moduleCount; // Number of loaded modules 39 | extern int currentDesk; // Current desktop 40 | extern int nDesks; // indicates the total number of desks (nDesksX * nDesksY) 41 | extern int nDesksX; // indicates the number of desks wide the virtual area is 42 | extern int nDesksY; // indicates the number of desks tall the virtual area is 43 | extern int mouseJumpLength; // How far to jump into new desktop 44 | extern int mouseDelay; // Mouse change delay 50ms*mouseDelay 45 | extern vwUByte mouseKnock; // mouse edge kncking mode 46 | extern vwUByte mouseEnable; // Required mouse support 47 | extern vwUByte mouseWarp; // if we don't want to move the mouse pointer after switch 48 | extern vwUByte mouseModifierUsed; // if user must use a modify key to warp with mouse 49 | extern vwUByte mouseModifier ; // modify key required to warp with mouse 50 | extern vwUByte preserveZOrder; // Should we preserve the window Z order 51 | extern vwUByte hiddenWindowAct; // Hidden window activation action 52 | extern vwUByte taskButtonAct; // Hidden window but visible task button activation action 53 | extern vwUByte releaseFocus; // release focus on switch 54 | extern vwUByte refreshOnWarp; // if we should refresh desktop after switch 55 | extern vwUByte initialDesktop; // The desktop to start on, usually 1 56 | extern vwUByte lastDeskNoDelay; // Don't wait a second before updating lastDesk 57 | extern vwUByte deskWrap; // If we want to have desktop cycling 58 | extern vwUByte invertY; // if up/down should be inverted 59 | extern vwUByte displayTaskbarIcon; // Should we display the systray icon 60 | extern vwUByte noTaskbarCheck; // Should we skip the taskbar search 61 | extern vwUByte useWindowRules; // Use window rules 62 | extern vwUByte useDynButtonRm; // Use dynamic taskbar button removal 63 | extern vwUByte useDskChgModRelease;// Use automatic desktop change modifier release 64 | extern vwUByte winListContent; // Required content of the winodw list menu 65 | extern vwUByte winListCompact; // if window list menu should be compact 66 | extern vwUByte winMenuCompact; // if current window menu should be compact 67 | extern vwUByte ctlMenuCompact; // if control menu should be compact 68 | extern vwUByte hotkeyMenuLoc; // Location to use if menu/list is opened via a hotkey 69 | extern vwUByte aggressiveRules; // Aggressive rule enforcement 70 | extern vwUByte minWinHide; // Flag to determine how to hide minimized windows 71 | extern vwUByte vwHookUse; // Use vwHook to resolve activate issues 72 | 73 | extern TCHAR *desktopName[vwDESKTOP_SIZE]; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Source/VirtuaWin.h: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // VirtuaWin.h - Main variable and function definitions. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | 24 | #ifndef _VIRTUAWIN_H_ 25 | #define _VIRTUAWIN_H_ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Defines.h" 32 | 33 | /* externally accessible variables */ 34 | extern HWND hWnd; // The handle to VirtuaWin 35 | extern int screenLeft; // the screen dimensions, from VirtuaWin.h 36 | extern int screenRight; 37 | extern int screenTop; 38 | extern int screenBottom; 39 | extern int deskImageCount; 40 | 41 | 42 | extern vwWindow *windowList; // list of managed windows 43 | extern vwWindowBase *windowBaseList; // list of all windows 44 | extern vwWindowRule *windowRuleList; // list for holding window rules 45 | extern vwMenuItem *ctlMenuItemList; // List of module inserted control menu items 46 | extern vwHotkey hotkeyList[vwHOTKEY_MAX]; // list for holding hotkeys 47 | 48 | extern int curDisabledMod; // how many disabled modules we have 49 | extern vwModule moduleList[MAXMODULES]; // list that holds modules 50 | extern vwDisModule disabledModules[MAXMODULES*2]; // list with disabled modules 51 | extern HWND ichangeHWnd; // handle to module hangling desktop changes 52 | 53 | /* logging defines & macros */ 54 | extern vwUByte vwLogFlag ; 55 | extern FILE *vwLogFile ; 56 | 57 | #define vwLogEnabled() (vwLogFile != NULL) 58 | #define vwLogBasic(a) (vwLogEnabled() ? vwLogPrint a :0) 59 | 60 | #ifdef vwLOG_VERBOSER 61 | #define vwLogVerboser(a) vwLogVerbose(a) 62 | #else 63 | #define vwLogVerboser(a) 64 | #endif 65 | 66 | #ifdef vwLOG_VERBOSE 67 | #define vwLogVerbose(a) (vwLogEnabled() ? vwLogPrint a :0) 68 | #else 69 | #define vwLogVerbose(a) 70 | #endif 71 | 72 | /* Prototypes from VirtuaWin.c */ 73 | void vwLogPrint(const TCHAR *format, ...) ; 74 | void vwMutexLock(void) ; 75 | void vwMutexRelease(void) ; 76 | HWND vwFindWindow(TCHAR *className, TCHAR *windowText, int printOut) ; 77 | void enableMouse(int turnOn) ; 78 | void setMouseKey(void) ; 79 | void vwHookSetup(void) ; 80 | void vwIconLoad(void) ; 81 | void vwIconSet(int deskNumber, int hungCount) ; 82 | void vwTaskbarHandleGet(void) ; 83 | void vwHotkeyRegister(int warnAll) ; 84 | void vwHotkeyUnregister(int unregAll) ; 85 | void getWorkArea(void) ; 86 | int windowListUpdate(void) ; 87 | void vwWindowRuleReapply(void) ; 88 | void vwLogWindows(void); 89 | int disableDeskImage(int count) ; 90 | int createDeskImage(int deskNo, int createDefault) ; 91 | void setForegroundWin(HWND theWin, int makeTop) ; 92 | int assignWindow(HWND theWin, int theDesk, vwUByte follow, vwUByte force, vwUByte setActive); 93 | int gotoDesk(int theDesk, vwUByte force); 94 | void showHelp(HWND aHWnd, TCHAR *topic); 95 | 96 | /* Prototypes from SetupDialog.c */ 97 | void createSetupDialog(HINSTANCE theHinst, HWND theHwndOwner) ; 98 | void initDesktopProperties(void) ; 99 | void storeDesktopProperties(void) ; 100 | 101 | /* Prototypes from WinRuleDialog.c */ 102 | void createWindowRuleDialog(HINSTANCE theHinst, HWND theHwndOwner, vwWindowRule *wtype, HWND theWin) ; 103 | void updateWindowRuleDialog(HINSTANCE theHinst, HWND theHwndOwner, vwWindowRule *wtype, HWND theWin) ; 104 | void windowRuleFormatDescription(TCHAR* ss, vwWindowRule *wt); 105 | 106 | /* Prototypes from ModuleRoutines.c */ 107 | void vwModulesLoad(void); 108 | void vwModulesSendMessage(UINT Msg, WPARAM wParam, LPARAM lParam); 109 | void vwModulesPostMessage(UINT Msg, WPARAM wParam, LPARAM lParam); 110 | void vwModuleLoad(int moduleIdx, TCHAR *path) ; 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /Source/vwHook/vwHook.c: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // vwHook.c - Windows Hook for sending window activation events. 4 | // 5 | // Copyright (c) 2007-2012 VirtuaWin (VirtuaWin@home.se) 6 | // 7 | // This program is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 2 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | // 22 | #define vwHOOK_BUILD 23 | #define vwHOOK_TEST 0 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "..\Messages.h" 30 | #include "vwHook.h" 31 | 32 | #ifdef _MSC_VER 33 | #pragma data_seg(".VWSHR") 34 | #define SHARED 35 | #else 36 | #define SHARED __attribute__((section(".VWSHR"), shared)) 37 | #endif 38 | 39 | static int vwHookUse SHARED = 0 ; 40 | static HWND vwHWnd SHARED = NULL ; 41 | 42 | #ifdef _MSC_VER 43 | #pragma data_seg() 44 | #pragma comment(linker, "/SECTION:.VWSHR,RWS") 45 | #endif 46 | 47 | #if vwHOOK_TEST 48 | FILE *logfp ; 49 | #endif 50 | 51 | HINSTANCE hookHInst ; 52 | HHOOK hookCallWndProc ; 53 | clock_t vwShowHideTime ; 54 | /* allow up to 0.25secs for VW to change the visibility state of a window */ 55 | #define vwCHANGE_STATE_TIME (CLOCKS_PER_SEC >> 2) 56 | BOOL WINAPI 57 | DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpvReserved) 58 | { 59 | if(fdwReason == DLL_PROCESS_ATTACH) 60 | { 61 | hookHInst = hInst ; 62 | #if vwHOOK_TEST 63 | if(logfp == NULL) 64 | logfp = fopen("c:\\vwHook.log","w+") ; 65 | fprintf(logfp,"DllMain: %p\n",hookHInst) ; 66 | fflush(logfp) ; 67 | #endif 68 | } 69 | return TRUE ; 70 | } 71 | 72 | 73 | LRESULT CALLBACK 74 | vwHookCallWndProc(int nCode, WPARAM wParam, LPARAM lParam) 75 | { 76 | if((nCode == HC_ACTION) && vwHookUse) 77 | { 78 | CWPSTRUCT *cwp = (CWPSTRUCT *) lParam ; 79 | HWND vwh = vwHWnd ; 80 | clock_t cc ; 81 | 82 | #if vwHOOK_TEST 83 | { 84 | SYSTEMTIME stime; 85 | GetLocalTime (&stime); 86 | fprintf(logfp,"[%04d-%02d-%02d %02d:%02d:%02d:%03d] vwHookCallWndProc %x: %d %d %d (%x %x %x) - %x\n", 87 | stime.wYear, stime.wMonth, stime.wDay, stime.wHour, stime.wMinute, stime.wSecond, stime.wMilliseconds, 88 | cwp->hwnd,cwp->message,cwp->wParam,cwp->lParam,cwp->message,cwp->wParam,cwp->lParam, 89 | GetWindowLong(cwp->hwnd, GWL_STYLE)) ; 90 | fflush(logfp) ; 91 | } 92 | #endif 93 | if(cwp->hwnd == vwh) 94 | /* dont report any VW window events back to VW */ 95 | ; 96 | else if((cwp->message == WM_ACTIVATE) && (LOWORD(cwp->wParam) != WA_INACTIVE) && 97 | (((cc=clock()) - vwShowHideTime) > vwCHANGE_STATE_TIME)) 98 | { 99 | #if vwHOOK_TEST 100 | fprintf(logfp," Activate: %d %d\n",vwShowHideTime,cc) ; 101 | fflush(logfp) ; 102 | #endif 103 | /* set time to this time to avoid sending more than one message at a time */ 104 | vwShowHideTime = cc ; 105 | PostMessage(vwh,VW_ACCESSWIN,(WPARAM) cwp->hwnd,-1) ; 106 | } 107 | else if((cwp->message == WM_NULL) && (cwp->wParam == 0x51842145) && (cwp->lParam == 0x5e7bdeba)) 108 | vwShowHideTime = clock() ; 109 | 110 | } 111 | 112 | return CallNextHookEx(hookCallWndProc,nCode,wParam,lParam) ; 113 | } 114 | 115 | vwHOOK_EXPORT void 116 | vwHookSetup(HWND ivwHWnd, int ivwHookUse) 117 | { 118 | vwHWnd = ivwHWnd ; 119 | vwHookUse = ivwHookUse ; 120 | } 121 | 122 | vwHOOK_EXPORT int 123 | vwHookInstall(void) 124 | { 125 | #if vwHOOK_TEST 126 | /* only hook the vwTestApp */ 127 | DWORD vwHookThreadId ; 128 | HWND hWnd ; 129 | 130 | if(logfp == NULL) 131 | logfp = fopen("c:\\vwHook.log","w+") ; 132 | fprintf(logfp,"vwHookInstall: %p\n",hookHInst) ; 133 | fflush(logfp) ; 134 | 135 | if(((hWnd = FindWindow("#32770","vwTestApp")) == NULL) || 136 | ((vwHookThreadId = GetWindowThreadProcessId(hWnd,NULL)) == 0)) 137 | return 1 ; 138 | fprintf(logfp,"vwHookInstall: %p: %x %d\n",hookHInst,hWnd,vwHookThreadId) ; 139 | fflush(logfp) ; 140 | #else 141 | #define vwHookThreadId 0 142 | #endif 143 | if((hookCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC,vwHookCallWndProc,hookHInst,vwHookThreadId)) == NULL) 144 | return 2 ; 145 | return 0 ; 146 | } 147 | 148 | vwHOOK_EXPORT void 149 | vwHookUninstall(void) 150 | { 151 | UnhookWindowsHookEx(hookCallWndProc) ; 152 | } 153 | -------------------------------------------------------------------------------- /VirtuaWin.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {3517D8E1-A68F-4EB4-8B87-D3474AE599C8} 15 | Win32Proj 16 | VirtuaWin 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | $(VC_IncludePath);$(WindowsSDK_IncludePath);Source 45 | $(VC_SourcePath);Source 46 | 47 | 48 | false 49 | $(Configuration)\VirtuaWin\ 50 | 51 | 52 | 53 | NotUsing 54 | Level3 55 | Disabled 56 | WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions) 57 | true 58 | /FS %(AdditionalOptions) 59 | 60 | 61 | Windows 62 | true 63 | C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib;%(AdditionalLibraryDirectories) 64 | "Comctl32.lib" %(AdditionalOptions) 65 | 66 | 67 | Source\VirtuaWin.exe.manifest %(AdditionalManifestFiles) 68 | 69 | 70 | 71 | 72 | Level3 73 | NotUsing 74 | MaxSpeed 75 | true 76 | true 77 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 78 | true 79 | /FS %(AdditionalOptions) 80 | 81 | 82 | Windows 83 | true 84 | true 85 | true 86 | "Comctl32.lib" %(AdditionalOptions) 87 | 88 | 89 | Source\VirtuaWin.exe.manifest %(AdditionalManifestFiles) 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | NotUsing 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /Source/ModuleRoutines.c: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // ModuleRoutines.c - Module handling routines. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | 24 | // Includes 25 | #include "VirtuaWin.h" 26 | #include "Messages.h" 27 | #include "ConfigParameters.h" 28 | #include "DiskRoutines.h" 29 | 30 | // Standard includes 31 | #include 32 | #include 33 | 34 | /************************************************* 35 | * Checks if a module is disabled 36 | */ 37 | static int 38 | vwModuleCheckDisabled(TCHAR *theModName) 39 | { 40 | int modIndex; 41 | 42 | for (modIndex = 0; modIndex < curDisabledMod; ++modIndex) 43 | if(!_tcsncmp(disabledModules[modIndex].moduleName,theModName,(_tcslen(theModName) - 4))) 44 | return TRUE; // Module disabled 45 | return FALSE; // Not disabled 46 | } 47 | 48 | void 49 | vwModuleLoad(int moduleIdx, TCHAR *path) 50 | { 51 | HWND modHWnd ; 52 | TCHAR buff[MAX_PATH], *s1, *s2 ; 53 | STARTUPINFO si; 54 | PROCESS_INFORMATION pi; 55 | int rv1, rv2 ; 56 | 57 | s1 = buff ; 58 | *s1++ = '"' ; 59 | if(path != NULL) 60 | { 61 | _tcscpy_s(s1, 260, path); 62 | s1 += _tcslen(s1) ; 63 | } 64 | else 65 | { 66 | GetFilename(vwMODULES,0,s1); 67 | if((s2 = _tcsrchr(s1,'\\')) != NULL) 68 | s1 = s2 + 1 ; 69 | } 70 | _tcscpy_s(s1, 261, moduleList[moduleIdx].description); 71 | s2 = s1 + _tcslen(s1); 72 | _tcscpy_s(s2, 261, _T(".exe")); 73 | s2 += 4 ; 74 | if((modHWnd = vwFindWindow(s1,NULL,0)) != NULL) 75 | { 76 | _stprintf_s(buff, 260, _T("The module '%s' seems to already be running and will be re-used. This is probably due to incorrect shutdown of VirtuaWin."), moduleList[moduleIdx].description); 77 | MessageBox(hWnd,buff,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONWARNING); 78 | } 79 | else 80 | { 81 | // Launch the module 82 | _tcscpy_s(s2, 260, _T("\" -module")); 83 | memset(&si, 0, sizeof(si)); 84 | si.cb = sizeof(si); 85 | if(!CreateProcess(NULL,buff,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) 86 | { 87 | vwLogBasic((_T("Failed to launch module: [%s] %d\n"),buff,(int) GetLastError())); 88 | _stprintf_s(buff,260, _T("Failed to launch module '%s'. (Err %d)"),moduleList[moduleIdx].description,(int) GetLastError()); 89 | MessageBox(hWnd,buff,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONWARNING); 90 | } 91 | else 92 | { 93 | CloseHandle(pi.hThread) ; 94 | // Wait max 20 sec for the module to initialize itself then close the process handle 95 | rv1 = WaitForInputIdle(pi.hProcess, 20000); 96 | *s2 = '\0' ; 97 | 98 | // Find the module with classname 99 | if((modHWnd = vwFindWindow(s1,NULL,0)) == NULL) 100 | { 101 | Sleep(500) ; 102 | rv2 = WaitForInputIdle(pi.hProcess,10000) ; 103 | if((modHWnd = vwFindWindow(s1,NULL,1)) == NULL) 104 | { 105 | _stprintf_s(buff,260, _T("Failed to load module '%s' - maybe wrong class or file name? (Err %d, %d, %d)"),moduleList[moduleIdx].description,rv1,rv2,(int) GetLastError()); 106 | MessageBox(hWnd,buff,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONWARNING); 107 | } 108 | } 109 | CloseHandle(pi.hProcess) ; 110 | } 111 | } 112 | if((moduleList[moduleIdx].handle = modHWnd) != NULL) 113 | PostMessage(modHWnd, MOD_INIT, (WPARAM) hWnd , 0); 114 | } 115 | 116 | /************************************************* 117 | * Adds a module to a list, found by vwModulesLoad() 118 | */ 119 | static void 120 | vwModuleAdd(TCHAR *moduleName, TCHAR *path) 121 | { 122 | TCHAR buff[MAX_PATH]; 123 | int ll ; 124 | 125 | // remove .exe to get module name 126 | ll = _tcslen(moduleName) - 4 ; 127 | moduleName[ll] = '\0'; 128 | if(ll > vwMODULENAME_MAX) 129 | { 130 | _stprintf_s(buff, 260, _T("Name of module '%s' is too long, maximum is %d."), moduleName, vwMODULENAME_MAX); 131 | MessageBox(hWnd,buff,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONWARNING); 132 | return; 133 | } 134 | if(moduleCount >= MAXMODULES) 135 | { 136 | _stprintf_s(buff, 260, _T("Max number of modules have been added, '%s' won't be loaded."), moduleName); 137 | MessageBox(hWnd,buff,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONWARNING); 138 | return; 139 | } 140 | 141 | // Add the module to the list 142 | _tcsncpy_s(moduleList[moduleCount].description, 80, moduleName, vwMODULENAME_MAX); 143 | moduleList[moduleCount].disabled = vwModuleCheckDisabled(moduleName) ; 144 | 145 | if(moduleList[moduleCount].disabled) 146 | // The module is disabled 147 | moduleList[moduleCount].handle = NULL; 148 | else 149 | vwModuleLoad(moduleCount,path) ; 150 | moduleCount++; 151 | return; 152 | } 153 | 154 | /************************************************* 155 | * Locates modules in "Modules" directory, that is 156 | * all files with an .exe extension 157 | */ 158 | void 159 | vwModulesLoad(void) 160 | { 161 | WIN32_FIND_DATA exe_file; 162 | TCHAR buff[MAX_PATH], *ss ; 163 | HANDLE hFile; 164 | 165 | GetFilename(vwMODULES,0,buff); 166 | 167 | // Find first .exe file in modules directory 168 | if((hFile = FindFirstFile(buff,&exe_file)) != INVALID_HANDLE_VALUE) 169 | { 170 | if((ss = _tcsrchr(buff,'\\')) != NULL) 171 | ss[1] = '\0' ; 172 | do { 173 | vwModuleAdd(exe_file.cFileName,buff); 174 | } while(FindNextFile(hFile,&exe_file)) ; 175 | 176 | FindClose(hFile); 177 | } 178 | } 179 | 180 | /************************************************* 181 | * Sends a message to all modules in the list 182 | */ 183 | void 184 | vwModulesSendMessage(UINT Msg, WPARAM wParam, LPARAM lParam) 185 | { 186 | int index; 187 | for(index = 0; index < moduleCount; ++index) 188 | if(moduleList[index].handle != NULL) 189 | SendMessageTimeout(moduleList[index].handle,Msg,wParam,lParam,SMTO_ABORTIFHUNG|SMTO_BLOCK,10000,NULL); 190 | } 191 | 192 | /************************************************* 193 | * Posts a message to all modules in the list 194 | */ 195 | void 196 | vwModulesPostMessage(UINT Msg, WPARAM wParam, LPARAM lParam) 197 | { 198 | int index; 199 | for(index = 0; index < moduleCount; ++index) 200 | if(moduleList[index].handle != NULL) 201 | PostMessage(moduleList[index].handle, Msg, wParam, lParam); 202 | } 203 | -------------------------------------------------------------------------------- /Source/Module/Module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | * Module.c - Example user module for VirtuaWin. 4 | * 5 | * Copyright (c) 1999-2005 Johan Piculell 6 | * Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | * USA. 22 | * 23 | ************************************************************************* 24 | * 25 | * Simple module skeleton for VirtuaWin. These are the minimal requirements. 26 | * It is a simple application with a hidden window that receives messages from virtuawin 27 | * Look in Messages.h to see what can be sent to and from VirtuaWin 28 | * 29 | * Note that the classname must be the same as the filename including the '.exe' 30 | */ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "Messages.h" 36 | 37 | int initialised=0 ; 38 | HWND vwHandle; /* Handle to VirtuaWin */ 39 | TCHAR installPath[MAX_PATH] ; /* VW install path */ 40 | TCHAR userAppPath[MAX_PATH] ; /* User's config path */ 41 | TCHAR deskName[MAX_PATH] ; /* Current desktop's name */ 42 | 43 | static void 44 | DisplayInfo(HWND hwnd, TCHAR *msgLabel) 45 | { 46 | TCHAR buff[MAX_PATH+MAX_PATH+MAX_PATH]; 47 | int deskSize, deskX, deskY, currentDesk ; 48 | deskSize = SendMessage(vwHandle, VW_DESKTOP_SIZE,0,0) ; 49 | deskX = SendMessage(vwHandle, VW_DESKX,0,0) ; 50 | deskY = SendMessage(vwHandle, VW_DESKY,0,0) ; 51 | currentDesk = SendMessage(vwHandle, VW_CURDESK,0,0) ; 52 | if(!SendMessage(vwHandle, VW_DESKNAME, (WPARAM) hwnd, 0)) 53 | { 54 | MessageBox(hwnd,_T("VirtuaWin failed to send the current Desktop name."),_T("Module Error"), MB_ICONWARNING); 55 | exit(1) ; 56 | } 57 | if(deskName[0] == '\0') 58 | _stprintf_s(deskName,260, _T(""),currentDesk) ; 59 | _stprintf_s(buff,780, _T("Desktop Size:\t%d\nInstall path:\t%s\t\nUser path:\t%s\t\n\nVW Message:\t%s\nDesk Layout:\t%d x %d\nCurrent Desk:\t%d\nDesk Name:\t%s"), 60 | deskSize,installPath,userAppPath,msgLabel,deskX,deskY,currentDesk,deskName) ; 61 | MessageBox(hwnd,buff,_T("VirtuaWin Module Example"),0); 62 | } 63 | 64 | 65 | LRESULT CALLBACK 66 | MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 67 | { 68 | switch (msg) 69 | { 70 | case MOD_INIT: 71 | /* This must be taken care of in order to get the handle to VirtuaWin. */ 72 | /* The handle to VirtuaWin comes in the wParam */ 73 | vwHandle = (HWND) wParam; /* Should be some error handling here if NULL */ 74 | if(!initialised) 75 | { 76 | /* Get the VW Install path and then the user's path - give VirtuaWin 10 seconds to do this */ 77 | if(!SendMessage(vwHandle, VW_INSTALLPATH, (WPARAM) hwnd, 0) || ((initialised & 1) == 0)) 78 | { 79 | MessageBox(hwnd,_T("VirtuaWin failed to send install path."),_T("Module Error"), MB_ICONWARNING); 80 | exit(1) ; 81 | } 82 | if(!SendMessage(vwHandle, VW_USERAPPPATH, (WPARAM) hwnd, 0) || ((initialised & 2) == 0)) 83 | { 84 | MessageBox(hwnd,_T("VirtuaWin failed to send the UserApp path."),_T("Module Error"), MB_ICONWARNING); 85 | exit(1) ; 86 | } 87 | 88 | } 89 | DisplayInfo(hwnd,_T("Init")) ; 90 | break; 91 | 92 | case WM_COPYDATA: 93 | { 94 | COPYDATASTRUCT *cds; 95 | cds = (COPYDATASTRUCT *) lParam ; 96 | if((cds->dwData == (0-VW_INSTALLPATH)) && ((initialised & 1) == 0)) 97 | { 98 | if((cds->cbData < 2) || (cds->lpData == NULL)) 99 | return FALSE ; 100 | initialised |= 1 ; 101 | /* the paths are always returned in a multibyte string so we do not need to know 102 | * whether we are talking to a unicode VW */ 103 | #ifdef _UNICODE 104 | MultiByteToWideChar(CP_ACP,0,(char *) cds->lpData,-1,installPath,MAX_PATH) ; 105 | #else 106 | strncpy_s(installPath,260,(char *) cds->lpData,MAX_PATH) ; 107 | #endif 108 | installPath[MAX_PATH-1] = '\0' ; 109 | } 110 | else if((cds->dwData == (0-VW_USERAPPPATH)) && ((initialised & 2) == 0)) 111 | { 112 | if((cds->cbData < 2) || (cds->lpData == NULL)) 113 | return FALSE ; 114 | initialised |= 2 ; 115 | #ifdef _UNICODE 116 | MultiByteToWideChar(CP_ACP,0,(char *) cds->lpData,-1,userAppPath,MAX_PATH) ; 117 | #else 118 | strncpy_s(userAppPath, 260, (char *) cds->lpData,MAX_PATH) ; 119 | #endif 120 | userAppPath[MAX_PATH-1] = '\0' ; 121 | } 122 | else if(cds->dwData == (0-VW_DESKNAME)) 123 | { 124 | if(cds->lpData == NULL) 125 | deskName[0] = '\0' ; 126 | else 127 | { 128 | #ifdef _UNICODE 129 | MultiByteToWideChar(CP_ACP,0,(char *) cds->lpData,-1,deskName,MAX_PATH) ; 130 | #else 131 | strncpy_s(deskName,260, (char *) cds->lpData,MAX_PATH) ; 132 | #endif 133 | deskName[MAX_PATH-1] = '\0' ; 134 | } 135 | } 136 | } 137 | return TRUE ; 138 | 139 | case MOD_QUIT: 140 | /* This must be handled, otherwise VirtuaWin can't shut down the module */ 141 | PostQuitMessage(0); 142 | break; 143 | case MOD_SETUP: 144 | /* Optional */ 145 | DisplayInfo(hwnd,_T("Setup")) ; 146 | break; 147 | case MOD_CFGCHANGE: 148 | DisplayInfo(hwnd,_T("Config Change")) ; 149 | break; 150 | case WM_DESTROY: 151 | PostQuitMessage(0); 152 | break; 153 | default: 154 | return DefWindowProc(hwnd, msg, wParam, lParam); 155 | } 156 | 157 | return 0; 158 | } 159 | 160 | /* 161 | * Main startup function 162 | */ 163 | int WINAPI 164 | WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) 165 | { 166 | WNDCLASS wc; 167 | MSG msg; 168 | 169 | memset(&wc, 0, sizeof(WNDCLASS)); 170 | wc.style = 0; 171 | wc.lpfnWndProc = (WNDPROC)MainWndProc; 172 | wc.hInstance = hInstance ; 173 | /* IMPORTANT! The classname must be the same as the filename since VirtuaWin uses 174 | this for locating the window */ 175 | wc.lpszClassName = _T("Module.exe"); 176 | 177 | if (!RegisterClass(&wc)) 178 | return 0; 179 | 180 | /* In this example, the window is never shown */ 181 | if (CreateWindow(_T("Module.exe"), 182 | _T("Module"), 183 | WS_POPUP, 184 | CW_USEDEFAULT, 185 | 0, 186 | CW_USEDEFAULT, 187 | 0, 188 | NULL, 189 | NULL, 190 | hInstance, 191 | NULL) == (HWND) 0) 192 | return 0; 193 | 194 | /* main messge loop */ 195 | while (GetMessage(&msg, NULL, 0, 0)) 196 | { 197 | TranslateMessage(&msg); 198 | DispatchMessage(&msg); 199 | } 200 | return msg.wParam; 201 | } 202 | -------------------------------------------------------------------------------- /Source/Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // ConfigParameters.h - Constant definitions used. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | */ 23 | 24 | #ifndef _DEFINES_H_ 25 | #define _DEFINES_H 26 | 27 | #include 28 | 29 | /* Application name and version defines */ 30 | #define vwVIRTUAWIN_NAME _T("VirtuaWin") 31 | #define vwVIRTUAWIN_CLASSNAME _T("VirtuaWinMainClass") 32 | #define vwVIRTUAWIN_EMAIL _T("VirtuaWin@home.se") 33 | #define vwVIRTUAWIN_NAME_VERSION _T("VirtuaWin v4.4") 34 | #define vwVIRTUAWIN_WEBSITE _T("http://virtuawin.sourceforge.net/") 35 | #define vwVIRTUAWIN_MODULES_URL vwVIRTUAWIN_WEBSITE _T("modules.php") 36 | 37 | /* Various defines used on several places */ 38 | #define vwHOTKEY_MAX 80 /* max number of hotkeys */ 39 | #define vwWINHASH_SIZE 509 /* size of the window hash table */ 40 | #define vwDESKTOP_MAX 20 /* max number of desktops */ 41 | #define vwDESKTOP_SIZE (vwDESKTOP_MAX + 2) 42 | #define vwCLASSNAME_MAX 64 /* class name buffer size */ 43 | #define vwWINDOWNAME_MAX 128 /* window name buffer size */ 44 | #define vwMODULENAME_MAX 79 /* Maximum length of a module name (buffer needs to be n+1 long) */ 45 | 46 | #define MAXMODULES 10 /* max number of modules to handle */ 47 | 48 | /* Internal windows messages */ 49 | #define VW_SYSTRAY (WM_USER + 1) /* Sent to us by the systray */ 50 | #define VW_MOUSEWARP (WM_USER + 9) /* Mouse thread message */ 51 | 52 | /* Some base types used to make code more readable */ 53 | typedef unsigned int vwUInt ; 54 | typedef unsigned short vwUShort ; 55 | typedef unsigned char vwUByte ; 56 | 57 | #define vwWTNAME_NONE _T("") 58 | #define vwWTNAME_COUNT 3 59 | #define vwWTFLAGS_CN_SVAR 0x00000001 60 | #define vwWTFLAGS_CN_EVAR 0x00000002 61 | #define vwWTFLAGS_WN_SVAR 0x00000004 62 | #define vwWTFLAGS_WN_EVAR 0x00000008 63 | #define vwWTFLAGS_PN_SVAR 0x00000010 64 | #define vwWTFLAGS_PN_EVAR 0x00000020 65 | #define vwWTFLAGS_ALWAYSONTOP 0x00000100 66 | #define vwWTFLAGS_MANAGE 0x00000200 67 | #define vwWTFLAGS_DONT_MANAGE 0x00000400 68 | #define vwWTFLAGS_ENABLED 0x00000800 69 | #define vwWTFLAGS_STICKY 0x00001000 70 | #define vwWTFLAGS_MOVE 0x00002000 71 | #define vwWTFLAGS_MOVE_IMMEDIATE 0x00004000 72 | #define vwWTFLAGS_MAIN_WIN 0x00008000 73 | #define vwWTFLAGS_GROUP_APP 0x00010000 74 | #define vwWTFLAGS_HWACT_MASK 0x000e0000 75 | #define vwWTFLAGS_HWACT_BITROT 17 76 | #define vwWTFLAGS_CLOSE 0x00100000 77 | #define vwWTFLAGS_HIDEWIN_MASK 0x0f000000 78 | #define vwWTFLAGS_HIDEWIN_BITROT 24 79 | #define vwWTFLAGS_HIDEWIN_HIDE 0x00000000 80 | #define vwWTFLAGS_HIDEWIN_MOVE 0x01000000 81 | #define vwWTFLAGS_HIDEWIN_MINIM 0x02000000 82 | #define vwWTFLAGS_HIDETSK_MASK 0xf0000000 83 | #define vwWTFLAGS_HIDETSK_BITROT 28 84 | #define vwWTFLAGS_HIDETSK_HIDE 0x00000000 85 | #define vwWTFLAGS_HIDETSK_DONT 0x10000000 86 | #define vwWTFLAGS_HIDETSK_TOOLWN 0x20000000 87 | 88 | typedef struct vwWindowRule { 89 | struct vwWindowRule *next; 90 | TCHAR *name[vwWTNAME_COUNT] ; 91 | vwUInt flags ; 92 | vwUByte desk ; 93 | vwUByte nameLen[vwWTNAME_COUNT] ; 94 | } vwWindowRule ; 95 | 96 | /* vwWindow structures for storing information about one window */ 97 | #define vwWINFLAGS_INITIALIZED 0x00000001 98 | #define vwWINFLAGS_FOUND 0x00000002 99 | #define vwWINFLAGS_ACTIVATED 0x00000004 100 | #define vwWINFLAGS_VISIBLE 0x00000008 101 | #define vwWINFLAGS_MINIMIZED 0x00000010 102 | #define vwWINFLAGS_WINDOW 0x00000020 103 | #define vwWINFLAGS_MANAGED 0x00000040 104 | #define vwWINFLAGS_MAXIMIZED 0x00000080 105 | #define vwWINFLAGS_SHOWN 0x00000100 106 | #define vwWINFLAGS_SHOW 0x00000200 107 | #define vwWINFLAGS_NO_TASKBAR_BUT 0x00000400 108 | #define vwWINFLAGS_RM_TASKBAR_BUT 0x00000800 109 | #define vwWINFLAGS_FORCE_NOT_MNGD vwWTFLAGS_STICKY 110 | #define vwWINFLAGS_STICKY vwWTFLAGS_STICKY 111 | #define vwWINFLAGS_MOVE vwWTFLAGS_MOVE 112 | #define vwWINFLAGS_MOVE_IMMEDIATE vwWTFLAGS_MOVE_IMMEDIATE 113 | #define vwWINFLAGS_MAIN_WIN vwWTFLAGS_MAIN_WIN 114 | #define vwWINFLAGS_GROUP_APP vwWTFLAGS_GROUP_APP 115 | #define vwWINFLAGS_HWACT_MASK vwWTFLAGS_HWACT_MASK 116 | #define vwWINFLAGS_HWACT_BITROT vwWTFLAGS_HWACT_BITROT 117 | #define vwWINFLAGS_ELEVATED 0x00100000 118 | #define vwWINFLAGS_ELEVATED_TEST 0x00200000 119 | #define vwWINFLAGS_HIDEWIN_MASK vwWTFLAGS_HIDEWIN_MASK 120 | #define vwWINFLAGS_HIDEWIN_HIDE vwWTFLAGS_HIDEWIN_HIDE 121 | #define vwWINFLAGS_HIDEWIN_MOVE vwWTFLAGS_HIDEWIN_MOVE 122 | #define vwWINFLAGS_HIDEWIN_MINIM vwWTFLAGS_HIDEWIN_MINIM 123 | #define vwWINFLAGS_HIDETSK_MASK vwWTFLAGS_HIDETSK_MASK 124 | #define vwWINFLAGS_HIDETSK_HIDE vwWTFLAGS_HIDETSK_HIDE 125 | #define vwWINFLAGS_HIDETSK_DONT vwWTFLAGS_HIDETSK_DONT 126 | #define vwWINFLAGS_HIDETSK_TOOLWN vwWTFLAGS_HIDETSK_TOOLWN 127 | 128 | /* vwWindowBase - Holds data far a non-managed window */ 129 | typedef struct vwWindowBase { 130 | struct vwWindowBase *next ; 131 | struct vwWindowBase *hash ; 132 | HWND handle ; 133 | vwUInt flags ; 134 | } vwWindowBase; 135 | 136 | /* vwWindow - Holds data far a managed window, start must be the same as vwWindowBase */ 137 | typedef struct vwWindow { 138 | /* same as vwWindowBase - start */ 139 | struct vwWindow *next ; 140 | struct vwWindow *hash ; 141 | HWND handle ; 142 | vwUInt flags ; 143 | /* same as vwWindowBase - end */ 144 | long exStyle; 145 | DWORD processId ; 146 | struct vwWindow *processNext ; 147 | struct vwWindow *linkedNext ; 148 | vwUInt zOrder[vwDESKTOP_SIZE] ; 149 | vwUByte menuId ; 150 | vwUByte desk; 151 | vwUByte assignedDesk; 152 | vwWindowRule *wt; 153 | } vwWindow ; 154 | 155 | /* Holds data for modules */ 156 | typedef struct { 157 | HWND handle; 158 | TCHAR description[vwMODULENAME_MAX+1]; 159 | vwUByte disabled; 160 | } vwModule ; 161 | 162 | /* Holds disabled modules */ 163 | typedef struct { 164 | TCHAR moduleName[vwMODULENAME_MAX+1]; 165 | } vwDisModule ; 166 | 167 | /* vwListItem - Structure used by the window list menu */ 168 | typedef struct { 169 | TCHAR *name; 170 | HICON icon; 171 | vwUInt zOrder ; 172 | vwUShort id; 173 | vwUByte desk; 174 | vwUByte sticky; 175 | } vwListItem ; 176 | 177 | /* vwHotkey - Structure to store a hotkey binding */ 178 | #define vwHOTKEY_ALT MOD_ALT 179 | #define vwHOTKEY_CONTROL MOD_CONTROL 180 | #define vwHOTKEY_SHIFT MOD_SHIFT 181 | #define vwHOTKEY_WIN MOD_WIN 182 | #define vwHOTKEY_MOD_MASK (MOD_ALT|MOD_CONTROL|MOD_SHIFT|MOD_WIN) 183 | #define vwHOTKEY_EXT 0x10 184 | #define vwHOTKEY_WIN_MOUSE 0x20 185 | 186 | typedef struct { 187 | ATOM atom ; 188 | vwUByte key ; 189 | vwUByte modifier ; 190 | vwUByte command ; 191 | vwUByte desk ; 192 | } vwHotkey ; 193 | 194 | #define vwMENU_LABEL_MAX 40 195 | 196 | typedef struct vwMenuItem { 197 | struct vwMenuItem *next ; 198 | HWND module ; 199 | HMENU submenu ; 200 | vwUShort position ; 201 | vwUShort message ; 202 | vwUShort id ; 203 | TCHAR label[vwMENU_LABEL_MAX] ; 204 | } vwMenuItem ; 205 | 206 | typedef struct { 207 | vwUShort position ; 208 | vwUShort message ; 209 | char label[vwMENU_LABEL_MAX] ; 210 | } vwMenuItemMsg ; 211 | 212 | #endif 213 | -------------------------------------------------------------------------------- /Source/Module/Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // ConfigParameters.h - Constant definitions used. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | */ 23 | 24 | #ifndef _DEFINES_H_ 25 | #define _DEFINES_H 26 | 27 | #include 28 | 29 | /* Application name and version defines */ 30 | #define vwVIRTUAWIN_NAME _T("VirtuaWin") 31 | #define vwVIRTUAWIN_CLASSNAME _T("VirtuaWinMainClass") 32 | #define vwVIRTUAWIN_EMAIL _T("VirtuaWin@home.se") 33 | #define vwVIRTUAWIN_NAME_VERSION _T("VirtuaWin v4.4") 34 | #define vwVIRTUAWIN_WEBSITE _T("http://virtuawin.sourceforge.net/") 35 | #define vwVIRTUAWIN_MODULES_URL vwVIRTUAWIN_WEBSITE _T("modules.php") 36 | 37 | /* Various defines used on several places */ 38 | #define vwHOTKEY_MAX 80 /* max number of hotkeys */ 39 | #define vwWINHASH_SIZE 509 /* size of the window hash table */ 40 | #define vwDESKTOP_MAX 20 /* max number of desktops */ 41 | #define vwDESKTOP_SIZE (vwDESKTOP_MAX + 2) 42 | #define vwCLASSNAME_MAX 64 /* class name buffer size */ 43 | #define vwWINDOWNAME_MAX 128 /* window name buffer size */ 44 | #define vwMODULENAME_MAX 79 /* Maximum length of a module name (buffer needs to be n+1 long) */ 45 | 46 | #define MAXMODULES 10 /* max number of modules to handle */ 47 | 48 | /* Internal windows messages */ 49 | #define VW_SYSTRAY (WM_USER + 1) /* Sent to us by the systray */ 50 | #define VW_MOUSEWARP (WM_USER + 9) /* Mouse thread message */ 51 | 52 | /* Some base types used to make code more readable */ 53 | typedef unsigned int vwUInt ; 54 | typedef unsigned short vwUShort ; 55 | typedef unsigned char vwUByte ; 56 | 57 | #define vwWTNAME_NONE _T("") 58 | #define vwWTNAME_COUNT 3 59 | #define vwWTFLAGS_CN_SVAR 0x00000001 60 | #define vwWTFLAGS_CN_EVAR 0x00000002 61 | #define vwWTFLAGS_WN_SVAR 0x00000004 62 | #define vwWTFLAGS_WN_EVAR 0x00000008 63 | #define vwWTFLAGS_PN_SVAR 0x00000010 64 | #define vwWTFLAGS_PN_EVAR 0x00000020 65 | #define vwWTFLAGS_ALWAYSONTOP 0x00000100 66 | #define vwWTFLAGS_MANAGE 0x00000200 67 | #define vwWTFLAGS_DONT_MANAGE 0x00000400 68 | #define vwWTFLAGS_ENABLED 0x00000800 69 | #define vwWTFLAGS_STICKY 0x00001000 70 | #define vwWTFLAGS_MOVE 0x00002000 71 | #define vwWTFLAGS_MOVE_IMMEDIATE 0x00004000 72 | #define vwWTFLAGS_MAIN_WIN 0x00008000 73 | #define vwWTFLAGS_GROUP_APP 0x00010000 74 | #define vwWTFLAGS_HWACT_MASK 0x000e0000 75 | #define vwWTFLAGS_HWACT_BITROT 17 76 | #define vwWTFLAGS_CLOSE 0x00100000 77 | #define vwWTFLAGS_HIDEWIN_MASK 0x0f000000 78 | #define vwWTFLAGS_HIDEWIN_BITROT 24 79 | #define vwWTFLAGS_HIDEWIN_HIDE 0x00000000 80 | #define vwWTFLAGS_HIDEWIN_MOVE 0x01000000 81 | #define vwWTFLAGS_HIDEWIN_MINIM 0x02000000 82 | #define vwWTFLAGS_HIDETSK_MASK 0xf0000000 83 | #define vwWTFLAGS_HIDETSK_BITROT 28 84 | #define vwWTFLAGS_HIDETSK_HIDE 0x00000000 85 | #define vwWTFLAGS_HIDETSK_DONT 0x10000000 86 | #define vwWTFLAGS_HIDETSK_TOOLWN 0x20000000 87 | 88 | typedef struct vwWindowRule { 89 | struct vwWindowRule *next; 90 | TCHAR *name[vwWTNAME_COUNT] ; 91 | vwUInt flags ; 92 | vwUByte desk ; 93 | vwUByte nameLen[vwWTNAME_COUNT] ; 94 | } vwWindowRule ; 95 | 96 | /* vwWindow structures for storing information about one window */ 97 | #define vwWINFLAGS_INITIALIZED 0x00000001 98 | #define vwWINFLAGS_FOUND 0x00000002 99 | #define vwWINFLAGS_ACTIVATED 0x00000004 100 | #define vwWINFLAGS_VISIBLE 0x00000008 101 | #define vwWINFLAGS_MINIMIZED 0x00000010 102 | #define vwWINFLAGS_WINDOW 0x00000020 103 | #define vwWINFLAGS_MANAGED 0x00000040 104 | #define vwWINFLAGS_MAXIMIZED 0x00000080 105 | #define vwWINFLAGS_SHOWN 0x00000100 106 | #define vwWINFLAGS_SHOW 0x00000200 107 | #define vwWINFLAGS_NO_TASKBAR_BUT 0x00000400 108 | #define vwWINFLAGS_RM_TASKBAR_BUT 0x00000800 109 | #define vwWINFLAGS_FORCE_NOT_MNGD vwWTFLAGS_STICKY 110 | #define vwWINFLAGS_STICKY vwWTFLAGS_STICKY 111 | #define vwWINFLAGS_MOVE vwWTFLAGS_MOVE 112 | #define vwWINFLAGS_MOVE_IMMEDIATE vwWTFLAGS_MOVE_IMMEDIATE 113 | #define vwWINFLAGS_MAIN_WIN vwWTFLAGS_MAIN_WIN 114 | #define vwWINFLAGS_GROUP_APP vwWTFLAGS_GROUP_APP 115 | #define vwWINFLAGS_HWACT_MASK vwWTFLAGS_HWACT_MASK 116 | #define vwWINFLAGS_HWACT_BITROT vwWTFLAGS_HWACT_BITROT 117 | #define vwWINFLAGS_ELEVATED 0x00100000 118 | #define vwWINFLAGS_ELEVATED_TEST 0x00200000 119 | #define vwWINFLAGS_HIDEWIN_MASK vwWTFLAGS_HIDEWIN_MASK 120 | #define vwWINFLAGS_HIDEWIN_HIDE vwWTFLAGS_HIDEWIN_HIDE 121 | #define vwWINFLAGS_HIDEWIN_MOVE vwWTFLAGS_HIDEWIN_MOVE 122 | #define vwWINFLAGS_HIDEWIN_MINIM vwWTFLAGS_HIDEWIN_MINIM 123 | #define vwWINFLAGS_HIDETSK_MASK vwWTFLAGS_HIDETSK_MASK 124 | #define vwWINFLAGS_HIDETSK_HIDE vwWTFLAGS_HIDETSK_HIDE 125 | #define vwWINFLAGS_HIDETSK_DONT vwWTFLAGS_HIDETSK_DONT 126 | #define vwWINFLAGS_HIDETSK_TOOLWN vwWTFLAGS_HIDETSK_TOOLWN 127 | 128 | /* vwWindowBase - Holds data far a non-managed window */ 129 | typedef struct vwWindowBase { 130 | struct vwWindowBase *next ; 131 | struct vwWindowBase *hash ; 132 | HWND handle ; 133 | vwUInt flags ; 134 | } vwWindowBase; 135 | 136 | /* vwWindow - Holds data far a managed window, start must be the same as vwWindowBase */ 137 | typedef struct vwWindow { 138 | /* same as vwWindowBase - start */ 139 | struct vwWindow *next ; 140 | struct vwWindow *hash ; 141 | HWND handle ; 142 | vwUInt flags ; 143 | /* same as vwWindowBase - end */ 144 | long exStyle; 145 | DWORD processId ; 146 | struct vwWindow *processNext ; 147 | struct vwWindow *linkedNext ; 148 | vwUInt zOrder[vwDESKTOP_SIZE] ; 149 | vwUByte menuId ; 150 | vwUByte desk; 151 | } vwWindow ; 152 | 153 | /* Holds data for modules */ 154 | typedef struct { 155 | HWND handle; 156 | TCHAR description[vwMODULENAME_MAX+1]; 157 | vwUByte disabled; 158 | } vwModule ; 159 | 160 | /* Holds disabled modules */ 161 | typedef struct { 162 | TCHAR moduleName[vwMODULENAME_MAX+1]; 163 | } vwDisModule ; 164 | 165 | /* vwListItem - Structure used by the window list menu */ 166 | typedef struct { 167 | TCHAR *name; 168 | HICON icon; 169 | vwUInt zOrder ; 170 | vwUShort id; 171 | vwUByte desk; 172 | vwUByte sticky; 173 | } vwListItem ; 174 | 175 | /* vwHotkey - Structure to store a hotkey binding */ 176 | #define vwHOTKEY_ALT MOD_ALT 177 | #define vwHOTKEY_CONTROL MOD_CONTROL 178 | #define vwHOTKEY_SHIFT MOD_SHIFT 179 | #define vwHOTKEY_WIN MOD_WIN 180 | #define vwHOTKEY_MOD_MASK (MOD_ALT|MOD_CONTROL|MOD_SHIFT|MOD_WIN) 181 | #define vwHOTKEY_EXT 0x10 182 | #define vwHOTKEY_WIN_MOUSE 0x20 183 | 184 | typedef struct { 185 | ATOM atom ; 186 | vwUByte key ; 187 | vwUByte modifier ; 188 | vwUByte command ; 189 | vwUByte desk ; 190 | } vwHotkey ; 191 | 192 | #define vwMENU_LABEL_MAX 40 193 | 194 | typedef struct vwMenuItem { 195 | struct vwMenuItem *next ; 196 | HWND module ; 197 | HMENU submenu ; 198 | vwUShort position ; 199 | vwUShort message ; 200 | vwUShort id ; 201 | TCHAR label[vwMENU_LABEL_MAX] ; 202 | } vwMenuItem ; 203 | 204 | typedef struct { 205 | vwUShort position ; 206 | vwUShort message ; 207 | char label[vwMENU_LABEL_MAX] ; 208 | } vwMenuItemMsg ; 209 | 210 | 211 | #endif 212 | -------------------------------------------------------------------------------- /Source/Messages.h: -------------------------------------------------------------------------------- 1 | #ifndef _MESSAGES_H_ 2 | #define _MESSAGES_H_ 3 | /************************************************************************* 4 | * 5 | * VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 6 | * ConfigParameters.h - Dfinition of all module messages 7 | * 8 | * Copyright (c) 1999-2005 Johan Piculell 9 | * Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 24 | * USA. 25 | * 26 | ************************************************************************* 27 | * This is a definition of all possible messages to send to VirtuaWin 28 | * and the messages that VirtuaWin uses for module communication 29 | * 30 | * All messages starting with VW_ is for controlling VirtuaWin 31 | * and messages starting with MOD_ is messages sent by VirtuaWin 32 | * 33 | * For example if you want to step one desktop to the left: 34 | * PostMessage(VirtuaWin HWND, VW_CHANGEDESK, VW_STEPLEFT, 0); 35 | * For messages where you expect a return value, use the SendMessage 36 | * function instead, see some win32 documentation for more info. 37 | * 38 | * Note: the message numbers is not all in sequence! 39 | * 40 | *************************************************************************/ 41 | 42 | /* Message, switch to a specified desktop, sent with following wParam or 1..vwDESKTOP_MAX */ 43 | #define VW_CHANGEDESK (WM_USER + 10) 44 | #define VW_STEPPREV (WM_USER + 1) 45 | #define VW_STEPNEXT (WM_USER + 2) 46 | #define VW_STEPLEFT (WM_USER + 11) 47 | #define VW_STEPRIGHT (WM_USER + 12) 48 | #define VW_STEPUP (WM_USER + 13) 49 | #define VW_STEPDOWN (WM_USER + 14) 50 | /* Message, close VirtuaWin */ 51 | #define VW_CLOSE (WM_USER + 15) 52 | /* Message, display setup dialog */ 53 | #define VW_SETUP (WM_USER + 16) 54 | /* Message, remove the systray icon */ 55 | #define VW_DELICON (WM_USER + 17) 56 | /* Message, displays the systray icon */ 57 | #define VW_SHOWICON (WM_USER + 18) 58 | /* Message, bring up the help */ 59 | #define VW_HELP (WM_USER + 19) 60 | /* Message, gather all windows */ 61 | #define VW_GATHER (WM_USER + 20) 62 | /* Message, retuns desktop width */ 63 | #define VW_DESKX (WM_USER + 21) 64 | /* Message, retuns desktop height */ 65 | #define VW_DESKY (WM_USER + 22) 66 | /* Message, request the window list from VirtuaWin - RETIRED. 67 | * This message was too dependent on the Window data structure, creating modules which 68 | * are very version dependent. As to v4.0 support for this message has been removed, 69 | * Module writers are encouraged to use the VW_WINGETINFO message instead see SF bug 70 | * 1915723 for more information */ 71 | #define VW_WINLIST (WM_USER + 23) 72 | /* Message, returns the current desktop number */ 73 | #define VW_CURDESK (WM_USER + 24) 74 | /* Message, assign a window to the specified desktop wParam is the window 75 | * handle (HWND, 0 for foreground window) and lParam is either VW_STEP* (see 76 | * 6 defines above) or the desktop number. If desk is -ve window is assigned 77 | * to desk (-lParam) and VW changes to the desk. Returns 0 if window was not 78 | * found (i.e. not managed by VW), non-zero otherwise */ 79 | #define VW_ASSIGNWIN (WM_USER + 25) 80 | /* Message, set the sticky state of a window. wParam is the window handle 81 | * (HWND, 0 for foreground window) and lParam should be -1 for toggle, 0 for 82 | * unset and 1 for set sticky state. */ 83 | #define VW_SETSTICKY (WM_USER + 26) 84 | /* Message, make a window the foreground, wParam is the window handle, if 0 then VirtuaWin chooses 85 | * the best window on the current desktop to make the foreground window. If wParam is not 0 it must 86 | * be a HWND of the window to give focus, in this case the lParam is used to define the desktop, 0 87 | * for the current desktop, if not the current desktop then only the windows desktop Z-order for that 88 | * desktop is changed (i.e. it will be main the foreground window when the user goes to that desktop) */ 89 | #define VW_FOREGDWIN (WM_USER + 27) 90 | /* Message, return VirtuaWin's installation path. The path will be returned via a WM_COPYDATA 91 | * message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 92 | #define VW_INSTALLPATH (WM_USER + 28) 93 | /* Message, return VirtuaWin's user application data path. The path will be returned via a 94 | * WM_COPYDATA message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 95 | #define VW_USERAPPPATH (WM_USER + 29) 96 | /* Message, access a window, wParam is the window handle (HWND) and lParam is the method: 97 | 0 - Use user's 'On hidden window activation' preference (ignore -> move) 98 | 1 - Move window to this desk 99 | 2 - Show window to this disk 100 | 3 - Change to window's desk 101 | -1 - Use window's 'On hidden window activation' setting (if set to ignore nothing will happen) 102 | Returns 0 if window was not found (i.e. not managed by VW), non-zero otherwise */ 103 | #define VW_ACCESSWIN (WM_USER + 39) 104 | /* Message, return the information VW has on the window given via wParam. 0 is returned if the 105 | * window is not found, otherwise use the 2 macros to extract the window flags (see vwWINFLAGS_* 106 | * defines in Defines.h, the hide method flags are not given) and the windows desk. To check 107 | * if a window is hung do: 108 | * if(((vwGetWindowInfoFlags(ii) & vwWINFLAGS_SHOWN) == 0) ^ ((vwGetWindowInfoFlags(ii) & vwWINFLAGS_SHOW) == 0)) 109 | */ 110 | #define VW_WINGETINFO (WM_USER + 40) 111 | #define vwWindowGetInfoFlags(ii) ((ii) & 0x00ffffff) 112 | #define vwWindowGetInfoDesk(ii) (((ii) >> 24) & 0x00ff) 113 | /* Message, Desk image generation message, the action of the message depends on the 114 | * value of wParam: 115 | * 0 - Returns the current status of image generation 116 | * 1 - Enables image generation, lParam specifies the required image height 117 | * (aspect ratio is maintained). Returns 1 if generation is enabled. 118 | * 2 - Disables image generation. Note: as multiple modules may enable image 119 | * generation an 'enable' counter is kept, each 'enable' message increments 120 | * and each disable decrements this counter. Image generation only stops 121 | * when the counter returns to zero. Returns 1 if counter was decremented, 122 | * 0 if counter is already 0. 123 | * 3 - Updates the current desk's image if image generation is enabled, returns 124 | * 1 if successfully updated, 0 otherwise. 125 | * 4 - Returns the desk image height if enabled, 0 otherwise 126 | * 5 - Returns the desk image width if enabled, 0 otherwise 127 | * 6 - Returns the width, in pixels, of the desktop. 128 | * 7 - Returns the depth, in pixels, of the desktop. 129 | * 8 - Temporarily disables (if lParam is 0) or enables (if lParam is not 0) the 130 | * generation of desktop images (this only takes effect if generation has been 131 | * enabled via a wParam=1 message) */ 132 | #define VW_DESKIMAGE (WM_USER + 41) 133 | /* Message, set the main VirtuaWin enable/disable state. If wParam is 0 134 | the current state is not changed, 1 for toggle, 2 for disable 135 | and 3 for enable. Returns the previous state, 1 for enable & 0 for disabled. */ 136 | #define VW_ENABLE_STATE (WM_USER + 42) 137 | /* Message, return the name of the desk specified by the lParam, if lParam is set 138 | * to 0 the current desktop name is returned. The name will be returned via a WM_COPYDATA 139 | * message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 140 | #define VW_DESKNAME (WM_USER + 43) 141 | /* Message, returns the value of vwDESKTOP_SIZE in Defines.h, this can be used to 142 | * quickly obtain the maximum size of any desk based array, i.e. guaranteed to be greater 143 | * than the current desktop. Note the this is not true of (DESKX * DESKY) due to hidden desktops. */ 144 | #define VW_DESKTOP_SIZE (WM_USER + 44) 145 | /* Message, set whether a window is managed by VW. wParam is the window handle 146 | * (HWND, 0 for foreground window) and lParam should be 0 for not managed and 1 for managed. */ 147 | #define VW_WINMANAGE (WM_USER + 45) 148 | /* Message, executes a hotkey command as if the user pressed the hotkey, where wParam is the 149 | * command id (see second column in vwCommands.def), LOWORD(lParam) is the desk (if required) and 150 | * HIWORD(lParam) is the modifier, only bit vwHOTKEY_WIN_MOUSE is used (and only set if really 151 | * needed as the command will fail if there is no window under the mouse). The return is dependent 152 | * on the command being executed. */ 153 | #define VW_HOTKEY (WM_USER + 46) 154 | /* Message & WM_COPYDATA ID, inserts or removes items from the control menu. See Feature request 155 | * 2980468 (https://sourceforge.net/tracker/?func=detail&aid=2980468&group_id=39588&atid=526970) 156 | * for more info and example code */ 157 | #define VW_CMENUITEM (WM_USER + 47) 158 | /* Message, used to get or set the current desktop change module handler and to manage a desktop 159 | * change. VirtuaWin supports one module controlling the desktop change process, if a module has 160 | * set itself as the ICHANGE handler then on every desktop change VirtuaWin will send the module 161 | * a VW_ICHANGEDESK message (wParam=oldDesk, lParam=newDesk) the module can then initiate 162 | * transition effects but it must also post a VW_ICHANGEDESK (wParam=3) message back to VirtuaWin 163 | * so it knows when to actually change desktops; VirtuaWin gives the Module upto half a second to 164 | * send this message otherwise it will change desks anyway. Values of wParam are as follows: 165 | * 0 to get current handler 166 | * 1 to set current handler 167 | * 2 to remove self as handler 168 | * 3 execute the desktop change */ 169 | #define VW_ICHANGEDESK (WM_USER + 48) 170 | /* Message, command to make VirtuaWin reapply window rules, always returns TRUE */ 171 | #define VW_APPLYRULES (WM_USER + 49) 172 | /* Message, returns the Expert setting of Invert Up/Down, 1 = enabled, 0 otherwise */ 173 | #define VW_INVERTY (WM_USER + 50) 174 | 175 | 176 | /* Message, sent by VirtuaWin after a switch. lParam will contain current desktop number 177 | if wParam isn't one of the following, then wParam will also contain current desktop. 178 | If desktop cycling is enabled, there will be two MOD_CHANGEDESK sent when going 179 | "over the edge". The first one will have a MOD_STEP* parameter, and the second 180 | will have current desktop in both parameters. 181 | */ 182 | #define MOD_CHANGEDESK (WM_USER + 30) 183 | #define MOD_STEPLEFT (WM_USER + 31) 184 | #define MOD_STEPRIGHT (WM_USER + 32) 185 | #define MOD_STEPUP (WM_USER + 33) 186 | #define MOD_STEPDOWN (WM_USER + 34) 187 | 188 | /* Message, sent just after the module is started. wParam will contain VirtuaWin hWnd */ 189 | #define MOD_INIT (WM_USER + 35) 190 | /* Message, sent when VirtuaWin quits or reloads its modules */ 191 | #define MOD_QUIT (WM_USER + 36) 192 | /* Message, sent by VirtuaWin when setup button is pressed in "module tab", 193 | * wParam set to the HWND of the 'parent' window or 0 */ 194 | #define MOD_SETUP (WM_USER + 37) 195 | /* Message, sent by VirtuaWin when the configuration has been updated */ 196 | #define MOD_CFGCHANGE (WM_USER + 38) 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /Source/Module/Messages.h: -------------------------------------------------------------------------------- 1 | #ifndef _MESSAGES_H_ 2 | #define _MESSAGES_H_ 3 | /************************************************************************* 4 | * 5 | * VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 6 | * ConfigParameters.h - Dfinition of all module messages 7 | * 8 | * Copyright (c) 1999-2005 Johan Piculell 9 | * Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 24 | * USA. 25 | * 26 | ************************************************************************* 27 | * This is a definition of all possible messages to send to VirtuaWin 28 | * and the messages that VirtuaWin uses for module communication 29 | * 30 | * All messages starting with VW_ is for controlling VirtuaWin 31 | * and messages starting with MOD_ is messages sent by VirtuaWin 32 | * 33 | * For example if you want to step one desktop to the left: 34 | * PostMessage(VirtuaWin HWND, VW_CHANGEDESK, VW_STEPLEFT, 0); 35 | * For messages where you expect a return value, use the SendMessage 36 | * function instead, see some win32 documentation for more info. 37 | * 38 | * Note: the message numbers is not all in sequence! 39 | * 40 | *************************************************************************/ 41 | 42 | /* Message, switch to a specified desktop, sent with following wParam or 1..vwDESKTOP_MAX */ 43 | #define VW_CHANGEDESK (WM_USER + 10) 44 | #define VW_STEPPREV (WM_USER + 1) 45 | #define VW_STEPNEXT (WM_USER + 2) 46 | #define VW_STEPLEFT (WM_USER + 11) 47 | #define VW_STEPRIGHT (WM_USER + 12) 48 | #define VW_STEPUP (WM_USER + 13) 49 | #define VW_STEPDOWN (WM_USER + 14) 50 | /* Message, close VirtuaWin */ 51 | #define VW_CLOSE (WM_USER + 15) 52 | /* Message, display setup dialog */ 53 | #define VW_SETUP (WM_USER + 16) 54 | /* Message, remove the systray icon */ 55 | #define VW_DELICON (WM_USER + 17) 56 | /* Message, displays the systray icon */ 57 | #define VW_SHOWICON (WM_USER + 18) 58 | /* Message, bring up the help */ 59 | #define VW_HELP (WM_USER + 19) 60 | /* Message, gather all windows */ 61 | #define VW_GATHER (WM_USER + 20) 62 | /* Message, retuns desktop width */ 63 | #define VW_DESKX (WM_USER + 21) 64 | /* Message, retuns desktop height */ 65 | #define VW_DESKY (WM_USER + 22) 66 | /* Message, request the window list from VirtuaWin - RETIRED. 67 | * This message was too dependent on the Window data structure, creating modules which 68 | * are very version dependent. As to v4.0 support for this message has been removed, 69 | * Module writers are encouraged to use the VW_WINGETINFO message instead see SF bug 70 | * 1915723 for more information */ 71 | #define VW_WINLIST (WM_USER + 23) 72 | /* Message, returns the current desktop number */ 73 | #define VW_CURDESK (WM_USER + 24) 74 | /* Message, assign a window to the specified desktop wParam is the window 75 | * handle (HWND, 0 for foreground window) and lParam is either VW_STEP* (see 76 | * 6 defines above) or the desktop number. If desk is -ve window is assigned 77 | * to desk (-lParam) and VW changes to the desk. Returns 0 if window was not 78 | * found (i.e. not managed by VW), non-zero otherwise */ 79 | #define VW_ASSIGNWIN (WM_USER + 25) 80 | /* Message, set the sticky state of a window. wParam is the window handle 81 | * (HWND, 0 for foreground window) and lParam should be -1 for toggle, 0 for 82 | * unset and 1 for set sticky state. */ 83 | #define VW_SETSTICKY (WM_USER + 26) 84 | /* Message, make a window the foreground, wParam is the window handle, if 0 then VirtuaWin chooses 85 | * the best window on the current desktop to make the foreground window. If wParam is not 0 it must 86 | * be a HWND of the window to give focus, in this case the lParam is used to define the desktop, 0 87 | * for the current desktop, if not the current desktop then only the windows desktop Z-order for that 88 | * desktop is changed (i.e. it will be main the foreground window when the user goes to that desktop) */ 89 | #define VW_FOREGDWIN (WM_USER + 27) 90 | /* Message, return VirtuaWin's installation path. The path will be returned via a WM_COPYDATA 91 | * message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 92 | #define VW_INSTALLPATH (WM_USER + 28) 93 | /* Message, return VirtuaWin's user application data path. The path will be returned via a 94 | * WM_COPYDATA message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 95 | #define VW_USERAPPPATH (WM_USER + 29) 96 | /* Message, access a window, wParam is the window handle (HWND) and lParam is the method: 97 | 0 - Use user's 'On hidden window activation' preference (ignore -> move) 98 | 1 - Move window to this desk 99 | 2 - Show window to this disk 100 | 3 - Change to window's desk 101 | -1 - Use window's 'On hidden window activation' setting (if set to ignore nothing will happen) 102 | Returns 0 if window was not found (i.e. not managed by VW), non-zero otherwise */ 103 | #define VW_ACCESSWIN (WM_USER + 39) 104 | /* Message, return the information VW has on the window given via wParam. 0 is returned if the 105 | * window is not found, otherwise use the 2 macros to extract the window flags (see vwWINFLAGS_* 106 | * defines in Defines.h, the hide method flags are not given) and the windows desk. To check 107 | * if a window is hung do: 108 | * if(((vwGetWindowInfoFlags(ii) & vwWINFLAGS_SHOWN) == 0) ^ ((vwGetWindowInfoFlags(ii) & vwWINFLAGS_SHOW) == 0)) 109 | */ 110 | #define VW_WINGETINFO (WM_USER + 40) 111 | #define vwWindowGetInfoFlags(ii) ((ii) & 0x00ffffff) 112 | #define vwWindowGetInfoDesk(ii) (((ii) >> 24) & 0x00ff) 113 | /* Message, Desk image generation message, the action of the message depends on the 114 | * value of wParam: 115 | * 0 - Returns the current status of image generation 116 | * 1 - Enables image generation, lParam specifies the required image height 117 | * (aspect ratio is maintained). Returns 1 if generation is enabled. 118 | * 2 - Disables image generation. Note: as multiple modules may enable image 119 | * generation an 'enable' counter is kept, each 'enable' message increments 120 | * and each disable decrements this counter. Image generation only stops 121 | * when the counter returns to zero. Returns 1 if counter was decremented, 122 | * 0 if counter is already 0. 123 | * 3 - Updates the current desk's image if image generation is enabled, returns 124 | * 1 if successfully updated, 0 otherwise. 125 | * 4 - Returns the desk image height if enabled, 0 otherwise 126 | * 5 - Returns the desk image width if enabled, 0 otherwise 127 | * 6 - Returns the width, in pixels, of the desktop. 128 | * 7 - Returns the depth, in pixels, of the desktop. 129 | * 8 - Temporarily disables (if lParam is 0) or enables (if lParam is not 0) the 130 | * generation of desktop images (this only takes effect if generation has been 131 | * enabled via a wParam=1 message) */ 132 | #define VW_DESKIMAGE (WM_USER + 41) 133 | /* Message, set the main VirtuaWin enable/disable state. If wParam is 0 134 | the current state is not changed, 1 for toggle, 2 for disable 135 | and 3 for enable. Returns the previous state, 1 for enable & 0 for disabled. */ 136 | #define VW_ENABLE_STATE (WM_USER + 42) 137 | /* Message, return the name of the desk specified by the lParam, if lParam is set 138 | * to 0 the current desktop name is returned. The name will be returned via a WM_COPYDATA 139 | * message, set wParam to the HWND which is to receive the WM_COPYDATA message */ 140 | #define VW_DESKNAME (WM_USER + 43) 141 | /* Message, returns the value of vwDESKTOP_SIZE in Defines.h, this can be used to 142 | * quickly obtain the maximum size of any desk based array, i.e. guaranteed to be greater 143 | * than the current desktop. Note the this is not true of (DESKX * DESKY) due to hidden desktops. */ 144 | #define VW_DESKTOP_SIZE (WM_USER + 44) 145 | /* Message, set whether a window is managed by VW. wParam is the window handle 146 | * (HWND, 0 for foreground window) and lParam should be 0 for not managed and 1 for managed. */ 147 | #define VW_WINMANAGE (WM_USER + 45) 148 | /* Message, executes a hotkey command as if the user pressed the hotkey, where wParam is the 149 | * command id (see second column in vwCommands.def), LOWORD(lParam) is the desk (if required) and 150 | * HIWORD(lParam) is the modifier, only bit vwHOTKEY_WIN_MOUSE is used (and only set if really 151 | * needed as the command will fail if there is no window under the mouse). The return is dependent 152 | * on the command being executed. */ 153 | #define VW_HOTKEY (WM_USER + 46) 154 | /* Message & WM_COPYDATA ID, inserts or removes items from the control menu. See Feature request 155 | * 2980468 (https://sourceforge.net/tracker/?func=detail&aid=2980468&group_id=39588&atid=526970) 156 | * for more info and example code */ 157 | #define VW_CMENUITEM (WM_USER + 47) 158 | /* Message, used to get or set the current desktop change module handler and to manage a desktop 159 | * change. VirtuaWin supports one module controlling the desktop change process, if a module has 160 | * set itself as the ICHANGE handler then on every desktop change VirtuaWin will send the module 161 | * a VW_ICHANGEDESK message (wParam=oldDesk, lParam=newDesk) the module can then initiate 162 | * transition effects but it must also post a VW_ICHANGEDESK (wParam=3) message back to VirtuaWin 163 | * so it knows when to actually change desktops; VirtuaWin gives the Module upto half a second to 164 | * send this message otherwise it will change desks anyway. Values of wParam are as follows: 165 | * 0 to get current handler 166 | * 1 to set current handler 167 | * 2 to remove self as handler 168 | * 3 execute the desktop change */ 169 | #define VW_ICHANGEDESK (WM_USER + 48) 170 | /* Message, command to make VirtuaWin reapply window rules, always returns TRUE */ 171 | #define VW_APPLYRULES (WM_USER + 49) 172 | /* Message, returns the Expert setting of Invert Up/Down, 1 = enabled, 0 otherwise */ 173 | #define VW_INVERTY (WM_USER + 50) 174 | 175 | 176 | /* Message, sent by VirtuaWin after a switch. lParam will contain current desktop number 177 | if wParam isn't one of the following, then wParam will also contain current desktop. 178 | If desktop cycling is enabled, there will be two MOD_CHANGEDESK sent when going 179 | "over the edge". The first one will have a MOD_STEP* parameter, and the second 180 | will have current desktop in both parameters. 181 | */ 182 | #define MOD_CHANGEDESK (WM_USER + 30) 183 | #define MOD_STEPLEFT (WM_USER + 31) 184 | #define MOD_STEPRIGHT (WM_USER + 32) 185 | #define MOD_STEPUP (WM_USER + 33) 186 | #define MOD_STEPDOWN (WM_USER + 34) 187 | 188 | /* Message, sent just after the module is started. wParam will contain VirtuaWin hWnd */ 189 | #define MOD_INIT (WM_USER + 35) 190 | /* Message, sent when VirtuaWin quits or reloads its modules */ 191 | #define MOD_QUIT (WM_USER + 36) 192 | /* Message, sent by VirtuaWin when setup button is pressed in "module tab", 193 | * wParam set to the HWND of the 'parent' window or 0 */ 194 | #define MOD_SETUP (WM_USER + 37) 195 | /* Message, sent by VirtuaWin when the configuration has been updated */ 196 | #define MOD_CFGCHANGE (WM_USER + 38) 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /COPYING.TXT: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Library General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | 125 | Thus, it is not the intent of this section to claim rights or contest 126 | your rights to work written entirely by you; rather, the intent is to 127 | exercise the right to control the distribution of derivative or 128 | collective works based on the Program. 129 | 130 | In addition, mere aggregation of another work not based on the Program 131 | with the Program (or with a work based on the Program) on a volume of 132 | a storage or distribution medium does not bring the other work under 133 | the scope of this License. 134 | 135 | 3. You may copy and distribute the Program (or a work based on it, 136 | under Section 2) in object code or executable form under the terms of 137 | Sections 1 and 2 above provided that you also do one of the following: 138 | 139 | a) Accompany it with the complete corresponding machine-readable 140 | source code, which must be distributed under the terms of Sections 141 | 1 and 2 above on a medium customarily used for software interchange; or, 142 | 143 | b) Accompany it with a written offer, valid for at least three 144 | years, to give any third party, for a charge no more than your 145 | cost of physically performing source distribution, a complete 146 | machine-readable copy of the corresponding source code, to be 147 | distributed under the terms of Sections 1 and 2 above on a medium 148 | customarily used for software interchange; or, 149 | 150 | c) Accompany it with the information you received as to the offer 151 | to distribute corresponding source code. (This alternative is 152 | allowed only for noncommercial distribution and only if you 153 | received the program in object code or executable form with such 154 | an offer, in accord with Subsection b above.) 155 | 156 | The source code for a work means the preferred form of the work for 157 | making modifications to it. For an executable work, complete source 158 | code means all the source code for all modules it contains, plus any 159 | associated interface definition files, plus the scripts used to 160 | control compilation and installation of the executable. However, as a 161 | special exception, the source code distributed need not include 162 | anything that is normally distributed (in either source or binary 163 | form) with the major components (compiler, kernel, and so on) of the 164 | operating system on which the executable runs, unless that component 165 | itself accompanies the executable. 166 | 167 | If distribution of executable or object code is made by offering 168 | access to copy from a designated place, then offering equivalent 169 | access to copy the source code from the same place counts as 170 | distribution of the source code, even though third parties are not 171 | compelled to copy the source along with the object code. 172 | 173 | 4. You may not copy, modify, sublicense, or distribute the Program 174 | except as expressly provided under this License. Any attempt 175 | otherwise to copy, modify, sublicense or distribute the Program is 176 | void, and will automatically terminate your rights under this License. 177 | However, parties who have received copies, or rights, from you under 178 | this License will not have their licenses terminated so long as such 179 | parties remain in full compliance. 180 | 181 | 5. You are not required to accept this License, since you have not 182 | signed it. However, nothing else grants you permission to modify or 183 | distribute the Program or its derivative works. These actions are 184 | prohibited by law if you do not accept this License. Therefore, by 185 | modifying or distributing the Program (or any work based on the 186 | Program), you indicate your acceptance of this License to do so, and 187 | all its terms and conditions for copying, distributing or modifying 188 | the Program or works based on it. 189 | 190 | 6. Each time you redistribute the Program (or any work based on the 191 | Program), the recipient automatically receives a license from the 192 | original licensor to copy, distribute or modify the Program subject to 193 | these terms and conditions. You may not impose any further 194 | restrictions on the recipients' exercise of the rights granted herein. 195 | You are not responsible for enforcing compliance by third parties to 196 | this License. 197 | 198 | 7. If, as a consequence of a court judgment or allegation of patent 199 | infringement or for any other reason (not limited to patent issues), 200 | conditions are imposed on you (whether by court order, agreement or 201 | otherwise) that contradict the conditions of this License, they do not 202 | excuse you from the conditions of this License. If you cannot 203 | distribute so as to satisfy simultaneously your obligations under this 204 | License and any other pertinent obligations, then as a consequence you 205 | may not distribute the Program at all. For example, if a patent 206 | license would not permit royalty-free redistribution of the Program by 207 | all those who receive copies directly or indirectly through you, then 208 | the only way you could satisfy both it and this License would be to 209 | refrain entirely from distribution of the Program. 210 | 211 | If any portion of this section is held invalid or unenforceable under 212 | any particular circumstance, the balance of the section is intended to 213 | apply and the section as a whole is intended to apply in other 214 | circumstances. 215 | 216 | It is not the purpose of this section to induce you to infringe any 217 | patents or other property right claims or to contest validity of any 218 | such claims; this section has the sole purpose of protecting the 219 | integrity of the free software distribution system, which is 220 | implemented by public license practices. Many people have made 221 | generous contributions to the wide range of software distributed 222 | through that system in reliance on consistent application of that 223 | system; it is up to the author/donor to decide if he or she is willing 224 | to distribute software through any other system and a licensee cannot 225 | impose that choice. 226 | 227 | This section is intended to make thoroughly clear what is believed to 228 | be a consequence of the rest of this License. 229 | 230 | 8. If the distribution and/or use of the Program is restricted in 231 | certain countries either by patents or by copyrighted interfaces, the 232 | original copyright holder who places the Program under this License 233 | may add an explicit geographical distribution limitation excluding 234 | those countries, so that distribution is permitted only in or among 235 | countries not thus excluded. In such case, this License incorporates 236 | the limitation as if written in the body of this License. 237 | 238 | 9. The Free Software Foundation may publish revised and/or new versions 239 | of the General Public License from time to time. Such new versions will 240 | be similar in spirit to the present version, but may differ in detail to 241 | address new problems or concerns. 242 | 243 | Each version is given a distinguishing version number. If the Program 244 | specifies a version number of this License which applies to it and "any 245 | later version", you have the option of following the terms and conditions 246 | either of that version or of any later version published by the Free 247 | Software Foundation. If the Program does not specify a version number of 248 | this License, you may choose any version ever published by the Free Software 249 | Foundation. 250 | 251 | 10. If you wish to incorporate parts of the Program into other free 252 | programs whose distribution conditions are different, write to the author 253 | to ask for permission. For software which is copyrighted by the Free 254 | Software Foundation, write to the Free Software Foundation; we sometimes 255 | make exceptions for this. Our decision will be guided by the two goals 256 | of preserving the free status of all derivatives of our free software and 257 | of promoting the sharing and reuse of software generally. 258 | 259 | NO WARRANTY 260 | 261 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 262 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 263 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 264 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 265 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 266 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 267 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 268 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 269 | REPAIR OR CORRECTION. 270 | 271 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 272 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 273 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 274 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 275 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 276 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 277 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 278 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 279 | POSSIBILITY OF SUCH DAMAGES. 280 | 281 | END OF TERMS AND CONDITIONS 282 | 283 | Appendix: How to Apply These Terms to Your New Programs 284 | 285 | If you develop a new program, and you want it to be of the greatest 286 | possible use to the public, the best way to achieve this is to make it 287 | free software which everyone can redistribute and change under these terms. 288 | 289 | To do so, attach the following notices to the program. It is safest 290 | to attach them to the start of each source file to most effectively 291 | convey the exclusion of warranty; and each file should have at least 292 | the "copyright" line and a pointer to where the full notice is found. 293 | 294 | 295 | Copyright (C) 19yy 296 | 297 | This program is free software; you can redistribute it and/or modify 298 | it under the terms of the GNU General Public License as published by 299 | the Free Software Foundation; either version 2 of the License, or 300 | (at your option) any later version. 301 | 302 | This program is distributed in the hope that it will be useful, 303 | but WITHOUT ANY WARRANTY; without even the implied warranty of 304 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 305 | GNU General Public License for more details. 306 | 307 | You should have received a copy of the GNU General Public License 308 | along with this program; if not, write to the Free Software 309 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) 19yy name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | 342 | -------------------------------------------------------------------------------- /Source/WinList/winlist.c: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // winlist.c - VirtuaWin module for restoring lost windows. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | #define _CRT_SECURE_NO_WARNINGS 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "winlistres.h" 32 | #include "../Defines.h" 33 | #include "../Messages.h" 34 | 35 | #ifndef INVALID_FILE_ATTRIBUTES 36 | #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 37 | #endif 38 | 39 | HINSTANCE hInst ; // Instance handle 40 | HWND hwndMain ; // Main window handle 41 | HWND vwHandle ; // Handle to VirtuaWin 42 | HWND listHWnd ; // Handle to the window list 43 | HWND hwndTask ; 44 | UINT RM_Shellhook ; 45 | TCHAR userAppPath[MAX_PATH] ; 46 | int deskCount ; 47 | int deskCrrnt ; 48 | 49 | typedef struct vwlWindow { 50 | struct vwlWindow *next ; 51 | HWND handle ; 52 | TCHAR className[vwCLASSNAME_MAX] ; 53 | TCHAR windowName[vwWINDOWNAME_MAX] ; 54 | RECT rect ; 55 | int style ; 56 | int exstyle ; 57 | short flag ; 58 | unsigned char state ; 59 | unsigned char restored ; 60 | } vwlWindow ; 61 | 62 | vwlWindow *windowList ; 63 | int runMode=0 ; 64 | int winInitialised=0 ; 65 | int screenLeft ; 66 | int screenRight ; 67 | int screenTop ; 68 | int screenBottom ; 69 | int sortCol ; 70 | int sortDir ; 71 | 72 | static void 73 | FreeWindowList(void) 74 | { 75 | vwlWindow *ww ; 76 | while((ww = windowList) != NULL) 77 | { 78 | windowList = ww->next ; 79 | free(ww) ; 80 | } 81 | } 82 | 83 | 84 | static int CALLBACK 85 | ListCompFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) 86 | { 87 | vwlWindow *w1, *w2 ; 88 | int ret ; 89 | 90 | w1 = (vwlWindow *) lParam1 ; 91 | w2 = (vwlWindow *) lParam2 ; 92 | if(sortCol == 0) 93 | ret = (((int) w2->flag) - ((int) w1->flag)) ; 94 | else if(sortCol == 1) 95 | ret = (((int) w1->state) - ((int) w2->state)) ; 96 | else if(sortCol == 2) 97 | ret = _tcsicmp(w2->className,w1->className) ; 98 | else 99 | ret = 0 ; 100 | if(ret == 0) 101 | ret = _tcsicmp(w2->windowName,w1->windowName) ; 102 | if(ret == 0) 103 | ret = (((int) w2->handle) - ((int) w1->handle)) ; 104 | 105 | return ((sortDir) ? ret:0-ret) ; 106 | } 107 | 108 | __inline BOOL CALLBACK 109 | enumWindowsProc(HWND hwnd, LPARAM lParam) 110 | { 111 | vwlWindow *win ; 112 | TCHAR fbuff[4], sbuff[4]; 113 | int idx, flag, state, exstyle, style = GetWindowLong(hwnd, GWL_STYLE); 114 | LVITEM item ; 115 | RECT rect ; 116 | 117 | if(style & WS_CHILD) 118 | return TRUE ; 119 | 120 | GetWindowRect(hwnd,&rect); 121 | exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); 122 | 123 | fbuff[1] = ' ' ; 124 | fbuff[2] = '\0' ; 125 | sbuff[0] = ' ' ; 126 | sbuff[1] = ' ' ; 127 | sbuff[2] = '\0' ; 128 | state = 0 ; 129 | if((vwHandle != 0) && ((flag = SendMessage(vwHandle,VW_WINGETINFO,(WPARAM) hwnd,0)) != 0)) 130 | { 131 | if((flag & vwWINFLAGS_WINDOW) == 0) 132 | return TRUE ; 133 | if((flag & vwWINFLAGS_MANAGED) == 0) 134 | { 135 | // This is a known unmanaged window 136 | fbuff[0] = 'U' ; 137 | flag = 0 ; 138 | } 139 | else 140 | { 141 | if((flag & (vwWINFLAGS_ELEVATED_TEST|vwWINFLAGS_ELEVATED)) == (vwWINFLAGS_ELEVATED_TEST|vwWINFLAGS_ELEVATED)) 142 | { 143 | /* window is known to be elevated */ 144 | state = 2 ; 145 | sbuff[0] = 'E' ; 146 | } 147 | else if(((flag & vwWINFLAGS_SHOWN) != 0) ^ ((flag & vwWINFLAGS_SHOW) == 0)) 148 | { 149 | /* if show & shown or vice versa then the window is okay */ 150 | state = 1 ; 151 | sbuff[0] = 'O' ; 152 | } 153 | else 154 | { 155 | /* window is hung */ 156 | state = 3 ; 157 | sbuff[0] = 'H' ; 158 | } 159 | flag = vwWindowGetInfoDesk(flag) ; 160 | if((flag != deskCrrnt) && (flag > deskCount)) 161 | // on a hidden desktop 162 | return TRUE ; 163 | fbuff[0] = (flag >= 10) ? ('0' + (flag / 10)) : ' ' ; 164 | fbuff[1] = '0' + (flag % 10) ; 165 | } 166 | } 167 | else if(style & WS_VISIBLE) 168 | { 169 | fbuff[0] = 'V' ; 170 | flag = -1 ; 171 | } 172 | else 173 | { 174 | fbuff[0] = 'H' ; 175 | flag = -2 ; 176 | } 177 | if((win = malloc(sizeof(vwlWindow))) == NULL) 178 | return FALSE ; 179 | memset(&item,0,sizeof(LVITEM)) ; 180 | item.iItem = ListView_GetItemCount(listHWnd) ; 181 | item.lParam = (LPARAM) win ; 182 | item.pszText = fbuff ; 183 | item.mask = LVIF_PARAM | LVIF_TEXT ; 184 | if((idx = ListView_InsertItem(listHWnd, &item)) < 0) 185 | { 186 | free(win) ; 187 | return TRUE; 188 | } 189 | win->next = windowList ; 190 | windowList = win ; 191 | GetClassName(hwnd,win->className,vwCLASSNAME_MAX); 192 | if(!GetWindowText(hwnd,win->windowName,vwWINDOWNAME_MAX)) 193 | _tcscpy_s(win->windowName, 128, _T("")) ; 194 | 195 | ListView_SetItemText(listHWnd,idx,1,sbuff) ; 196 | ListView_SetItemText(listHWnd,idx,2,win->className) ; 197 | ListView_SetItemText(listHWnd,idx,3,win->windowName) ; 198 | 199 | win->handle = hwnd; 200 | win->style = style; 201 | win->exstyle = exstyle; 202 | win->state = (unsigned char) state ; 203 | win->flag = (short) flag ; 204 | win->rect = rect ; 205 | win->restored = 0 ; 206 | 207 | return TRUE; 208 | } 209 | 210 | 211 | static int 212 | GenerateWinList(HWND hDlg, int update) 213 | { 214 | /* The virtual screen size system matrix values were only added for WINVER >= 0x0500 (Win2k) */ 215 | #ifndef SM_XVIRTUALSCREEN 216 | #define SM_XVIRTUALSCREEN 76 217 | #define SM_YVIRTUALSCREEN 77 218 | #define SM_CXVIRTUALSCREEN 78 219 | #define SM_CYVIRTUALSCREEN 79 220 | #endif 221 | FreeWindowList() ; 222 | if((screenRight = GetSystemMetrics(SM_CXVIRTUALSCREEN)) <= 0) 223 | { 224 | /* The virtual screen size system matrix values are not supported on 225 | * this OS (Win95 & NT), use the desktop window size */ 226 | RECT r; 227 | GetClientRect(GetDesktopWindow(), &r); 228 | screenLeft = r.left; 229 | screenRight = r.right; 230 | screenTop = r.top; 231 | screenBottom = r.bottom; 232 | } 233 | else 234 | { 235 | screenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN); 236 | screenRight += screenLeft; 237 | screenTop = GetSystemMetrics(SM_YVIRTUALSCREEN); 238 | screenBottom = GetSystemMetrics(SM_CYVIRTUALSCREEN)+screenTop; 239 | } 240 | 241 | listHWnd = GetDlgItem(hDlg,ID_WINLIST) ; 242 | if(update) 243 | ListView_DeleteAllItems(listHWnd) ; 244 | else 245 | { 246 | LVCOLUMN col; 247 | ListView_SetExtendedListViewStyleEx(listHWnd,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT); 248 | 249 | col.mask = LVCF_FMT | LVCF_TEXT; 250 | col.fmt = LVCFMT_LEFT; 251 | col.pszText = _T("F") ; 252 | ListView_InsertColumn(listHWnd,0,&col); 253 | 254 | col.pszText = _T("S") ; 255 | ListView_InsertColumn(listHWnd,1,&col); 256 | 257 | col.pszText = _T("Class") ; 258 | ListView_InsertColumn(listHWnd,2,&col); 259 | 260 | col.pszText = _T("Title") ; 261 | ListView_InsertColumn(listHWnd,3,&col); 262 | } 263 | if(vwHandle != 0) 264 | { 265 | deskCount = SendMessage(vwHandle, VW_DESKX, 0, 0) * SendMessage(vwHandle, VW_DESKY, 0, 0) ; 266 | deskCrrnt = SendMessage(vwHandle, VW_CURDESK, 0, 0) ; 267 | } 268 | 269 | EnumWindows(enumWindowsProc, (LPARAM) hDlg); // get all windows 270 | 271 | ListView_SortItems(listHWnd,ListCompFunc,0) ; 272 | 273 | ListView_SetColumnWidth(listHWnd,0,LVSCW_AUTOSIZE); 274 | ListView_SetColumnWidth(listHWnd,1,LVSCW_AUTOSIZE); 275 | ListView_SetColumnWidth(listHWnd,2,LVSCW_AUTOSIZE); 276 | ListView_SetColumnWidth(listHWnd,3,LVSCW_AUTOSIZE); 277 | 278 | EnableWindow(GetDlgItem(hDlg,IDUNDO),FALSE) ; 279 | 280 | return 1; 281 | } 282 | 283 | 284 | BOOL CALLBACK 285 | enumWindowsSaveListProc(HWND hwnd, LPARAM lParam) 286 | { 287 | FILE *wdFp=(FILE *) lParam ; 288 | DWORD procId, threadId ; 289 | int style, exstyle, desk ; 290 | RECT pos ; 291 | #ifdef _UNICODE 292 | WCHAR nameW[vwWINDOWNAME_MAX] ; 293 | #endif 294 | char text[vwWINDOWNAME_MAX] ; 295 | char class[vwCLASSNAME_MAX] ; 296 | 297 | 298 | style = GetWindowLong(hwnd, GWL_STYLE); 299 | exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); 300 | threadId = GetWindowThreadProcessId(hwnd,&procId) ; 301 | GetWindowRect(hwnd,&pos); 302 | #ifdef _UNICODE 303 | GetClassName(hwnd,nameW,vwCLASSNAME_MAX); 304 | WideCharToMultiByte(CP_ACP,0,nameW,-1,class,vwCLASSNAME_MAX, 0, 0) ; 305 | if(GetWindowText(hwnd,nameW,vwWINDOWNAME_MAX)) 306 | WideCharToMultiByte(CP_ACP,0,nameW,-1,text,vwWINDOWNAME_MAX, 0, 0) ; 307 | else 308 | #else 309 | GetClassName(hwnd,class,vwCLASSNAME_MAX); 310 | if(!GetWindowText(hwnd,text,vwWINDOWNAME_MAX)) 311 | #endif 312 | strcpy_s(text,128, ""); 313 | 314 | if(vwHandle != 0) 315 | desk = SendMessage(vwHandle,VW_WINGETINFO,(WPARAM) hwnd,0) ; 316 | else 317 | desk = 0 ; 318 | fprintf(wdFp,"%8x %08x %08x %8x %8x %8x %6x %s\n%8d %8x %8d %8d %8d %8d %6d %s\n", 319 | (int)hwnd,style,exstyle,(int)GetParent(hwnd), 320 | (int)GetWindow(hwnd,GW_OWNER),(int)GetClassLong(hwnd,GCL_HICON),(desk & 0x00ffffff),text, 321 | (int)procId,(int)threadId,(int)pos.top,(int)pos.bottom,(int)pos.left,(int)pos.right, 322 | ((desk >> vwWTFLAGS_HIDEWIN_BITROT) & 0x00ff),class) ; 323 | 324 | return TRUE; 325 | } 326 | 327 | static vwlWindow * 328 | GetListSelection(HWND hwndDlg) 329 | { 330 | LVITEM item ; 331 | int ii ; 332 | 333 | listHWnd = GetDlgItem(hwndDlg,ID_WINLIST) ; 334 | if(ListView_GetSelectedCount(listHWnd) != 1) 335 | return NULL ; 336 | 337 | ii = ListView_GetItemCount(listHWnd) ; 338 | while(--ii >=0) 339 | { 340 | memset(&item,0,sizeof(LVITEM)) ; 341 | item.mask = LVIF_STATE | LVIF_PARAM ; 342 | item.stateMask = LVIS_SELECTED ; 343 | item.iItem = ii ; 344 | ListView_GetItem(listHWnd,&item) ; 345 | if(item.state & LVIS_SELECTED) 346 | return ((vwlWindow *) item.lParam) ; 347 | } 348 | return NULL ; 349 | } 350 | 351 | /* This is the main function for the dialog. */ 352 | static BOOL CALLBACK 353 | DialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 354 | { 355 | vwlWindow *curw ; 356 | 357 | switch(msg) 358 | { 359 | case WM_INITDIALOG: 360 | GenerateWinList(hwndDlg,0); 361 | return TRUE; 362 | 363 | case WM_NOTIFY: 364 | if(wParam == ID_WINLIST) 365 | { 366 | NM_LISTVIEW *nm = (NM_LISTVIEW *) lParam ; 367 | if(nm->hdr.code == LVN_COLUMNCLICK) 368 | { 369 | if(nm->iSubItem != sortCol) 370 | { 371 | sortCol = nm->iSubItem ; 372 | sortDir = 0 ; 373 | } 374 | else 375 | sortDir ^= 1 ; 376 | ListView_SortItems(nm->hdr.hwndFrom,ListCompFunc,0) ; 377 | return TRUE; 378 | } 379 | } 380 | break; 381 | case WM_COMMAND: 382 | switch (LOWORD(wParam)) 383 | { 384 | case IDREFRESH: 385 | GenerateWinList(hwndDlg,1) ; 386 | return TRUE; 387 | 388 | case IDOK: 389 | if((curw = GetListSelection(hwndDlg)) != NULL) 390 | { 391 | int left, top; 392 | if(curw->flag > 0) 393 | /* make VW display the window */ 394 | SendMessage(vwHandle,VW_ACCESSWIN,(WPARAM) curw->handle,1) ; 395 | if((curw->style & WS_VISIBLE) == 0) 396 | { 397 | ShowWindow(curw->handle, SW_SHOWNA); 398 | ShowOwnedPopups(curw->handle, SW_SHOWNA); 399 | } 400 | if((curw->style & WS_VISIBLE) && (curw->exstyle & WS_EX_TOOLWINDOW)) 401 | { 402 | // Restore the window mode 403 | SetWindowLong(curw->handle, GWL_EXSTYLE, (curw->exstyle & (~WS_EX_TOOLWINDOW))) ; 404 | // Notify taskbar of the change 405 | if(hwndTask != NULL) 406 | PostMessage(hwndTask, RM_Shellhook, 1, (LPARAM) curw->handle); 407 | } 408 | left = curw->rect.left ; 409 | top = curw->rect.top ; 410 | /* some apps hide the window by pushing it to -32000, 411 | * VirtuaWin does not move these windows */ 412 | if((left != -32000) || (top != -32000)) 413 | { 414 | if(top < -5000) 415 | top += 25000 ; 416 | if(left < screenLeft) 417 | left = screenLeft + 10 ; 418 | else if(left > screenRight) 419 | left = screenLeft + 10 ; 420 | if(top < screenTop) 421 | top = screenTop + 10 ; 422 | else if(top > screenBottom) 423 | top = screenTop + 10 ; 424 | SetWindowPos(curw->handle, 0, left, top, 0, 0, 425 | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE ); 426 | } 427 | SetForegroundWindow(curw->handle); 428 | curw->restored = 1 ; 429 | EnableWindow(GetDlgItem(hwndDlg,IDUNDO),TRUE) ; 430 | } 431 | return 1; 432 | case IDUNDO: 433 | if((curw = GetListSelection(hwndDlg)) != NULL) 434 | { 435 | if(curw->restored) 436 | { 437 | if(curw->flag > 0) 438 | /* make VW display the window */ 439 | SendMessage(vwHandle,VW_ASSIGNWIN,(WPARAM) curw->handle, (LPARAM) curw->flag) ; 440 | if((curw->style & WS_VISIBLE) == 0) 441 | { 442 | ShowWindow(curw->handle, SW_HIDE); 443 | ShowOwnedPopups(curw->handle, SW_HIDE); 444 | } 445 | if((curw->style & WS_VISIBLE) && (curw->exstyle & WS_EX_TOOLWINDOW)) 446 | { 447 | // Restore the window mode 448 | SetWindowLong(curw->handle, GWL_EXSTYLE, curw->exstyle) ; 449 | // Notify taskbar of the change 450 | if(hwndTask != NULL) 451 | PostMessage(hwndTask, RM_Shellhook, 2, (LPARAM) curw->handle); 452 | } 453 | SetWindowPos(curw->handle, 0, curw->rect.left, curw->rect.top, 0, 0, 454 | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE ); 455 | curw->restored = 0 ; 456 | } 457 | else 458 | MessageBox(hwndDlg, _T("Cannot undo, not restored."), _T("VirtuaWinList Error"), MB_ICONWARNING); 459 | } 460 | return 1; 461 | 462 | case IDSAVE: 463 | if(winInitialised) 464 | { 465 | TCHAR fname[MAX_PATH] ; 466 | FILE *wdFp ; 467 | int ii=1 ; 468 | while(ii < 1000) 469 | { 470 | _stprintf_s(fname,260, _T("%sWinList_%d.log"),(winInitialised) ? userAppPath:_T(""),ii) ; 471 | if(GetFileAttributes(fname) == INVALID_FILE_ATTRIBUTES) 472 | break ; 473 | ii++ ; 474 | } 475 | if(ii == 1000) 476 | MessageBox(hwndDlg, _T("Cannot create a WinList_#.log file, please clean up your user directory."), _T("VirtuaWinList Error"), MB_ICONWARNING); 477 | else 478 | { 479 | wdFp = _tfopen(fname, _T("w+")); 480 | EnumWindows(enumWindowsSaveListProc,(LPARAM) wdFp) ; 481 | fclose(wdFp) ; 482 | } 483 | } 484 | return 1; 485 | case IDCANCEL: 486 | EndDialog(hwndDlg,0); 487 | if(runMode) 488 | exit(0) ; 489 | FreeWindowList() ; 490 | return 1; 491 | } 492 | break; 493 | 494 | case WM_CLOSE: 495 | EndDialog(hwndDlg,0); 496 | if(runMode) 497 | exit(0) ; 498 | FreeWindowList() ; 499 | return TRUE; 500 | 501 | } 502 | return FALSE; 503 | } 504 | 505 | 506 | static void 507 | goGetTheTaskbarHandle(void) 508 | { 509 | HWND hwndTray = FindWindowEx(NULL, NULL,_T("Shell_TrayWnd"), NULL); 510 | HWND hwndBar = FindWindowEx(hwndTray, NULL,_T("ReBarWindow32"), NULL ); 511 | 512 | // Maybe "RebarWindow32" is not a child to "Shell_TrayWnd", then try this 513 | if(hwndBar == NULL) 514 | hwndBar = hwndTray; 515 | 516 | hwndTask = FindWindowEx(hwndBar, NULL,_T("MSTaskSwWClass"), NULL); 517 | 518 | /* SF 1843056 - don't complain if not found, may be using a different 519 | * shell, leave it to VirtuaWin to complain if appropriate */ 520 | } 521 | 522 | LRESULT CALLBACK 523 | MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 524 | { 525 | switch (msg) 526 | { 527 | 528 | case MOD_INIT: 529 | // The handle to VirtuaWin comes in the wParam 530 | vwHandle = (HWND) wParam; 531 | // If not yet winInitialised get the user path and initialize. 532 | if(!winInitialised) 533 | { 534 | SendMessage(vwHandle, VW_USERAPPPATH, (WPARAM) hwnd, 0) ; 535 | if(!winInitialised) 536 | /* do not exit as this maybe caused by a problem we are trying to fix */ 537 | MessageBox(hwnd, _T("VirtuaWin failed to send the UserApp path."), _T("VirtuaWinList Error"), MB_ICONWARNING); 538 | } 539 | break; 540 | case WM_COPYDATA: 541 | if(!winInitialised) 542 | { 543 | COPYDATASTRUCT *cds; 544 | cds = (COPYDATASTRUCT *) lParam ; 545 | if(cds->dwData == (0-VW_USERAPPPATH)) 546 | { 547 | if((cds->cbData < 2) || (cds->lpData == NULL)) 548 | return FALSE ; 549 | winInitialised = 1 ; 550 | #ifdef _UNICODE 551 | MultiByteToWideChar(CP_ACP,0,(char *) cds->lpData,-1,userAppPath,MAX_PATH) ; 552 | #else 553 | strcpy_s(userAppPath,260,(char *) cds->lpData) ; 554 | #endif 555 | } 556 | } 557 | return TRUE ; 558 | case MOD_QUIT: // This must be handeled, otherwise VirtuaWin can't shut down the module 559 | PostQuitMessage(0); 560 | break; 561 | case MOD_SETUP: // Optional 562 | if(wParam != 0) 563 | hwnd = (HWND) wParam ; 564 | else 565 | hwnd = (HWND) hwndMain ; 566 | SetForegroundWindow(hwnd) ; 567 | DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), hwnd, (DLGPROC) DialogFunc); 568 | break; 569 | case WM_DESTROY: 570 | PostQuitMessage(0); 571 | break; 572 | default: 573 | return DefWindowProc(hwnd, msg, wParam, lParam); 574 | } 575 | 576 | return 0; 577 | } 578 | 579 | /* Initializes the window */ 580 | static BOOL 581 | WinListInit(void) 582 | { 583 | WNDCLASS wc; 584 | 585 | InitCommonControls(); 586 | memset(&wc, 0, sizeof(WNDCLASS)); 587 | wc.style = 0; 588 | wc.lpfnWndProc = (WNDPROC)MainWndProc; 589 | wc.hInstance = hInst; 590 | /* IMPORTANT! The classname must be the same as the filename since VirtuaWin uses 591 | this for locating the window */ 592 | wc.lpszClassName = _T("WinList.exe"); 593 | 594 | if (!RegisterClass(&wc)) 595 | return 0; 596 | 597 | // the window is never shown 598 | if ((hwndMain = CreateWindow(_T("WinList.exe"), 599 | _T("WinList"), 600 | WS_POPUP, 601 | CW_USEDEFAULT, 602 | 0, 603 | CW_USEDEFAULT, 604 | 0, 605 | NULL, 606 | NULL, 607 | hInst, 608 | NULL)) == (HWND)0) 609 | return 0; 610 | 611 | RM_Shellhook = RegisterWindowMessage(_T("SHELLHOOK")); 612 | goGetTheTaskbarHandle() ; 613 | 614 | return 1; 615 | } 616 | 617 | /* 618 | * Main startup function 619 | */ 620 | int WINAPI 621 | WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) 622 | { 623 | MSG msg; 624 | 625 | hInst = hInstance; 626 | if(!WinListInit()) 627 | return 0; 628 | 629 | runMode = (strstr(lpCmdLine,"-module") == NULL) ; 630 | if(runMode) 631 | { 632 | SetForegroundWindow(hwndMain) ; 633 | DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), hwndMain, (DLGPROC) DialogFunc); 634 | } 635 | 636 | // main messge loop 637 | while (GetMessage(&msg, NULL, 0, 0)) 638 | { 639 | TranslateMessage(&msg); 640 | DispatchMessage(&msg); 641 | } 642 | return msg.wParam; 643 | } 644 | -------------------------------------------------------------------------------- /Source/WinRuleDialog.c: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // WinRuleDialog.c - Window Rule Dialog routines. 4 | // 5 | // Copyright (c) 2007-2012 VirtuaWin (VirtuaWin@home.se) 6 | // 7 | // This program is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 2 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | // USA. 21 | // 22 | 23 | // Must compile with define of _WIN32_IE=0x0200 otherwise the dialog 24 | // will not open on NT/95 without a patch (known MS issue) 25 | #define _WIN32_IE 0x0200 26 | 27 | // Includes 28 | #include "VirtuaWin.h" 29 | #include "Resource.h" 30 | #include "Messages.h" 31 | #include "DiskRoutines.h" 32 | #include "ConfigParameters.h" 33 | 34 | // Standard includes 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | static int deskCount ; 42 | static HWND initWin ; 43 | static vwWindowRule *winRuleCur ; 44 | static char wtypeNameLabel[vwWTNAME_COUNT] = "CWP"; 45 | 46 | static void 47 | windowRuleDialogInitList(HWND hDlg) 48 | { 49 | static int ts[3] = { 16, 20, 120 } ; 50 | vwWindowRule *wt ; 51 | TCHAR buff[388], *ss; 52 | int ii, winRuleCurIdx=0 ; 53 | 54 | SendDlgItemMessage(hDlg,IDC_WTYPE_LIST,LB_RESETCONTENT,0, 0); 55 | SendDlgItemMessage(hDlg,IDC_WTYPE_LIST,LB_SETTABSTOPS,(WPARAM) 3,(LPARAM) ts); 56 | ii = 0 ; 57 | wt = windowRuleList ; 58 | while(wt != NULL) 59 | { 60 | if(((wt->flags & vwWTFLAGS_MOVE) == 0) || (wt->desk <= deskCount)) 61 | { 62 | ii++ ; 63 | ss = buff; 64 | ss += _stprintf_s(ss, 388, _T("%d"), ii); 65 | windowRuleFormatDescription(ss, wt); 66 | SendDlgItemMessage(hDlg,IDC_WTYPE_LIST,LB_ADDSTRING,0,(LONG) buff); 67 | if(wt == winRuleCur) 68 | winRuleCurIdx = ii ; 69 | } 70 | wt = wt->next ; 71 | } 72 | if(winRuleCurIdx) 73 | SendDlgItemMessage(hDlg,IDC_WTYPE_LIST,LB_SETCURSEL,winRuleCurIdx-1,0) ; 74 | else 75 | winRuleCur = NULL ; 76 | } 77 | 78 | void 79 | windowRuleFormatDescription(TCHAR* ss, vwWindowRule *wt) 80 | { 81 | int jj, kk; 82 | 83 | for (jj = 0; jjname[jj] != NULL) 86 | { 87 | *ss++ = '\t'; 88 | *ss++ = wtypeNameLabel[jj]; 89 | *ss++ = 'N'; 90 | *ss++ = ':'; 91 | if (wt->flags & (1 << (jj << 1))) 92 | *ss++ = '*'; 93 | kk = _tcslen(wt->name[jj]); 94 | if (kk > 120) 95 | { 96 | _tcsncpy_s(ss, 388, wt->name[jj], 120); 97 | ss += 120; 98 | *ss++ = '.'; 99 | *ss++ = '.'; 100 | *ss++ = '.'; 101 | } 102 | else 103 | { 104 | _tcsncpy_s(ss, 388, wt->name[jj], kk); 105 | ss += kk; 106 | } 107 | if (wt->flags & (2 << (jj << 1))) 108 | *ss++ = '*'; 109 | } 110 | } 111 | *ss = '\0'; 112 | } 113 | 114 | 115 | 116 | static int wtypeNameEntry[vwWTNAME_COUNT] = { IDC_WTYPE_CNAME, IDC_WTYPE_WNAME, IDC_WTYPE_PNAME } ; 117 | static void 118 | windowRuleDialogInitItem(HWND hDlg) 119 | { 120 | vwWindowRule *wt ; 121 | TCHAR buff[1024] ; 122 | int ii ; 123 | 124 | if(winRuleCur != NULL) 125 | { 126 | ii = 0 ; 127 | wt = windowRuleList ; 128 | while(wt != NULL) 129 | { 130 | if(((wt->flags & vwWTFLAGS_MOVE) == 0) || (wt->desk <= deskCount)) 131 | { 132 | if(wt == winRuleCur) 133 | break ; 134 | ii++ ; 135 | } 136 | wt = wt->next ; 137 | } 138 | 139 | if(wt != NULL) 140 | { 141 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_UP),(ii > 0)) ; 142 | ii = vwWTNAME_COUNT-1 ; 143 | do { 144 | buff[0] = '\0' ; 145 | if(wt->name[ii] != NULL) 146 | { 147 | if(wt->flags & (1 << (ii << 1))) 148 | { 149 | buff[0] = '*' ; 150 | _tcscpy_s(buff + 1, 1024, wt->name[ii]); 151 | } 152 | else 153 | _tcscpy_s(buff, 1024, wt->name[ii]); 154 | if(wt->flags & (2 << (ii << 1))) 155 | _tcscat_s(buff, 1024, _T("*")); 156 | if(buff[0] == '\0') 157 | _tcscpy_s(buff, 1024,vwWTNAME_NONE); 158 | } 159 | SetDlgItemText(hDlg,wtypeNameEntry[ii],buff) ; 160 | } while(--ii >= 0) ; 161 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_MOD),TRUE) ; 162 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DEL),TRUE) ; 163 | SendDlgItemMessage(hDlg,IDC_WTYPE_ENABLE,BM_SETCHECK,((wt->flags & vwWTFLAGS_ENABLED) != 0), 0); 164 | SendDlgItemMessage(hDlg,IDC_WTYPE_CLOSE,BM_SETCHECK,((wt->flags & vwWTFLAGS_CLOSE) != 0), 0); 165 | SendDlgItemMessage(hDlg,IDC_WTYPE_ALONTOP,BM_SETCHECK,((wt->flags & vwWTFLAGS_ALWAYSONTOP) != 0), 0); 166 | SendDlgItemMessage(hDlg,IDC_WTYPE_NMANAGE,BM_SETCHECK,((wt->flags & vwWTFLAGS_DONT_MANAGE) != 0), 0); 167 | SendDlgItemMessage(hDlg,IDC_WTYPE_AMANAGE,BM_SETCHECK,((wt->flags & vwWTFLAGS_MANAGE) != 0), 0); 168 | SendDlgItemMessage(hDlg,IDC_WTYPE_VMANAGE,BM_SETCHECK,((wt->flags & (vwWTFLAGS_DONT_MANAGE|vwWTFLAGS_MANAGE)) == 0), 0); 169 | SendDlgItemMessage(hDlg,IDC_WTYPE_MAINWIN,BM_SETCHECK,((wt->flags & vwWTFLAGS_MAIN_WIN) != 0), 0); 170 | SendDlgItemMessage(hDlg,IDC_WTYPE_STICKY,BM_SETCHECK,((wt->flags & vwWTFLAGS_STICKY) != 0), 0); 171 | SendDlgItemMessage(hDlg,IDC_WTYPE_GRPAPP,BM_SETCHECK,((wt->flags & vwWTFLAGS_GROUP_APP) != 0), 0); 172 | if((ii = ((wt->flags & vwWTFLAGS_MOVE) != 0)) && wt->desk) 173 | SendDlgItemMessage(hDlg,IDC_WTYPE_AMDSK,CB_SETCURSEL,wt->desk-1, 0) ; 174 | SendDlgItemMessage(hDlg,IDC_WTYPE_AMOVE,BM_SETCHECK,ii,0); 175 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_AMDSK),ii) ; 176 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_AMIMM),ii) ; 177 | SendDlgItemMessage(hDlg,IDC_WTYPE_AMIMM,BM_SETCHECK,((wt->flags & vwWTFLAGS_MOVE_IMMEDIATE) != 0), 0); 178 | SendDlgItemMessage(hDlg,IDC_WTYPE_HWACT,CB_SETCURSEL,((wt->flags & vwWTFLAGS_HWACT_MASK) >> vwWTFLAGS_HWACT_BITROT), 0) ; 179 | SendDlgItemMessage(hDlg,IDC_WTYPE_WHIDE,CB_SETCURSEL,((wt->flags & vwWTFLAGS_HIDEWIN_MASK) >> vwWTFLAGS_HIDEWIN_BITROT), 0) ; 180 | SendDlgItemMessage(hDlg,IDC_WTYPE_THIDE,CB_SETCURSEL,((wt->flags & vwWTFLAGS_HIDETSK_MASK) >> vwWTFLAGS_HIDETSK_BITROT), 0) ; 181 | 182 | while((wt=wt->next) != NULL) 183 | if(((wt->flags & vwWTFLAGS_MOVE) == 0) || (wt->desk <= deskCount)) 184 | break ; 185 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DOWN),(wt != NULL)) ; 186 | return ; 187 | } 188 | } 189 | winRuleCur = NULL ; 190 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_UP),FALSE) ; 191 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DOWN),FALSE) ; 192 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_MOD),FALSE) ; 193 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DEL),FALSE) ; 194 | } 195 | 196 | 197 | static void 198 | windowRuleFillInitial(HWND hDlg) { 199 | if (initWin != NULL) 200 | { 201 | TCHAR buff[MAX_PATH]; 202 | DWORD procId; 203 | HANDLE procHdl; 204 | DWORD procSize = MAX_PATH; 205 | typedef DWORD(WINAPI *vwGETMODULEFILENAMEEX)(HANDLE, HMODULE, LPTSTR, DWORD); 206 | extern vwGETMODULEFILENAMEEX vwGetModuleFileNameEx; 207 | 208 | buff[0] = 0; 209 | GetClassName(initWin, buff, MAX_PATH); 210 | SetDlgItemText(hDlg, wtypeNameEntry[0], buff); 211 | buff[0] = 0; 212 | GetWindowText(initWin, buff, MAX_PATH); 213 | if (buff[0] == 0) 214 | _tcscpy_s(buff, 260, vwWTNAME_NONE); 215 | SetDlgItemText(hDlg, wtypeNameEntry[1], buff); 216 | buff[0] = 0; 217 | if ((vwGetModuleFileNameEx != NULL) && 218 | (GetWindowThreadProcessId(initWin, &procId) != 0) && (procId != 0) && 219 | ((procHdl = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, procId)) != NULL)) 220 | { 221 | // vwGetModuleFileNameEx(procHdl, NULL, buff, MAX_PATH); 222 | QueryFullProcessImageName(procHdl, 0, buff, &procSize); 223 | CloseHandle(procHdl); 224 | } 225 | SetDlgItemText(hDlg, wtypeNameEntry[2], buff); 226 | initWin = NULL; 227 | } 228 | } 229 | 230 | 231 | static void 232 | windowRuleDialogInit(HWND hDlg, int firstTime) 233 | { 234 | TCHAR buff[MAX_PATH]; 235 | int ii; 236 | 237 | if (firstTime) 238 | { 239 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_ADDSTRING, 0, (LONG)_T("Default - configured in main Setup")); 240 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_ADDSTRING, 0, (LONG)_T("Ignore the event")); 241 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_ADDSTRING, 0, (LONG)_T("Move window to current desktop")); 242 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_ADDSTRING, 0, (LONG)_T("Show window on current desktop")); 243 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_ADDSTRING, 0, (LONG)_T("Change to window's desktop")); 244 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_ADDSTRING, 0, (LONG)_T("Hide using standard method")); 245 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_ADDSTRING, 0, (LONG)_T("Hide by move window")); 246 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_ADDSTRING, 0, (LONG)_T("Hide by minimizing window")); 247 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_ADDSTRING, 0, (LONG)_T("Hide using standard method")); 248 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_ADDSTRING, 0, (LONG)_T("Show - Keep taskbar button visible")); 249 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_ADDSTRING, 0, (LONG)_T("Hide by using toolwin flag")); 250 | SendDlgItemMessage(hDlg, IDC_WTYPE_ENABLE, BM_SETCHECK, 1, 0); 251 | SendDlgItemMessage(hDlg, IDC_WTYPE_VMANAGE, BM_SETCHECK, 1, 0); 252 | SendDlgItemMessage(hDlg, IDC_WTYPE_HWACT, CB_SETCURSEL, 0, 0); 253 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_SETCURSEL, 0, 0); 254 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_SETCURSEL, 0, 0); 255 | EnableWindow(GetDlgItem(hDlg, IDC_WTYPE_AMDSK), FALSE); 256 | EnableWindow(GetDlgItem(hDlg, IDC_WTYPE_AMIMM), FALSE); 257 | EnableWindow(GetDlgItem(hDlg, IDC_WTYPE_APPLY), FALSE); 258 | } 259 | SendDlgItemMessage(hDlg, IDC_WTYPE_AMDSK, CB_RESETCONTENT, 0, 0); 260 | for (ii = 1; ii <= deskCount; ii++) 261 | { 262 | _stprintf_s(buff, 260, _T("%d"), ii); 263 | SendDlgItemMessage(hDlg, IDC_WTYPE_AMDSK, CB_ADDSTRING, 0, (LONG)buff); 264 | } 265 | SendDlgItemMessage(hDlg, IDC_WTYPE_AMDSK, CB_SETCURSEL, 0, 0); 266 | windowRuleDialogInitList(hDlg); 267 | windowRuleDialogInitItem(hDlg); 268 | windowRuleFillInitial(hDlg); 269 | } 270 | 271 | 272 | 273 | static void 274 | windowRuleDialogSetItem(HWND hDlg) 275 | { 276 | int ii, jj ; 277 | 278 | if((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_LIST,LB_GETCURSEL,0,0)) != LB_ERR) 279 | { 280 | jj = 0 ; 281 | winRuleCur = windowRuleList ; 282 | while(winRuleCur != NULL) 283 | { 284 | if((winRuleCur->flags & vwWTFLAGS_MOVE) && (winRuleCur->desk > deskCount)) 285 | ii++ ; 286 | if(jj == ii) 287 | break ; 288 | jj++ ; 289 | winRuleCur = winRuleCur->next ; 290 | } 291 | } 292 | else 293 | winRuleCur = NULL ; 294 | windowRuleDialogInitItem(hDlg) ; 295 | } 296 | 297 | static void 298 | windowRuleDialogMoveUp(HWND hDlg) 299 | { 300 | vwWindowRule *wt, *pwt, *ppwt ; 301 | 302 | if(winRuleCur != NULL) 303 | { 304 | ppwt = pwt = NULL ; 305 | wt = windowRuleList ; 306 | while((wt != winRuleCur) && (wt != NULL)) 307 | { 308 | if(((wt->flags & vwWTFLAGS_MOVE) == 0) || (wt->desk <= deskCount)) 309 | { 310 | ppwt = pwt ; 311 | pwt = wt ; 312 | } 313 | wt = wt->next ; 314 | } 315 | if(wt == NULL) 316 | winRuleCur = NULL ; 317 | else if(pwt != NULL) 318 | { 319 | wt = pwt ; 320 | while(wt->next != winRuleCur) 321 | wt = wt->next ; 322 | wt->next = winRuleCur->next ; 323 | if(pwt == windowRuleList) 324 | windowRuleList = winRuleCur ; 325 | else 326 | { 327 | wt = windowRuleList ; 328 | while(wt->next != pwt) 329 | wt = wt->next ; 330 | wt->next = winRuleCur ; 331 | } 332 | winRuleCur->next = pwt ; 333 | if(ppwt == NULL) 334 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_UP),FALSE) ; 335 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DOWN),TRUE) ; 336 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_APPLY),TRUE) ; 337 | } 338 | } 339 | windowRuleDialogInitList(hDlg) ; 340 | } 341 | 342 | static void 343 | windowRuleDialogMoveDown(HWND hDlg) 344 | { 345 | vwWindowRule *wt, *pwt ; 346 | 347 | if(winRuleCur != NULL) 348 | { 349 | wt = windowRuleList ; 350 | while((wt != winRuleCur) && (wt != NULL)) 351 | wt = wt->next ; 352 | if(wt == NULL) 353 | winRuleCur = NULL ; 354 | else 355 | { 356 | while(((wt = wt->next) != NULL) && (wt->flags & vwWTFLAGS_MOVE) && (wt->desk > deskCount)) 357 | ; 358 | if(wt != NULL) 359 | { 360 | if(winRuleCur == windowRuleList) 361 | windowRuleList = winRuleCur->next ; 362 | else 363 | { 364 | pwt = windowRuleList ; 365 | while(pwt->next != winRuleCur) 366 | pwt = pwt->next ; 367 | pwt->next = winRuleCur->next ; 368 | } 369 | winRuleCur->next = wt->next ; 370 | wt->next = winRuleCur ; 371 | wt = winRuleCur ; 372 | while(((wt = wt->next) != NULL) && (wt->flags & vwWTFLAGS_MOVE) && (wt->desk > deskCount)) 373 | ; 374 | if(wt == NULL) 375 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_DOWN),FALSE) ; 376 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_UP),TRUE) ; 377 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_APPLY),TRUE) ; 378 | } 379 | } 380 | } 381 | windowRuleDialogInitList(hDlg) ; 382 | } 383 | 384 | 385 | // 386 | 387 | /************************************************ 388 | * Add or modify rules in the window rule dialog 389 | * add can be one of the following values: 390 | * -1 - modify existing rule, do not refresh 391 | * 0 - modify current rule, refresh 392 | * 1 - add new rule, refresh 393 | * - Window will be shown on the current desktop. 394 | */ 395 | static void 396 | windowRuleDialogAddMod(HWND hDlg, int add) 397 | { 398 | vwWindowRule *wt ; 399 | int ii, ll, mallocErr=0 ; 400 | TCHAR buff[1024], *ss ; 401 | vwUInt flags ; 402 | 403 | if(add == 1) 404 | { 405 | if((wt = calloc(1,sizeof(vwWindowRule))) == NULL) 406 | mallocErr = 1 ; 407 | else 408 | { 409 | wt->next = windowRuleList ; 410 | windowRuleList = wt ; 411 | } 412 | } 413 | else 414 | { 415 | wt = windowRuleList ; 416 | while((wt != winRuleCur) && (wt != NULL)) 417 | wt = wt->next ; 418 | } 419 | if(wt != NULL) 420 | { 421 | flags = 0 ; 422 | 423 | ii = vwWTNAME_COUNT-1 ; 424 | do { 425 | GetDlgItemText(hDlg,wtypeNameEntry[ii],buff,1024) ; 426 | ss = buff ; 427 | if(ss[0] != '\0') 428 | { 429 | if(!_tcscmp(buff,vwWTNAME_NONE)) 430 | ss[0] = '\0' ; 431 | if(ss[0] == '*') 432 | { 433 | flags |= 1 << (ii << 1) ; 434 | ss++ ; 435 | } 436 | ll = _tcslen(ss) ; 437 | if((ll > 0) && (ss[ll-1] == '*')) 438 | { 439 | flags |= 2 << (ii << 1) ; 440 | ss[--ll] = '\0' ; 441 | } 442 | if((wt->name[ii] != NULL) && _tcscmp(ss,wt->name[ii])) 443 | { 444 | free(wt->name[ii]) ; 445 | wt->name[ii] = NULL ; 446 | wt->nameLen[ii] = 0 ; 447 | } 448 | if(wt->name[ii] == NULL) 449 | { 450 | if((wt->name[ii] = _tcsdup(ss)) == NULL) 451 | mallocErr = 1 ; 452 | else 453 | wt->nameLen[ii] = ll ; 454 | } 455 | } 456 | else if(wt->name[ii] != NULL) 457 | { 458 | free(wt->name[ii]) ; 459 | wt->name[ii] = NULL ; 460 | wt->nameLen[ii] = 0 ; 461 | } 462 | } while(--ii >= 0) ; 463 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_ENABLE,BM_GETCHECK,0,0) == BST_CHECKED) 464 | flags |= vwWTFLAGS_ENABLED ; 465 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_CLOSE,BM_GETCHECK,0,0) == BST_CHECKED) 466 | flags |= vwWTFLAGS_CLOSE ; 467 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_ALONTOP,BM_GETCHECK,0,0) == BST_CHECKED) 468 | flags |= vwWTFLAGS_ALWAYSONTOP ; 469 | else if(SendDlgItemMessage(hDlg,IDC_WTYPE_NMANAGE,BM_GETCHECK,0,0) == BST_CHECKED) 470 | flags |= vwWTFLAGS_DONT_MANAGE ; 471 | else if(SendDlgItemMessage(hDlg,IDC_WTYPE_AMANAGE,BM_GETCHECK,0,0) == BST_CHECKED) 472 | flags |= vwWTFLAGS_MANAGE ; 473 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_MAINWIN,BM_GETCHECK,0,0) == BST_CHECKED) 474 | flags |= vwWTFLAGS_MAIN_WIN ; 475 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_STICKY,BM_GETCHECK,0,0) == BST_CHECKED) 476 | flags |= vwWTFLAGS_STICKY ; 477 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_GRPAPP,BM_GETCHECK,0,0) == BST_CHECKED) 478 | flags |= vwWTFLAGS_GROUP_APP ; 479 | wt->desk = 0 ; 480 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_AMOVE,BM_GETCHECK,0,0) == BST_CHECKED) 481 | { 482 | flags |= vwWTFLAGS_MOVE ; 483 | if((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_AMDSK,CB_GETCURSEL,0,0)) != CB_ERR) 484 | wt->desk = ii + 1 ; 485 | } 486 | if(SendDlgItemMessage(hDlg,IDC_WTYPE_AMIMM,BM_GETCHECK,0,0) == BST_CHECKED) 487 | flags |= vwWTFLAGS_MOVE_IMMEDIATE ; 488 | 489 | if((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_HWACT,CB_GETCURSEL,0,0)) != CB_ERR) 490 | flags |= ii << vwWTFLAGS_HWACT_BITROT ; 491 | if((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_WHIDE,CB_GETCURSEL,0,0)) != CB_ERR) 492 | flags |= ii << vwWTFLAGS_HIDEWIN_BITROT ; 493 | if((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_THIDE,CB_GETCURSEL,0,0)) != CB_ERR) 494 | flags |= ii << vwWTFLAGS_HIDETSK_BITROT ; 495 | wt->flags = flags ; 496 | winRuleCur = wt ; 497 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_APPLY),TRUE) ; 498 | } 499 | if(mallocErr) 500 | MessageBox(hWnd,_T("System resources are low, failed to create new window rule."),vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR); 501 | if (add != -1) { 502 | windowRuleDialogInitList(hDlg); 503 | windowRuleDialogInitItem(hDlg); 504 | } 505 | 506 | } 507 | 508 | static void 509 | windowRuleDialogDelete(HWND hDlg) 510 | { 511 | vwWindowRule *wt, *pwt ; 512 | int ii ; 513 | if(winRuleCur != NULL) 514 | { 515 | pwt = NULL ; 516 | wt = windowRuleList ; 517 | while((wt != winRuleCur) && (wt != NULL)) 518 | { 519 | pwt = wt ; 520 | wt = wt->next ; 521 | } 522 | if(wt != NULL) 523 | { 524 | if(pwt == NULL) 525 | windowRuleList = wt->next ; 526 | else 527 | pwt->next = wt->next ; 528 | 529 | ii = vwWTNAME_COUNT-1 ; 530 | do { 531 | if(wt->name[ii] != NULL) 532 | free(wt->name[ii]) ; 533 | } while(--ii >= 0) ; 534 | free(wt) ; 535 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_APPLY),TRUE) ; 536 | } 537 | winRuleCur = NULL ; 538 | } 539 | windowRuleDialogInitList(hDlg) ; 540 | } 541 | 542 | static BOOL CALLBACK 543 | windowRuleDialogFunc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) 544 | { 545 | int ii, jj ; 546 | switch (msg) 547 | { 548 | case WM_INITDIALOG: 549 | dialogHWnd = hDlg ; 550 | SetWindowPos(hDlg, 0, dialogPos[0], dialogPos[1], 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); 551 | windowRuleDialogInit(hDlg,1) ; 552 | return TRUE; 553 | 554 | case WM_COMMAND: 555 | switch (LOWORD(wParam)) 556 | { 557 | case IDC_WTYPE_LIST: 558 | if(HIWORD(wParam) == LBN_SELCHANGE) 559 | // To add automatic saving will require a small refactor. 560 | // We need to start saving the currently selected item globally, 561 | // and then applying operations to that item, instead of relying 562 | // on the dialog box to keep track of the item, since before we see the 563 | // switch message it forgets the item without saving. 564 | //if (winRuleCur != NULL) 565 | // windowRuleDialogAddMod(hDlg, -1); 566 | 567 | windowRuleDialogSetItem(hDlg) ; 568 | break ; 569 | 570 | case IDC_WTYPE_UP: 571 | windowRuleDialogMoveUp(hDlg) ; 572 | break ; 573 | 574 | case IDC_WTYPE_DOWN: 575 | windowRuleDialogMoveDown(hDlg) ; 576 | break ; 577 | 578 | case IDC_WTYPE_ADD: 579 | windowRuleDialogAddMod(hDlg,1) ; 580 | break ; 581 | 582 | case IDC_WTYPE_MOD: 583 | windowRuleDialogAddMod(hDlg, 0); 584 | break ; 585 | 586 | case IDC_WTYPE_DEL: 587 | windowRuleDialogDelete(hDlg) ; 588 | break ; 589 | 590 | case IDC_WTYPE_AMOVE: 591 | ii = (SendDlgItemMessage(hDlg,IDC_WTYPE_AMOVE,BM_GETCHECK,0,0) == BST_CHECKED) ; 592 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_AMDSK),ii) ; 593 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_AMIMM),ii) ; 594 | break ; 595 | 596 | case IDC_WTYPE_WHIDE: 597 | if((HIWORD(wParam) == CBN_SELCHANGE) && 598 | ((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_WHIDE,CB_GETCURSEL,0,0)) != CB_ERR) && 599 | ((jj=SendDlgItemMessage(hDlg,IDC_WTYPE_THIDE,CB_GETCURSEL,0,0)) != CB_ERR)) 600 | { 601 | if((ii > 0) && (jj == 0)) 602 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_SETCURSEL, 2, 0) ; 603 | else if((ii == 0) && (jj == 1)) 604 | SendDlgItemMessage(hDlg, IDC_WTYPE_THIDE, CB_SETCURSEL, 0, 0) ; 605 | } 606 | break ; 607 | 608 | case IDC_WTYPE_THIDE: 609 | if((HIWORD(wParam) == CBN_SELCHANGE) && 610 | ((ii=SendDlgItemMessage(hDlg,IDC_WTYPE_THIDE,CB_GETCURSEL,0,0)) != CB_ERR) && 611 | ((jj=SendDlgItemMessage(hDlg,IDC_WTYPE_WHIDE,CB_GETCURSEL,0,0)) != CB_ERR)) 612 | { 613 | if((ii == 1) && (jj == 0)) 614 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_SETCURSEL, 2, 0) ; 615 | else if((ii == 0) && (jj != 0)) 616 | SendDlgItemMessage(hDlg, IDC_WTYPE_WHIDE, CB_SETCURSEL, 0, 0) ; 617 | } 618 | break ; 619 | 620 | case IDC_WTYPE_OK: 621 | if(IsWindowEnabled(GetDlgItem(hDlg,IDC_WTYPE_APPLY))) 622 | saveWindowConfig(); 623 | vwWindowRuleReapply(); 624 | EndDialog(hDlg,0); 625 | return TRUE; 626 | 627 | case IDCANCEL: 628 | /* load original config back in */ 629 | loadWindowConfig() ; 630 | EndDialog(hDlg,0); 631 | return TRUE; 632 | 633 | case IDC_WTYPE_APPLY: 634 | saveWindowConfig(); 635 | vwWindowRuleReapply(); 636 | EnableWindow(GetDlgItem(hDlg,IDC_WTYPE_APPLY),FALSE); 637 | break ; 638 | 639 | case IDC_WTYPE_HELP: 640 | showHelp(hDlg,_T("WindowRulesDialog.htm")) ; 641 | break ; 642 | } 643 | break ; 644 | 645 | case WM_UPDATE_DIALOG: 646 | windowRuleFillInitial(hDlg); 647 | break; 648 | 649 | case WM_CLOSE: 650 | /* load original config back in */ 651 | loadWindowConfig() ; 652 | EndDialog(hDlg,0); 653 | return TRUE; 654 | 655 | } 656 | return FALSE; 657 | } 658 | 659 | void 660 | createWindowRuleDialog(HINSTANCE theHinst, HWND theHwndOwner, vwWindowRule *wtype, HWND theWin) 661 | { 662 | if((deskCount = nDesks) < currentDesk) 663 | deskCount = currentDesk ; 664 | winRuleCur = wtype ; 665 | initWin = theWin ; 666 | dialogOpen = TRUE ; 667 | DialogBox(theHinst,MAKEINTRESOURCE(IDD_WINDOWRULEDIALOG),theHwndOwner,(DLGPROC) windowRuleDialogFunc) ; 668 | dialogOpen = FALSE ; 669 | dialogHWnd = NULL ; 670 | } 671 | 672 | 673 | void 674 | updateWindowRuleDialog(HINSTANCE theHinst, HWND theHwndOwner, vwWindowRule *wtype, HWND theWin) { 675 | if ((deskCount = nDesks) < currentDesk) 676 | deskCount = currentDesk; 677 | winRuleCur = wtype; 678 | initWin = theWin; 679 | if (dialogOpen == TRUE) 680 | SendMessage(dialogHWnd, WM_UPDATE_DIALOG, (WPARAM)wtype, 0); 681 | 682 | } -------------------------------------------------------------------------------- /Source/DiskRoutines.c: -------------------------------------------------------------------------------- 1 | // 2 | // VirtuaWin - Virtual Desktop Manager (virtuawin.sourceforge.net) 3 | // DiskRoutines.c - File reading an writing routines. 4 | // 5 | // Copyright (c) 1999-2005 Johan Piculell 6 | // Copyright (c) 2006-2012 VirtuaWin (VirtuaWin@home.se) 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 21 | // USA. 22 | // 23 | 24 | #define _CRT_SECURE_NO_WARNINGS 25 | #define _CRT_NON_CONFORMING_SWPRINTFS 26 | #include "VirtuaWin.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include // for SHGetFolderPath 33 | #include // for mkdir 34 | 35 | #include "DiskRoutines.h" 36 | #include "ConfigParameters.h" 37 | 38 | #ifndef INVALID_FILE_ATTRIBUTES 39 | #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 40 | #endif 41 | #define VIRTUAWIN_SUBDIR vwVIRTUAWIN_NAME 42 | 43 | #define vwWindowRuleDefaultCount 7 44 | static TCHAR *vwWindowRuleDefault0Names[vwWindowRuleDefaultCount]={ 45 | _T("XLMAIN"), 46 | _T("AdobeAcrobat"), 47 | _T("WindowsForms10."), 48 | _T("ExploreWClass"), 49 | _T("IEFrame"), 50 | _T("CabinetWClass"), 51 | _T("BaseBar") 52 | } ; 53 | static vwUInt vwWindowRuleDefaultFlags[vwWindowRuleDefaultCount]={ 54 | (vwWTFLAGS_ENABLED|vwWTFLAGS_MAIN_WIN), 55 | (vwWTFLAGS_ENABLED|vwWTFLAGS_MAIN_WIN), 56 | (vwWTFLAGS_ENABLED|vwWTFLAGS_HIDEWIN_MOVE|vwWTFLAGS_HIDETSK_TOOLWN|vwWTFLAGS_CN_EVAR), 57 | (vwWTFLAGS_ENABLED|vwWTFLAGS_HIDEWIN_MOVE|vwWTFLAGS_HIDETSK_TOOLWN), 58 | (vwWTFLAGS_ENABLED|vwWTFLAGS_HIDEWIN_MOVE|vwWTFLAGS_HIDETSK_TOOLWN), 59 | (vwWTFLAGS_ENABLED|vwWTFLAGS_HIDEWIN_MOVE|vwWTFLAGS_HIDETSK_TOOLWN), 60 | (vwWTFLAGS_ENABLED|vwWTFLAGS_DONT_MANAGE) 61 | } ; 62 | 63 | TCHAR *VirtuaWinPath=NULL ; 64 | TCHAR *UserAppPath=NULL ; 65 | #ifdef _UNICODE 66 | char *VirtuaWinPathStr=NULL ; 67 | char *UserAppPathStr=NULL ; 68 | #endif 69 | 70 | /************************************************** 71 | * Gets the local application settings path for the current user. 72 | * Calling function MUST pre-allocate the return string! 73 | */ 74 | static void getUserAppPath(TCHAR *path) 75 | { 76 | LPITEMIDLIST idList ; 77 | TCHAR buff[MAX_PATH], *ss, *se, cc ; 78 | FILE *fp; 79 | size_t pssSize; 80 | int len ; 81 | 82 | path[0] = '\0' ; 83 | 84 | /* look for a userpath.cfg file */ 85 | _tcscpy_s(buff, 260, VirtuaWinPath); 86 | _tcscat_s(buff, 260, _T("userpath.cfg")); 87 | if ((fp = _tfopen(buff, _T("r"))) != NULL) 88 | { 89 | if((_fgetts(buff,MAX_PATH,fp) == 0) && (buff[0] != '\0')) 90 | { 91 | len = 0 ; 92 | ss = buff ; 93 | while(((cc=*ss++) != '\0') && (cc !='\n')) 94 | { 95 | if((cc == '$') && (*ss == '{') && ((se=_tcschr(ss,'}')) != NULL)) 96 | { 97 | *se++ = '\0' ; 98 | if(!_tcscmp(ss+1,_T("VIRTUAWIN_PATH"))) 99 | ss = VirtuaWinPath ; 100 | else 101 | _tgetenv_s(&pssSize, ss, 260, ss + 1); 102 | if(ss != NULL) 103 | { 104 | _tcscpy_s(path + len, 260, ss); 105 | len += _tcslen(ss) ; 106 | } 107 | ss = se ; 108 | } 109 | else 110 | { 111 | if(cc == '/') 112 | cc = '\\' ; 113 | if((cc != '\\') || (len <= 1) || (path[len-1] != '\\')) 114 | path[len++] = cc ; 115 | } 116 | } 117 | if(len && (path[len-1] != '\\')) 118 | path[len++] = '\\' ; 119 | path[len] = '\0' ; 120 | } 121 | fclose(fp) ; 122 | } 123 | if(path[0] == '\0') 124 | { 125 | if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,CSIDL_APPDATA,&idList)) && (idList != NULL)) 126 | { 127 | IMalloc *im ; 128 | SHGetPathFromIDList(idList,path); 129 | if(SUCCEEDED(SHGetMalloc(&im)) && (im != NULL)) 130 | { 131 | im->lpVtbl->Free(im,idList) ; 132 | im->lpVtbl->Release(im); 133 | } 134 | } 135 | if(path[0] != '\0') 136 | { 137 | len = _tcslen(path) ; 138 | if(path[len - 1] != '\\') 139 | path[len++] = '\\' ; 140 | _tcsncpy_s(path + len, 200, VIRTUAWIN_SUBDIR, MAX_PATH - len); 141 | len += _tcslen(path+len) ; 142 | path[len++] = '\\' ; 143 | path[len] = '\0' ; 144 | } 145 | } 146 | } 147 | 148 | /************************************************ 149 | * Generates a path + username for the requested file type, fills in 150 | * the supplied string parameter, that MUST be pre-allocated. Caller 151 | * is responsible for memory allocation. It is suggested that the 152 | * caller allocate the string on the stack, not dynamically on the 153 | * heap so that it is cleaned up automatically. Strings can be up to 154 | * MAX_PATH in length. 155 | * 156 | * Return is 1 if successful, 0 otherwise. (suggestion, convert to 157 | * type bool after porting to cpp) 158 | */ 159 | 160 | void 161 | GetFilename(eFileNames filetype, int location, TCHAR *outStr) 162 | { 163 | static TCHAR *subPath[vwFILE_COUNT] = { 164 | _T("modules\\*.exe"), _T("virtuawin.chm"), _T("virtuawin.cfg"), _T("window.cfg"), _T("module.cfg") 165 | }; 166 | DWORD len ; 167 | 168 | if(UserAppPath == NULL) 169 | { 170 | /* initialization of paths, find the installation and user paths, 171 | * exit on failure - initialization happens so early on it is safe to 172 | * simply exit */ 173 | TCHAR path[MAX_PATH], *ss ; 174 | 175 | GetModuleFileName(GetModuleHandle(NULL),path,MAX_PATH) ; 176 | ss = _tcsrchr(path,'\\') ; 177 | ss[1] = '\0' ; 178 | if((VirtuaWinPath = _tcsdup(path)) != NULL) 179 | { 180 | getUserAppPath(path) ; 181 | if(path[0] == '\0') 182 | UserAppPath = VirtuaWinPath ; 183 | else 184 | UserAppPath = _tcsdup(path) ; 185 | } 186 | if((VirtuaWinPath == NULL) || (UserAppPath == NULL)) 187 | { 188 | MessageBox(hWnd,_T("Memory resources appear to be very low, try rebooting.\nIf you still have problems, send a mail to \n") vwVIRTUAWIN_EMAIL,vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR); 189 | exit(1); 190 | } 191 | #ifdef _UNICODE 192 | if(WideCharToMultiByte(CP_ACP,0,VirtuaWinPath,-1,(char *) path,MAX_PATH, 0, 0)) 193 | VirtuaWinPathStr = _strdup((char *) path) ; 194 | if(UserAppPath == VirtuaWinPath) 195 | UserAppPathStr = VirtuaWinPathStr ; 196 | else if(WideCharToMultiByte(CP_ACP,0,UserAppPath,-1,(char *) path,MAX_PATH, 0, 0)) 197 | UserAppPathStr = _strdup((char *) path) ; 198 | #endif 199 | } 200 | 201 | _tcsncpy(outStr, (location) ? UserAppPath:VirtuaWinPath, MAX_PATH); 202 | if(filetype < vwFILE_COUNT) 203 | { 204 | len = MAX_PATH - _tcslen(outStr) ; 205 | _tcsncat_s(outStr,260, subPath[filetype],len) ; 206 | } 207 | } 208 | 209 | 210 | /************************************************* 211 | * Loads module names that should be disabled 212 | */ 213 | int 214 | loadDisabledModules(vwDisModule *theDisList) 215 | { 216 | TCHAR buff[MAX_PATH]; 217 | int len, nOfDisMod = 0; 218 | FILE *fp; 219 | 220 | GetFilename(vwMODULE_CFG,1,buff); 221 | 222 | if ((fp = _tfopen(buff, _T("r"))) != NULL) 223 | { 224 | while(_fgetts(buff,MAX_PATH,fp) != NULL) 225 | { 226 | if((len = _tcslen(buff)) > 1) 227 | { 228 | if(len > vwMODULENAME_MAX) 229 | buff[vwMODULENAME_MAX] = '\0' ; 230 | else if(buff[len-1] == '\n') 231 | buff[len-1] = '\0' ; 232 | _tcscpy_s(theDisList[nOfDisMod++].moduleName, 80, buff); 233 | if(nOfDisMod == (MAXMODULES * 2)) 234 | break ; 235 | } 236 | } 237 | fclose(fp); 238 | } 239 | return nOfDisMod; 240 | } 241 | 242 | /************************************************* 243 | * Write out the disabled modules 244 | */ 245 | void 246 | saveDisabledList(int theNOfModules, vwModule *theModList) 247 | { 248 | TCHAR DisabledFileList[MAX_PATH]; 249 | FILE* fp; 250 | 251 | GetFilename(vwMODULE_CFG,1,DisabledFileList); 252 | if ((fp = _tfopen(DisabledFileList, _T("w"))) == NULL) 253 | MessageBox(hWnd,_T("Error saving disabled module state"),vwVIRTUAWIN_NAME _T(" Error"),MB_ICONERROR); 254 | else 255 | { 256 | int i; 257 | for(i = 0; i < theNOfModules; ++i) 258 | if(theModList[i].disabled) 259 | _ftprintf(fp,_T("%s\n"),theModList[i].description); 260 | fclose(fp); 261 | } 262 | } 263 | 264 | /************************************************* 265 | * Reads window rules from window.cfg file 266 | */ 267 | void 268 | loadWindowConfig(void) 269 | { 270 | vwWindowRule *wt, *pwt ; 271 | vwWindow *win ; 272 | TCHAR buff[1024], *ss ; 273 | int ii, ll, mallocErr=0 ; 274 | FILE *fp ; 275 | 276 | if(windowRuleList != NULL) 277 | { 278 | /* free current list first */ 279 | while((wt = windowRuleList) != NULL) 280 | { 281 | windowRuleList = wt->next ; 282 | ii = vwWTNAME_COUNT - 1 ; 283 | do { 284 | if(wt->name[ii] != NULL) 285 | free(wt->name[ii]) ; 286 | } while(--ii >= 0) ; 287 | free(wt) ; 288 | } 289 | 290 | /* set existing vwWindowRules to NULL */ 291 | win = (vwWindow *) windowBaseList ; 292 | while(win != NULL) 293 | { 294 | if (win->flags & vwWINFLAGS_WINDOW) { 295 | win->wt = NULL; 296 | } 297 | win = win->next ; 298 | } 299 | } 300 | 301 | GetFilename(vwWINDOW_CFG,1,buff); 302 | if ((fp = _tfopen(buff, _T("r"))) != 0) 303 | { 304 | pwt = wt = NULL ; 305 | while(_fgetts(buff,1024,fp) != NULL) 306 | { 307 | if(!_tcsncmp(buff,_T("flags# "),7)) 308 | { 309 | /* start of a new windowRule */ 310 | if((wt = calloc(1,sizeof(vwWindowRule))) == NULL) 311 | { 312 | mallocErr = 1 ; 313 | break ; 314 | } 315 | if(pwt == NULL) 316 | windowRuleList = wt ; 317 | else 318 | pwt->next = wt ; 319 | pwt = wt ; 320 | wt->flags = _ttoi(buff+7) ; 321 | } 322 | else if(wt != NULL) 323 | { 324 | if((buff[0] >= '0') && (buff[0] <= '3') && !_tcsncmp(buff+1,_T("n# "),3)) 325 | { 326 | ll = _tcslen(buff+4) ; 327 | if(buff[ll+3] == '\n') 328 | { 329 | buff[ll+3] = '\0' ; 330 | ll-- ; 331 | } 332 | if((ss = _tcsdup(buff+4)) == NULL) 333 | { 334 | mallocErr = 1 ; 335 | break ; 336 | } 337 | ii = buff[0] - '0' ; 338 | wt->name[ii] = ss ; 339 | wt->nameLen[ii] = ll ; 340 | } 341 | else if(!_tcsncmp(buff,_T("desk# "),6) && 342 | ((wt->desk = _ttoi(buff+6)) >= vwDESKTOP_SIZE)) 343 | wt->desk = 0 ; 344 | } 345 | } 346 | fclose(fp) ; 347 | } 348 | else 349 | { 350 | /* no window.cfg file yet create the default */ 351 | ii = vwWindowRuleDefaultCount ; 352 | while(--ii >= 0) 353 | { 354 | if(((wt = calloc(1,sizeof(vwWindowRule))) == NULL) || 355 | ((wt->name[0] = _tcsdup(vwWindowRuleDefault0Names[ii])) == NULL)) 356 | { 357 | mallocErr = 1 ; 358 | break ; 359 | } 360 | wt->nameLen[0] = _tcslen(vwWindowRuleDefault0Names[ii]) ; 361 | wt->flags = vwWindowRuleDefaultFlags[ii] ; 362 | wt->next = windowRuleList ; 363 | windowRuleList = wt ; 364 | } 365 | } 366 | if(mallocErr) 367 | MessageBox(hWnd,_T("System resources are low, failed to load configuration."),vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR); 368 | } 369 | 370 | /************************************************* 371 | * Writes the window rule list to window.cfg file 372 | */ 373 | void 374 | saveWindowConfig(void) 375 | { 376 | TCHAR fname[MAX_PATH]; 377 | vwWindowRule *wt; 378 | FILE *fp = NULL; 379 | int ii ; 380 | 381 | GetFilename(vwWINDOW_CFG,1,fname); 382 | if ((fp = _tfopen(fname, _T("w"))) == NULL) { 383 | wchar_t buff[40]; 384 | _stprintf(buff, _T("Error writing %s. \nReason: %s"), fname, _tcserror(errno) ); 385 | MessageBox(NULL, buff, vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR); 386 | } 387 | else 388 | { 389 | wt = windowRuleList ; 390 | while(wt != NULL) 391 | { 392 | fprintf(fp, "flags# %d\n", wt->flags); 393 | for(ii=0 ; iiname[ii] != NULL) 395 | _ftprintf(fp,_T("%dn# %s\n"),ii,wt->name[ii]); 396 | if(wt->desk > 0) 397 | fprintf(fp, "desk# %d\n", wt->desk); 398 | wt = wt->next ; 399 | } 400 | fclose(fp); 401 | } 402 | } 403 | 404 | /************************************************* 405 | * Reads a saved configuration from file 406 | */ 407 | /* Get the list of hotkey commands */ 408 | #define VW_COMMAND(a, b, c, d) a = b , 409 | enum { 410 | #include "vwCommands.def".desk = 411 | } ; 412 | #undef VW_COMMAND 413 | 414 | /* horrible macro, used as it makes the code more legible - use with care! */ 415 | #define vwConfigReadInt(fp,buff,tmpI,var) if(fscanf_s(fp, "%s%i", (char *) (buff), 2048, &(tmpI)) == 2) (var) = (tmpI) 416 | 417 | static void 418 | addOldHotkey(int key, int mod, int win, int cmd, int desk) 419 | { 420 | if(key != 0) 421 | { 422 | hotkeyList[hotkeyCount].key = (vwUByte) key ; 423 | hotkeyList[hotkeyCount].modifier = 0 ; 424 | if(mod & HOTKEYF_ALT) 425 | hotkeyList[hotkeyCount].modifier |= vwHOTKEY_ALT ; 426 | if(mod & HOTKEYF_CONTROL) 427 | hotkeyList[hotkeyCount].modifier |= vwHOTKEY_CONTROL; 428 | if(mod & HOTKEYF_SHIFT) 429 | hotkeyList[hotkeyCount].modifier |= vwHOTKEY_SHIFT; 430 | if(mod & HOTKEYF_EXT) 431 | hotkeyList[hotkeyCount].modifier |= vwHOTKEY_EXT; 432 | if(win) 433 | hotkeyList[hotkeyCount].modifier |= vwHOTKEY_WIN; 434 | hotkeyList[hotkeyCount].command = (vwUByte) cmd ; 435 | hotkeyList[hotkeyCount].desk = (vwUByte) desk ; 436 | hotkeyCount++ ; 437 | } 438 | } 439 | 440 | void 441 | loadVirtuawinConfig(void) 442 | { 443 | TCHAR buff[MAX_PATH], buff2[2048], err[40], * ss; 444 | FILE *fp = NULL, *wfp = NULL; 445 | int ii, jj, ll, hk[4] ; 446 | 447 | GetFilename(vwVIRTUAWIN_CFG,1,buff); 448 | if(GetFileAttributes(buff) == INVALID_FILE_ATTRIBUTES) 449 | { 450 | static char *defaultCfg="ver# 2\nhotkeyCount# 6\nhotkey1# 37 19 1 0\nhotkey2# 39 19 2 0\nhotkey3# 38 19 3 0\nhotkey4# 40 19 4 0\nhotkey5# 37 25 13 0\nhotkey6# 39 25 15 0\ndesktopNameCount# 0\n" ; 451 | /* config file does not exist - new user, setup configuration, check 452 | * the user path exists first and if not try to create it - note that 453 | * multiple levels may need to be created due to the userpath.cfg */ 454 | if((buff[0] == '\\') && (buff[1] == '\\') && ((ss = _tcschr(buff+2,'\\')) != NULL) && (ss[1] != '\0')) 455 | ; 456 | else if(buff[1] == ':') 457 | ss = buff + 2 ; 458 | else 459 | ss = buff ; 460 | while((ss = _tcschr(ss+1,'\\')) != NULL) 461 | { 462 | *ss = '\0' ; 463 | if(((GetFileAttributes(buff) & (0xf0000000|FILE_ATTRIBUTE_DIRECTORY)) != FILE_ATTRIBUTE_DIRECTORY) && 464 | (CreateDirectory(buff,NULL) == 0)) 465 | { 466 | _stprintf_s(buff2,2048, vwVIRTUAWIN_NAME _T(" cannot create the user config directory:\n\n %s\n\nPlease check file permissions. If you continue to have problems, send e-mail to:\n\n ") vwVIRTUAWIN_EMAIL,buff); 467 | MessageBox(hWnd,buff2,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONERROR); 468 | exit(1) ; 469 | } 470 | *ss = '\\' ; 471 | } 472 | 473 | /* If the user path is not the installation path then copy all the 474 | * config files across to the user area */ 475 | fp = NULL ; 476 | ii = vwFILE_COUNT ; 477 | if (_tcsicmp(VirtuaWinPath, UserAppPath)) 478 | { 479 | while (--ii >= vwVIRTUAWIN_CFG) 480 | { 481 | 482 | GetFilename(ii, 0, buff); 483 | OutputDebugString(_T("Trying to open ")); 484 | OutputDebugString(buff); 485 | OutputDebugString(_T("\n")); 486 | if ((fp = _tfopen(buff, _T("rb"))) != 0) 487 | { 488 | GetFilename(ii, 1, buff2); 489 | OutputDebugString(_T("\nTrying to create ")); 490 | OutputDebugString(buff2); 491 | OutputDebugString(_T("\n")); 492 | if ((wfp = _tfopen(buff2, _T("wb"))) == 0) 493 | break; 494 | OutputDebugString(_T("Copying new file.\n")); 495 | for (;;) 496 | { 497 | 498 | 499 | if ((jj = fread(buff2, 1, 2048, fp)) <= 0) 500 | break; 501 | if (fwrite(buff2, 1, jj, wfp) != (size_t)jj) 502 | { 503 | jj = -1; 504 | break; 505 | } 506 | } 507 | fclose(fp); 508 | if ((fclose(wfp) != 0) || (jj < 0)) 509 | break; 510 | } 511 | else { 512 | _tcserror_s(err, 40, errno); 513 | _stprintf_s(buff2, 2048, _T("Could not open. Reason: %s"), err); 514 | OutputDebugString(buff2); 515 | } 516 | } 517 | } 518 | else 519 | { 520 | /* must create the main VirtuaWin.cfg file */ 521 | ii = vwVIRTUAWIN_CFG - 1 ; 522 | fp = NULL ; 523 | } 524 | GetFilename(vwVIRTUAWIN_CFG,1,buff); 525 | /* check a main config file has been copied, if not create a dummy one */ 526 | 527 | _stprintf_s(buff2, 20, _T("ii = %i"), ii); 528 | if ((ii < vwVIRTUAWIN_CFG) && (fp == NULL)) { 529 | if ((wfp = _tfopen(buff, _T("wb"))) != 0) { 530 | size_t written = fwrite(defaultCfg, strlen(defaultCfg), 1, wfp); 531 | if (written > 1) { 532 | if (fclose(wfp) != 0) { 533 | ii = vwVIRTUAWIN_CFG; 534 | _stprintf_s(buff2, 20, _T("No error!")); 535 | } 536 | else { 537 | _stprintf_s(buff2, 20, _T("Error closing file")); 538 | } 539 | } 540 | else { 541 | _stprintf_s(buff2, 20, _T("Error writing file")); 542 | } 543 | } 544 | else { 545 | _stprintf_s(buff2, 20, _T("Error opening file")); 546 | } 547 | } 548 | 549 | 550 | 551 | 552 | /* check we did not break out due to an error and virtuawin.cfg was found */ 553 | if (ii >= vwVIRTUAWIN_CFG) 554 | { 555 | _stprintf_s(buff2, 2048, _T("Error creating new user configuration, please check installation & file permissions.\nIf you continue to have problems, send e-mail to:\n\n " vwVIRTUAWIN_EMAIL), buff2); 556 | MessageBox(hWnd, buff2, vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR); 557 | exit(1); 558 | } 559 | _stprintf_s(buff2,2048, _T("Welcome to %s\n\nA new user configuration has been created in directory:\n\n %s\n\nRight click on tray icon to access the Setup dialog."),vwVIRTUAWIN_NAME_VERSION,UserAppPath) ; 560 | MessageBox(hWnd,buff2,vwVIRTUAWIN_NAME,MB_ICONINFORMATION); 561 | } 562 | 563 | 564 | /* Is file readable at all? */ 565 | if ((fp = _tfopen(buff, _T("r"))) == 0) 566 | { 567 | _tcserror_s(err, 40, errno); 568 | _stprintf_s(buff2,2048, _T("Error reading config file:\n\n %s\n\nReason: %s.\n\n If you continue to have problems, send e-mail to:\n\n ") vwVIRTUAWIN_EMAIL,buff, err); 569 | MessageBox(hWnd,buff2,vwVIRTUAWIN_NAME _T(" Error"),MB_ICONERROR) ; 570 | exit(1) ; 571 | } 572 | /* Try readying the first line which is either a version or mouseDelay if pre-v4 */ 573 | if(fscanf(fp, "%s%d", (char *) buff2, &ii) != 2) 574 | { 575 | fclose(fp); 576 | _stprintf_s(buff2,2048, _T("Error reading config file:\n\n %s\n\nFile empty or corrupt, please remove."), buff); 577 | MessageBox(hWnd, buff2, vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR) ; 578 | exit(1) ; 579 | } 580 | /* Is it a version line? */ 581 | if(strcmp((char *) buff2,"ver#")) 582 | { 583 | /* Nope, there was no version */ 584 | int kk, hkc[5], hks[3] ; 585 | 586 | mouseEnable = ii ; 587 | hotkeyCount = 0 ; 588 | vwConfigReadInt(fp,buff2,ii,mouseDelay); 589 | fscanf(fp, "%s%i", (char *) buff, &jj); 590 | vwConfigReadInt(fp,buff,ii,releaseFocus); 591 | fscanf(fp, "%s%i", (char *) buff, &ii); 592 | fscanf(fp, "%s%i", (char *) buff, hk + 0); 593 | fscanf(fp, "%s%i", (char *) buff, hk + 1); 594 | fscanf(fp, "%s%i", (char *) buff, hk + 2); 595 | fscanf(fp, "%s%i", (char *) buff, hk + 3); 596 | if(jj) 597 | { 598 | jj = hk[0] | hk[1] | hk[2] | hk[3] | vwHOTKEY_EXT ; 599 | ii = 3 ; 600 | do { 601 | hotkeyList[ii].modifier = jj ; 602 | hotkeyList[ii].command = vwCMD_NAV_MOVE_LEFT + ii ; 603 | hotkeyList[ii].desk = 0 ; 604 | } while(--ii >= 0) ; 605 | hotkeyList[0].key = VK_LEFT ; 606 | hotkeyList[1].key = VK_RIGHT ; 607 | hotkeyList[2].key = VK_UP ; 608 | hotkeyList[3].key = VK_DOWN ; 609 | hotkeyCount = 4 ; 610 | } 611 | vwConfigReadInt(fp,buff,ii,mouseJumpLength); 612 | fscanf(fp, "%s%i", (char *) buff, &ii); 613 | fscanf(fp, "%s%i", (char *) buff, &ii); 614 | vwConfigReadInt(fp,buff,ii,nDesksY); 615 | vwConfigReadInt(fp,buff,ii,nDesksX); 616 | fscanf(fp, "%s%i", (char *) buff, &ii); 617 | for(ii=1,jj=9,kk=0 ; ii<=jj ; ii++) 618 | { 619 | fscanf(fp, "%s%i", (char *) buff, hk + 1); 620 | if((ii==1) && !strcmp((char *) buff,"Desk_count#")) 621 | { 622 | jj = hk[1] ; 623 | hk[1] = 0 ; 624 | ii = 0 ; 625 | kk = 1 ; 626 | } 627 | else 628 | { 629 | fscanf(fp, "%s%i", (char *) buff, hk + 2); 630 | fscanf(fp, "%s%i\n", (char *) buff, hk + 3); 631 | if(hk[1]) 632 | addOldHotkey(hk[1],hk[2],hk[3],vwCMD_NAV_MOVE_DESKTOP,ii) ; 633 | if(kk && (_fgetts(buff2,2048,fp) != NULL) && ((ss=_tcschr(buff2,' ')) != NULL) && 634 | ((ll=_tcslen(++ss)) > 1)) 635 | { 636 | if(ss[ll-1] == '\n') 637 | ss[ll-1] = '\0' ; 638 | desktopName[ii] = _tcsdup(ss) ; 639 | } 640 | } 641 | } 642 | vwConfigReadInt(fp,buff,ii,mouseModifierUsed); 643 | if(fscanf(fp, "%s%i", (char *) buff, &ii) == 2) 644 | mouseModifier = 0 ; 645 | if(ii) mouseModifier |= vwHOTKEY_ALT ; 646 | fscanf(fp, "%s%i", (char *) buff, &ii); 647 | if(ii) mouseModifier |= vwHOTKEY_SHIFT ; 648 | fscanf(fp, "%s%i", (char *) buff, &ii); 649 | if(ii) mouseModifier |= vwHOTKEY_CONTROL ; 650 | fscanf(fp, "%s%i", (char *) buff, &ii); 651 | vwConfigReadInt(fp,buff,ii,refreshOnWarp); 652 | if(fscanf(fp, "%s%d", (char *) buff, &ii) == 2) 653 | mouseWarp = (ii == 0) ; 654 | fscanf(fp, "%s%i", (char *) buff, hks + 0); 655 | fscanf(fp, "%s%i", (char *) buff, hks + 1); 656 | vwConfigReadInt(fp,buff,ii,preserveZOrder); 657 | vwConfigReadInt(fp,buff,ii,deskWrap); 658 | vwConfigReadInt(fp,buff,ii,invertY); 659 | if(fscanf(fp, "%s%i", (char *) buff, &ii) == 2) 660 | winListContent = 0 ; 661 | if(ii) winListContent |= vwWINLIST_STICKY ; 662 | fscanf(fp, "%s%i", (char *) buff, &ii); 663 | if(ii) winListContent |= vwWINLIST_ASSIGN ; 664 | fscanf(fp, "%s%i", (char *) buff, &ii); 665 | if(ii) winListContent |= vwWINLIST_ACCESS ; 666 | fscanf(fp, "%s%i", (char *) buff, &ii); 667 | fscanf(fp, "%s%i", (char *) buff, &ii); 668 | fscanf(fp, "%s%i", (char *) buff, &ii); 669 | fscanf(fp, "%s%i", (char *) buff, hkc + 0); 670 | fscanf(fp, "%s%i", (char *) buff, hkc + 1); 671 | fscanf(fp, "%s%i", (char *) buff, hkc + 2); 672 | fscanf(fp, "%s%i", (char *) buff, hkc + 3); 673 | fscanf(fp, "%s%i", (char *) buff, hkc + 4); 674 | fscanf(fp, "%s%i", (char *) buff, hk + 0); 675 | fscanf(fp, "%s%i", (char *) buff, hk + 1); 676 | fscanf(fp, "%s%i", (char *) buff, hk + 2); 677 | fscanf(fp, "%s%i", (char *) buff, hk + 3); 678 | if(hk[0]) 679 | { 680 | kk = hotkeyCount ; 681 | addOldHotkey(hk[1],hk[2],hk[3],vwCMD_UI_WINLIST_STD,0) ; 682 | } 683 | else 684 | kk = -1 ; 685 | vwConfigReadInt(fp,buff,ii,displayTaskbarIcon); 686 | fscanf(fp, "%s%i", (char *) buff, hks + 2); 687 | vwConfigReadInt(fp,buff,ii,noTaskbarCheck); 688 | fscanf(fp, "%s%i", (char *) buff, &ii); 689 | fscanf(fp, "%s%i", (char *) buff, &ii); 690 | fscanf(fp, "%s%i", (char *) buff, &ii); 691 | fscanf(fp, "%s%i", (char *) buff, &ii); 692 | fscanf(fp, "%s%i", (char *) buff, &jj); 693 | if(hkc[0]) 694 | { 695 | addOldHotkey(hkc[1],hkc[2],ii,vwCMD_NAV_MOVE_NEXT,0) ; 696 | addOldHotkey(hkc[3],hkc[4],jj,vwCMD_NAV_MOVE_PREV,0) ; 697 | } 698 | fscanf(fp, "%s%i", (char *) buff, &ii); 699 | if(ii) 700 | addOldHotkey(hks[1],hks[0],hk[2],vwCMD_WIN_STICKY,0) ; 701 | fscanf(fp, "%s%i", (char *) buff, &ii); 702 | fscanf(fp, "%s%i", (char *) buff, &ii); 703 | fscanf(fp, "%s%i", (char *) buff, &ii); 704 | fscanf(fp, "%s%i", (char *) buff, &ii); 705 | vwConfigReadInt(fp,buff,ii,hiddenWindowAct); 706 | fscanf(fp, "%s%i", (char *) buff, &ii); 707 | fscanf(fp, "%s%i", (char *) buff, hk + 0); 708 | fscanf(fp, "%s%i", (char *) buff, hk + 1); 709 | fscanf(fp, "%s%i", (char *) buff, hk + 2); 710 | fscanf(fp, "%s%i", (char *) buff, hk + 3); 711 | if(hk[0]) 712 | addOldHotkey(hk[1],hk[2],hk[3],vwCMD_WIN_DISMISS,0) ; 713 | vwConfigReadInt(fp,buff,ii,vwLogFlag); 714 | vwConfigReadInt(fp,buff,ii,mouseKnock); 715 | vwConfigReadInt(fp,buff,ii,winListCompact); 716 | if(winListCompact && (kk >= 0)) 717 | hotkeyList[kk].command = vwCMD_UI_WINMENU_CMP ; 718 | fscanf(fp, "%s%i", (char *) buff, hk + 0); 719 | fscanf(fp, "%s%i", (char *) buff, hk + 1); 720 | fscanf(fp, "%s%i", (char *) buff, hk + 2); 721 | fscanf(fp, "%s%i", (char *) buff, hk + 3); 722 | if(hk[0]) 723 | addOldHotkey(hk[1],hk[2],hk[3],vwCMD_UI_WINMENU_STD,0) ; 724 | fscanf(fp, "%s%i", (char *) buff, &ii); 725 | if(ii) winListContent |= vwWINLIST_SHOW ; 726 | } 727 | else if(ii == 2) 728 | { 729 | /* read the hotkeys and desktop names */ 730 | hotkeyCount = 0 ; 731 | fscanf(fp, "%s%d", (char *) buff, &jj); 732 | for(ii=0 ; ii= 0) 745 | { 746 | if(desktopName[ii] != NULL) 747 | { 748 | free(desktopName[ii]) ; 749 | desktopName[ii] = NULL ; 750 | } 751 | } 752 | fscanf(fp, "%s%d\n", (char *) buff, &jj); 753 | for(ii=1 ; ii<=jj ; ii++) 754 | { 755 | if((_fgetts(buff2,2048,fp) != NULL) && ((ss=_tcschr(buff2,' ')) != NULL) && 756 | ((ll=_tcslen(++ss)) > 1)) 757 | { 758 | if(ss[ll-1] == '\n') 759 | ss[ll-1] = '\0' ; 760 | desktopName[ii] = _tcsdup(ss) ; 761 | } 762 | } 763 | /* now read all the simple flags */ 764 | vwConfigReadInt(fp,buff,ii,nDesksX); 765 | vwConfigReadInt(fp,buff,ii,nDesksY); 766 | vwConfigReadInt(fp,buff,ii,deskWrap); 767 | vwConfigReadInt(fp,buff,ii,useWindowRules); 768 | vwConfigReadInt(fp,buff,ii,taskButtonAct); 769 | vwConfigReadInt(fp,buff,ii,winListContent); 770 | vwConfigReadInt(fp,buff,ii,winListCompact); 771 | vwConfigReadInt(fp,buff,ii,mouseEnable); 772 | vwConfigReadInt(fp,buff,ii,mouseJumpLength); 773 | vwConfigReadInt(fp,buff,ii,mouseDelay); 774 | vwConfigReadInt(fp,buff,ii,mouseWarp); 775 | vwConfigReadInt(fp,buff,ii,mouseKnock); 776 | vwConfigReadInt(fp,buff,ii,mouseModifierUsed); 777 | vwConfigReadInt(fp,buff,ii,mouseModifier); 778 | vwConfigReadInt(fp,buff,ii,preserveZOrder); 779 | vwConfigReadInt(fp,buff,ii,hiddenWindowAct); 780 | vwConfigReadInt(fp,buff,ii,releaseFocus); 781 | vwConfigReadInt(fp,buff,ii,refreshOnWarp); 782 | vwConfigReadInt(fp,buff,ii,invertY); 783 | vwConfigReadInt(fp,buff,ii,noTaskbarCheck); 784 | vwConfigReadInt(fp,buff,ii,displayTaskbarIcon); 785 | vwConfigReadInt(fp,buff,ii,vwLogFlag); 786 | vwConfigReadInt(fp,buff,ii,winMenuCompact); 787 | vwConfigReadInt(fp,buff,ii,useDynButtonRm); 788 | vwConfigReadInt(fp,buff,ii,hotkeyMenuLoc); 789 | vwConfigReadInt(fp, buff, ii, aggressiveRules); 790 | vwConfigReadInt(fp,buff,ii,vwHookUse); 791 | vwConfigReadInt(fp,buff,ii,useDskChgModRelease); 792 | vwConfigReadInt(fp,buff,ii,initialDesktop); 793 | vwConfigReadInt(fp,buff,ii,lastDeskNoDelay); 794 | vwConfigReadInt(fp,buff,ii,minWinHide); 795 | vwConfigReadInt(fp,buff,ii,ctlMenuCompact); 796 | } 797 | else 798 | { 799 | fclose(fp); 800 | _stprintf_s(buff2,2048, _T("Error reading config file:\n\n %s\n\nUnsupported version %d, please remove."), buff, ii); 801 | MessageBox(hWnd, buff2, vwVIRTUAWIN_NAME _T(" Error"), MB_ICONERROR) ; 802 | exit(1); 803 | } 804 | 805 | nDesks = nDesksX * nDesksY ; 806 | fclose(fp); 807 | } 808 | 809 | /************************************************ 810 | * Writes down the current configuration on file 811 | */ 812 | void 813 | saveVirtuawinConfig(void) 814 | { 815 | TCHAR VWConfigFile[MAX_PATH]; 816 | FILE* fp; 817 | int ii, jj ; 818 | 819 | GetFilename(vwVIRTUAWIN_CFG,1,VWConfigFile); 820 | if ((fp = _tfopen(VWConfigFile, _T("w"))) == 0) 821 | { 822 | MessageBox(NULL,_T("Error writing virtuawin.cfg file"),vwVIRTUAWIN_NAME _T(" Error"),MB_ICONERROR); 823 | } 824 | else 825 | { 826 | fprintf(fp, "ver# 2\n") ; 827 | fprintf(fp, "hotkeyCount# %d\n", hotkeyCount); 828 | for(ii=0 ; ii