1: /*
2: ============================================================================
3: xoblite™ -> an advanced "extended shell" for Microsoft® Windows® 11
4: Copyright © 2002-2026 Karl Henrik Henriksson [qwilk/@xoblite]
5: Copyright © 2001-2004 The Blackbox for Windows Development Team
6: http://xoblite.net/ + https://github.com/xoblite/
7: ============================================================================
8:
9: Blackbox for Windows is free software, released under the
10: GNU General Public License (GPL version 2 or later), with an extension
11: that allows linking of proprietary modules under a controlled interface.
12: What this means is that plugins etc. are allowed to be released
13: under any license the author wishes. Please note, however, that the
14: original Blackbox gradient math code used in Blackbox for Windows
15: is available under the BSD license.
16:
17: http://www.fsf.org/licenses/gpl.html
18: http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface
19: http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
20:
21: This program is distributed in the hope that it will be useful,
22: but WITHOUT ANY WARRANTY; without even the implied warranty of
23: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24: GNU General Public License for more details.
25:
26: For additional license information, please read the included license.html.
27:
28: ============================================================================
29: */
30:
31: #ifndef __TASKBAR_H
32: #define __TASKBAR_H
33:
34: #include "..\API\BBApi.h"
35: #include "..\Desktop\Desktop.h"
36: #include "..\Settings\Settings.h"
37: #include "..\Plugins\PluginManager.h"
38: #include "..\Resources\resource.h"
39: #include <dwmapi.h>
40: #include <vector>
41: #include <algorithm>
42: #include <psapi.h>
43:
44: //===========================================================================
45:
46: typedef struct taskListItem
47: {
48: HWND hwnd;
49: // HICON icon;
50: RECT r; // The task item's rect on the Toolbar taskbar
51: bool active;
52: int workspace; // Note: Still work in progress reworking of Taskbar vs Workspaces code...
53: // bool sticky; // Note: Still work in progress reworking of Taskbar vs Workspaces code...
54: bool hidden;
55: bool isAppPlugin;
56: char path[MAX_PATH];
57: char captionANSI[265]; // -> 255+10 chars (the latter used only for some specific internal use cases)
58: wchar_t captionUnicode[265]; // ...
59: int lastUsed; // -> This is reset to 0 when an item is added or activated, and increased when another item is is added or activated, creating a sortable list of "last used apps"
60: DWORD priorityClass;
61: Placement dimensions; // This is used e.g. when moving between tiled and non-tiled ("floating") window states. Re-using the Placement struct for this made sense here as tiling options are similar to regular placement options.
62: } taskListItem;
63:
64: //====================
65:
66: class Taskbar
67: {
68: public:
69: Taskbar();
70: ~Taskbar();
71:
72: void InitializeTaskList();
73: friend BOOL CALLBACK TaskEnumerator(HWND window, LPARAM main);
74:
75: void AddTask(HWND newWindow);
76: void RemoveTask(HWND oldWindow);
77: int FindTask(HWND window);
78: void CheckTaskListIntegrity();
79:
80: void SetActiveTask(HWND activeWindow);
81: int GetActiveTask();
82: HWND GetActiveWindow();
83: void RedrawTask(HWND window);
84:
85: void ActivateShellWindow();
86: void MinimizeAllWindows();
87: void RestoreAllWindows();
88:
89: int DropFiles(HWND hwnd, WPARAM wParam, bool checkTaskbarDrop);
90:
91: bool MouseButtonOnTaskbar(HWND hwnd, unsigned int message, WPARAM wParam, LPARAM lParam);
92: void MouseHoveringOverTaskbar(HWND hwnd, unsigned int message, WPARAM wParam, LPARAM lParam);
93:
94: void DrawTaskbar(HDC hdc, int iconPos, RECT taskbarRect);
95: int DrawTaskButtons(HDC hdc);
96:
97: void ChangeTaskbarMode(int mode);
98:
99: void ToggleCurrentOnly();
100: bool OnCurrentWorkspace(HWND window);
101: int GetTaskButtonsToDraw();
102: int GetTaskbarScrollIndicatorSizes(int* leftTopPadding, int* rightBottomPadding);
103: bool CheckCloakedWindow(HWND hwnd);
104:
105: int FindFirstVisible();
106: int FindLastVisible(int offset);
107:
108: void NextTask(bool currentWorkspaceOnly, bool visibleOnly);
109: void PreviousTask(bool currentWorkspaceOnly, bool visibleOnly);
110:
111: void SortTaskbarItems(int mode);
112: static bool CompareTaskbarItemsByLastUsed(taskListItem* t1, taskListItem* t2);
113: //static bool CompareTaskbarItemsByName(taskListItem* t1, taskListItem* t2);
114:
115: void TileWindow(int placement);
116:
117: //====================
118:
119: HWND hBlackboxWnd; // Blackbox window handle
120:
121: HDC cachedTaskButtonActive;
122: HDC cachedTaskButtonInactive;
123: bool cachedTaskButtonsExist;
124:
125: //====================
126:
127: RECT TaskbarRect;
128:
129: POINT taskbarMouseHoverPoint;
130:
131: bool activeTaskAvailable;
132: RECT ActiveTaskRect;
133: int lastHoveredTaskButton;
134:
135: RECT currentTaskButton;
136: HWND currentTaskButtonWnd;
137: HICON currentTaskButtonIcon;
138: // char currentTaskButtonWindowText[MAX_LINE_LENGTH];
139:
140: int iconSize;
141: RECT iconRect, textRect;
142:
143: int taskButtonWidth, taskButtonWidthMinusPadding, taskButtonHeight, taskButtonHeightMinusPadding;
144:
145: int taskButtonsToDraw; // All workspaces or current workspace only
146: int taskButtonsOffset;
147:
148: HWND flashingHwnd;
149:
150: // typedef vector<taskListItem*> taskListVector;
151: // taskListVector taskList;
152: vector<taskListItem*> taskList;
153:
154: bool enumeratingTasks;
155:
156: bool blockNextMouseClick;
157: };
158:
159: //===========================================================================
160:
161: #endif /* __TASKBAR_H */
162: