Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
CSaratakij committed Aug 19, 2018
2 parents f2e3ed5 + 0ee87bf commit 4ff49c7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Keybind.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[ Mod + 7 ] - Switch to Workspace 7
[ Mod + 8 ] - Switch to Workspace 8
[ Mod + 9 ] - Switch to Workspace 9
[ Mod + 10 ] - Switch to Workspace 10
[ Mod + 0 ] - Switch to Workspace 10
[ Mod + Shift + 1 ] - Move window to workspace 1
[ Mod + Shift + 2 ] - Move window to workspace 2
[ Mod + Shift + 3 ] - Move window to workspace 3
Expand All @@ -34,6 +34,6 @@
[ Mod + Shift + 7 ] - Move window to workspace 7
[ Mod + Shift + 8 ] - Move window to workspace 8
[ Mod + Shift + 9 ] - Move window to workspace 9
[ Mod + Shift + 10 ] - Move window to workspace 10
[ Mod + Shift + 0 ] - Move window to workspace 10
[ Mod + F12 ] - Toggle Explorer Shell's Taskbar
```
65 changes: 45 additions & 20 deletions MyWinTiles/MyWinTiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define MAX_LOADSTRING 100

HWND bar = NULL;
HWND appbar = NULL;

int currentFocusIndice[MAX_WORKSPACE];
int totalWindowInWorkspace[MAX_WORKSPACE];
Expand Down Expand Up @@ -68,9 +68,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
case HSHELL_WINDOWCREATED:
{
HWND hWnd = (HWND)msg.lParam;
bar = FindWindow(_T(APPBAR_WINDOW_CLASS), NULL);
appbar = FindWindow(_T(APPBAR_WINDOW_CLASS), NULL);

if (bar != NULL && bar == hWnd)
if (appbar != NULL && appbar == hWnd)
break;

if (!IsWindow(hWnd) && IsValidWindow(hWnd))
Expand Down Expand Up @@ -107,25 +107,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,

case HSHELL_RUDEAPPACTIVATED:
{
HWND hWnd = (HWND) msg.lParam;
SendCurrentFocusWindowThroughIPC(msg.hwnd, hWnd);

if (isFocusByHotkey) {
isFocusByHotkey = FALSE;
break;
}

HWND hWnd = (HWND) msg.lParam;

int indice = currentFocusIndice[currentWorkSpace - 1];
HWND* currentAry = GetWorkspaceByID(currentWorkSpace);

if (hWnd != currentAry[indice]) {
for (UINT i = 0; i < MAX_WORKSPACE; ++i) {
if (currentAry[i] == hWnd) {
currentFocusIndice[currentWorkSpace - 1] = i;
break;
}
}
}

UpdateFocusIndice(currentWorkSpace, hWnd);
break;
}

Expand Down Expand Up @@ -1081,9 +1071,9 @@ void SwapCurrentFocusWindow(UINT workspace, UINT swapType)
void SendCurrentWorkspaceThroughIPC(HWND hWnd)
{
ULONG updateCurrentWorkspace = 1;
HWND testbar = FindWindow(_T(APPBAR_WINDOW_CLASS), NULL);
appbar = FindWindow(_T(APPBAR_WINDOW_CLASS), NULL);

if (testbar == NULL)
if (appbar == NULL)
return;

COPYDATASTRUCT data;
Expand All @@ -1092,7 +1082,24 @@ void SendCurrentWorkspaceThroughIPC(HWND hWnd)
data.cbData = sizeof(UINT);
data.lpData = &currentWorkSpace;

SendMessage(testbar, WM_COPYDATA, (WPARAM) hWnd, (LPARAM)(LPVOID) &data);
SendMessage(appbar, WM_COPYDATA, (WPARAM) hWnd, (LPARAM)(LPVOID) &data);
}

void SendCurrentFocusWindowThroughIPC(HWND currentWindow, HWND focusWindow)
{
ULONG updateFocusWindow = 2;
appbar = FindWindow(_T(APPBAR_WINDOW_CLASS), NULL);

if (appbar == NULL)
return;

COPYDATASTRUCT data;

data.dwData = updateFocusWindow;
data.cbData = sizeof(HWND);
data.lpData = &focusWindow;

SendMessage(appbar, WM_COPYDATA, (WPARAM) currentWindow, (LPARAM)(LPVOID) &data);
}

void ToggleWindow(HWND hWnd)
Expand All @@ -1105,3 +1112,21 @@ void ToggleWindow(HWND hWnd)
else
ShowWindow(hWnd, SW_SHOW);
}

void UpdateFocusIndice(UINT workspaceID, HWND hWnd)
{
if (workspaceID > MAX_WORKSPACE)
return;

int indice = currentFocusIndice[workspaceID - 1];
HWND* currentAry = GetWorkspaceByID(workspaceID);

if (hWnd != currentAry[indice]) {
for (UINT i = 0; i < MAX_WORKSPACE; ++i) {
if (currentAry[i] == hWnd) {
currentFocusIndice[workspaceID - 1] = i;
break;
}
}
}
}
3 changes: 2 additions & 1 deletion MyWinTiles/MyWinTiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ void RefreshWorkspace(UINT);
void UpdateTotalWindowInWorkspace(UINT);
void SwapCurrentFocusWindow(UINT, UINT);
void SendCurrentWorkspaceThroughIPC(HWND);
void SendCurrentFocusWindowThroughIPC(HWND, HWND);
void ToggleWindow(HWND);

void UpdateFocusIndice(UINT, HWND);
Binary file modified MyWinTiles/MyWinTiles.rc
Binary file not shown.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ NoWinKeys REG_DWORD 0x00000001 (1)

# Additional
- You might want to use [MyWinBar](https://github.com/CSaratakij/MyWinBar), an AppBar for MyWinTiles.
- You might want to use [Wox](https://github.com/Wox-launcher/Wox), an alternative App Launcher of choice for MyWinTiles.
Use with [Optional Disable Key](optinal_disable_keys.ahk) for convenience.

# Issue
- Test with Windows 10 (Other windows version don't officially support.)
Expand All @@ -33,3 +35,4 @@ NoWinKeys REG_DWORD 0x00000001 (1)

# License
- [GNU GPLv3](LICENSE)

2 changes: 2 additions & 0 deletions optinal_disable_keys.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
~LWin Up::Return
^[::Send {Esc}

0 comments on commit 4ff49c7

Please sign in to comment.