ReactOS  0.4.14-dev-52-g6116262
appswitch.c File Reference
#include <user32.h>
Include dependency graph for appswitch.c:

Go to the source code of this file.

Macros

#define DIALOG_MARGIN   8
 
#define CX_ICON   32
 
#define CY_ICON   32
 
#define ICON_MARGIN   4
 
#define CX_ITEM   (CX_ICON + 2 * ICON_MARGIN)
 
#define CY_ITEM   (CY_ICON + 2 * ICON_MARGIN)
 
#define ITEM_MARGIN   4
 
#define CX_ITEM_SPACE   (CX_ITEM + 2 * ITEM_MARGIN)
 
#define CY_ITEM_SPACE   (CY_ITEM + 2 * ITEM_MARGIN)
 
#define CY_TEXT_MARGIN   4
 
#define MAX_WINDOWS   120
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
DWORD wtodw (const WCHAR *psz)
 
BOOL LoadCoolSwitchSettings (void)
 
void ResizeAndCenter (HWND hwnd, int width, int height)
 
void MakeWindowActive (HWND hwnd)
 
void CompleteSwitch (BOOL doSwitch)
 
BOOL CALLBACK EnumerateCallback (HWND window, LPARAM lParam)
 
static HWND GetNiceRootOwner (HWND hwnd)
 
BOOL IsAltTabWindow (HWND hwnd)
 
static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
 
void ProcessMouseMessage (UINT message, LPARAM lParam)
 
void OnPaint (HWND hWnd)
 
DWORD CreateSwitcherWindow (HINSTANCE hInstance)
 
DWORD GetDialogFont (VOID)
 
void PrepareWindow (VOID)
 
BOOL ProcessHotKey (VOID)
 
void RotateTasks (BOOL bShift)
 
static void MoveLeft (void)
 
static void MoveRight (void)
 
static void MoveUp (void)
 
static void MoveDown (void)
 
VOID DestroyAppWindows (VOID)
 
LRESULT WINAPI DoAppSwitch (WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI SwitchWndProc_common (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT WINAPI SwitchWndProcA (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI SwitchWndProcW (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

HWND switchdialog = NULL
 
HFONT dialogFont
 
int selectedWindow = 0
 
BOOL isOpen = FALSE
 
int fontHeight =0
 
WCHAR windowText [1024]
 
HWND windowList [MAX_WINDOWS]
 
HICON iconList [MAX_WINDOWS]
 
int windowCount = 0
 
int cxBorder
 
int cyBorder
 
int nItems
 
int nCols
 
int nRows
 
int itemsW
 
int itemsH
 
int totalW
 
int totalH
 
int xOffset
 
int yOffset
 
POINT ptStart
 
int nShift = 0
 
BOOL Esc = FALSE
 
BOOL CoolSwitch = TRUE
 
int CoolSwitchRows = 3
 
int CoolSwitchColumns = 7
 
const DWORD Style = WS_POPUP | WS_BORDER | WS_DISABLED
 
const DWORD ExStyle = WS_EX_TOPMOST | WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW
 

Macro Definition Documentation

◆ CX_ICON

#define CX_ICON   32

Definition at line 24 of file appswitch.c.

◆ CX_ITEM

#define CX_ITEM   (CX_ICON + 2 * ICON_MARGIN)

Definition at line 28 of file appswitch.c.

◆ CX_ITEM_SPACE

#define CX_ITEM_SPACE   (CX_ITEM + 2 * ITEM_MARGIN)

Definition at line 32 of file appswitch.c.

◆ CY_ICON

#define CY_ICON   32

Definition at line 25 of file appswitch.c.

◆ CY_ITEM

#define CY_ITEM   (CY_ICON + 2 * ICON_MARGIN)

Definition at line 29 of file appswitch.c.

◆ CY_ITEM_SPACE

#define CY_ITEM_SPACE   (CY_ITEM + 2 * ITEM_MARGIN)

Definition at line 33 of file appswitch.c.

◆ CY_TEXT_MARGIN

#define CY_TEXT_MARGIN   4

Definition at line 35 of file appswitch.c.

◆ DIALOG_MARGIN

#define DIALOG_MARGIN   8

Definition at line 22 of file appswitch.c.

◆ ICON_MARGIN

#define ICON_MARGIN   4

Definition at line 26 of file appswitch.c.

◆ ITEM_MARGIN

#define ITEM_MARGIN   4

Definition at line 30 of file appswitch.c.

◆ MAX_WINDOWS

#define MAX_WINDOWS   120

Definition at line 39 of file appswitch.c.

Function Documentation

◆ CompleteSwitch()

void CompleteSwitch ( BOOL  doSwitch)

Definition at line 134 of file appswitch.c.

135 {
136  if (!isOpen)
137  return;
138 
139  isOpen = FALSE;
140 
141  TRACE("[ATbot] CompleteSwitch Hiding Window.\n");
143 
144  if(doSwitch)
145  {
147  return;
148 
149  // FIXME: workaround because reactos fails to activate the previous window correctly.
150  //if(selectedWindow != 0)
151  {
153 
155 
156  TRACE("[ATbot] CompleteSwitch Switching to 0x%08x (%ls)\n", hwnd, windowText);
157 
159  }
160  }
161 
162  windowCount = 0;
163 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND switchdialog
Definition: appswitch.c:42
#define SW_HIDE
Definition: winuser.h:762
#define _countof(array)
Definition: fontsub.cpp:30
int windowCount
Definition: appswitch.c:53
BOOL isOpen
Definition: appswitch.c:45
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
void MakeWindowActive(HWND hwnd)
Definition: appswitch.c:125
WCHAR windowText[1024]
Definition: appswitch.c:49
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch(), ProcessMouseMessage(), and SwitchWndProc_common().

◆ CreateSwitcherWindow()

DWORD CreateSwitcherWindow ( HINSTANCE  hInstance)

Definition at line 414 of file appswitch.c.

415 {
417  WC_SWITCH,
418  L"",
422  400, 150,
423  NULL, NULL,
424  hInstance, NULL);
425  if (!switchdialog)
426  {
427  TRACE("[ATbot] Task Switcher Window failed to create.\n");
428  return 0;
429  }
430 
431  isOpen = FALSE;
432  return 1;
433 }
#define WS_DISABLED
Definition: pedump.c:621
HWND switchdialog
Definition: appswitch.c:42
BOOL isOpen
Definition: appswitch.c:45
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
HINSTANCE hInstance
Definition: charmap.c:20
#define WC_SWITCH
Definition: undocuser.h:12
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR L[]
Definition: oid.c:1250
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616

Referenced by ProcessHotKey().

◆ DestroyAppWindows()

VOID DestroyAppWindows ( VOID  )

Definition at line 589 of file appswitch.c.

590 {
591  // for every item of the icon list:
592  INT i;
593  for (i = 0; i < windowCount; ++i)
594  {
595  // destroy the icon
597  iconList[i] = NULL;
598  }
599 }
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52

Referenced by DoAppSwitch(), and SwitchWndProc_common().

◆ DoAppSwitch()

LRESULT WINAPI DoAppSwitch ( WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 601 of file appswitch.c.

602 {
603  HWND hwndActive;
604  MSG msg;
605 
606  // FIXME: Is loading timing OK?
608 
609  if (!CoolSwitch)
610  return 0;
611 
612  // Already in the loop.
613  if (switchdialog || Esc) return 0;
614 
615  if (lParam == VK_ESCAPE)
616  {
617  Esc = TRUE;
618 
619  windowCount = 0;
621 
622  if (windowCount < 2)
623  return 0;
624 
626 
627  hwndActive = GetActiveWindow();
628 
629  if (hwndActive == NULL)
630  {
631  Esc = FALSE;
632  return 0;
633  }
634  }
635 
636  // Capture current active window.
637  hwndActive = GetActiveWindow();
638  if (hwndActive)
639  SetCapture(hwndActive);
640 
641  switch (lParam)
642  {
643  case VK_TAB:
644  if (!GetDialogFont() || !ProcessHotKey())
645  goto Exit;
646  break;
647 
648  case VK_ESCAPE:
649  break;
650 
651  default:
652  goto Exit;
653  }
654 
655  if (!hwndActive)
656  goto Exit;
657 
658  // Main message loop:
659  while (1)
660  {
661  for (;;)
662  {
663  if (PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ))
664  {
665  if (!CallMsgFilterW( &msg, MSGF_NEXTWINDOW )) break;
666  /* remove the message from the queue */
667  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
668  }
669  else
670  WaitMessage();
671  }
672 
673  switch (msg.message)
674  {
675  case WM_KEYUP:
676  {
677  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
678  if (msg.wParam == VK_MENU)
679  {
681  }
682  else if (msg.wParam == VK_RETURN)
683  {
685  }
686  else if (msg.wParam == VK_ESCAPE)
687  {
688  TRACE("DoAppSwitch VK_ESCAPE 2\n");
690  }
691  goto Exit; //break;
692  }
693 
694  case WM_SYSKEYDOWN:
695  {
696  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
697  if (HIWORD(msg.lParam) & KF_ALTDOWN)
698  {
699  if ( msg.wParam == VK_TAB )
700  {
701  if (Esc) break;
702  if (GetKeyState(VK_SHIFT) < 0)
703  {
704  MoveLeft();
705  }
706  else
707  {
708  MoveRight();
709  }
710  }
711  else if ( msg.wParam == VK_ESCAPE )
712  {
713  if (!Esc) break;
715  }
716  else if ( msg.wParam == VK_LEFT )
717  {
718  MoveLeft();
719  }
720  else if ( msg.wParam == VK_RIGHT )
721  {
722  MoveRight();
723  }
724  else if ( msg.wParam == VK_UP )
725  {
726  MoveUp();
727  }
728  else if ( msg.wParam == VK_DOWN )
729  {
730  MoveDown();
731  }
732  }
733  break;
734  }
735 
736  case WM_LBUTTONUP:
737  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
738  ProcessMouseMessage(msg.message, msg.lParam);
739  goto Exit;
740 
741  default:
742  if (PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ))
743  {
746  }
747  break;
748  }
749  }
750 Exit:
751  ReleaseCapture();
753  if (Esc) DestroyAppWindows();
754  switchdialog = NULL;
755  selectedWindow = 0;
756  windowCount = 0;
757  Esc = FALSE;
758  return 0;
759 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:134
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
BOOL WINAPI WaitMessage(void)
Definition: ntwrapper.h:350
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL Esc
Definition: appswitch.c:64
int windowCount
Definition: appswitch.c:53
#define VK_LEFT
Definition: winuser.h:2199
#define VK_TAB
Definition: winuser.h:2174
#define VK_DOWN
Definition: winuser.h:2202
#define VK_MENU
Definition: winuser.h:2179
#define VK_ESCAPE
Definition: winuser.h:2189
BOOL WINAPI DestroyWindow(_In_ HWND)
#define VK_RETURN
Definition: winuser.h:2176
static void MoveDown(void)
Definition: appswitch.c:573
#define PM_NOREMOVE
Definition: winuser.h:1181
#define MSGF_NEXTWINDOW
Definition: winuser.h:1165
BOOL WINAPI CallMsgFilterW(_In_ LPMSG, _In_ INT)
#define VK_UP
Definition: winuser.h:2200
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
static void MoveUp(void)
Definition: appswitch.c:558
#define VK_SHIFT
Definition: winuser.h:2177
smooth NULL
Definition: ftsmooth.c:416
SHORT WINAPI GetKeyState(_In_ int)
static void MoveLeft(void)
Definition: appswitch.c:544
#define TRACE(s)
Definition: solgame.cpp:4
static void Exit(void)
Definition: sock.c:1331
#define WM_KEYUP
Definition: winuser.h:1698
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
DWORD GetDialogFont(VOID)
Definition: appswitch.c:435
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define VK_RIGHT
Definition: winuser.h:2201
HWND WINAPI SetCapture(_In_ HWND hWnd)
BOOL LoadCoolSwitchSettings(void)
Definition: appswitch.c:86
BOOL ProcessHotKey(VOID)
Definition: appswitch.c:472
#define WM_LBUTTONUP
Definition: winuser.h:1759
static void MoveRight(void)
Definition: appswitch.c:552
#define KF_ALTDOWN
Definition: winuser.h:2424
void ProcessMouseMessage(UINT message, LPARAM lParam)
Definition: appswitch.c:294
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
void RotateTasks(BOOL bShift)
Definition: appswitch.c:507
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
BOOL CoolSwitch
Definition: appswitch.c:66
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: appswitch.c:284
VOID DestroyAppWindows(VOID)
Definition: appswitch.c:589

Referenced by DefWndHandleSysCommand().

◆ EnumerateCallback()

BOOL CALLBACK EnumerateCallback ( HWND  window,
LPARAM  lParam 
)

Definition at line 165 of file appswitch.c.

166 {
167  HICON hIcon;
168 
170 
171  // First try to get the big icon assigned to the window
172  hIcon = (HICON)SendMessageW(window, WM_GETICON, ICON_BIG, 0);
173  if (!hIcon)
174  {
175  // If no icon is assigned, try to get the icon assigned to the windows' class
177  if (!hIcon)
178  {
179  // If we still don't have an icon, see if we can do with the small icon,
180  // or a default application icon
181  hIcon = (HICON)SendMessageW(window, WM_GETICON, ICON_SMALL2, 0);
182  if (!hIcon)
183  {
184  // using windows logo icon as default
185  hIcon = gpsi->hIconWindows;
186  if (!hIcon)
187  {
188  //if all attempts to get icon fails go to the next window
189  return TRUE;
190  }
191  }
192  }
193  }
194 
197 
198  windowCount++;
199 
200  // If we got to the max number of windows,
201  // we won't be able to add any more
202  if(windowCount >= MAX_WINDOWS)
203  return FALSE;
204 
205  return TRUE;
206 }
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define MAX_WINDOWS
Definition: appswitch.c:39
int windowCount
Definition: appswitch.c:53
PSERVERINFO gpsi
Definition: main.c:27
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52
static IHTMLWindow2 * window
Definition: events.c:77
#define GCL_HICON
Definition: winuser.h:661
HICON WINAPI CopyIcon(_In_ HICON)
Definition: cursoricon.c:1980
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
LPARAM lParam
Definition: combotst.c:139
#define GetClassLongPtrW
Definition: winuser.h:4465
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by EnumWindowsProc().

◆ EnumWindowsProc()

static BOOL CALLBACK EnumWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 284 of file appswitch.c.

285 {
286  if (IsAltTabWindow(hwnd))
287  {
289  return FALSE;
290  }
291  return TRUE;
292 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL CALLBACK EnumerateCallback(HWND window, LPARAM lParam)
Definition: appswitch.c:165
#define TRUE
Definition: types.h:120
BOOL IsAltTabWindow(HWND hwnd)
Definition: appswitch.c:234
LPARAM lParam
Definition: combotst.c:139

Referenced by DoAppSwitch(), and ProcessHotKey().

◆ GetDialogFont()

DWORD GetDialogFont ( VOID  )

Definition at line 435 of file appswitch.c.

436 {
437  HDC tDC;
438  TEXTMETRIC tm;
439 
441 
442  tDC = GetDC(0);
443  GetTextMetrics(tDC, &tm);
444  fontHeight = tm.tmHeight;
445  ReleaseDC(0, tDC);
446 
447  return 1;
448 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HFONT dialogFont
Definition: appswitch.c:43
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define GetTextMetrics
Definition: wingdi.h:4469
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
int fontHeight
Definition: appswitch.c:47
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
Definition: time.h:76
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

Referenced by DoAppSwitch().

◆ GetNiceRootOwner()

static HWND GetNiceRootOwner ( HWND  hwnd)
static

Definition at line 208 of file appswitch.c.

209 {
210  HWND hwndOwner;
211  DWORD ExStyle, OwnerExStyle;
212 
213  for (;;)
214  {
215  // A window with WS_EX_APPWINDOW is treated as if it has no owner
217  if (ExStyle & WS_EX_APPWINDOW)
218  break;
219 
220  // Is the owner visible?
221  // An window with WS_EX_TOOLWINDOW is treated as if it weren't visible
222  hwndOwner = GetWindow(hwnd, GW_OWNER);
223  OwnerExStyle = GetWindowLong(hwndOwner, GWL_EXSTYLE);
224  if (!IsWindowVisible(hwndOwner) || (OwnerExStyle & WS_EX_TOOLWINDOW))
225  break;
226 
227  hwnd = hwndOwner;
228  }
229 
230  return hwnd;
231 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GetWindowLong
Definition: winuser.h:5697
#define GW_OWNER
Definition: winuser.h:761
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by IsAltTabWindow().

◆ IsAltTabWindow()

BOOL IsAltTabWindow ( HWND  hwnd)

Definition at line 234 of file appswitch.c.

235 {
236  DWORD ExStyle;
237  RECT rc;
238  HWND hwndTry, hwndWalk;
239  WCHAR szClass[64];
240 
241  // must be visible
242  if (!IsWindowVisible(hwnd))
243  return FALSE;
244 
245  // must not be WS_EX_TOOLWINDOW
248  return FALSE;
249 
250  // must be not empty rect
251  GetWindowRect(hwnd, &rc);
252  if (IsRectEmpty(&rc))
253  return FALSE;
254 
255  // check special windows
256  if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
257  wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
258  wcscmp(szClass, L"Progman") == 0)
259  {
260  return TRUE;
261  }
262 
263  // get 'nice' root owner
264  hwndWalk = GetNiceRootOwner(hwnd);
265 
266  // walk back from hwndWalk toward hwnd
267  for (;;)
268  {
269  hwndTry = GetLastActivePopup(hwndWalk);
270  if (hwndTry == hwndWalk)
271  break;
272 
273  ExStyle = GetWindowLong(hwndTry, GWL_EXSTYLE);
274  if (IsWindowVisible(hwndTry) && !(ExStyle & WS_EX_TOOLWINDOW))
275  break;
276 
277  hwndWalk = hwndTry;
278  }
279 
280  return hwnd == hwndTry; // Reached?
281 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
static HWND GetNiceRootOwner(HWND hwnd)
Definition: appswitch.c:208
#define _countof(array)
Definition: fontsub.cpp:30
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
HWND WINAPI GetLastActivePopup(_In_ HWND)
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define GetWindowLong
Definition: winuser.h:5697
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by EnumWindowsProc().

◆ LoadCoolSwitchSettings()

BOOL LoadCoolSwitchSettings ( void  )

Definition at line 86 of file appswitch.c.

87 {
88  CoolSwitch = TRUE;
89  CoolSwitchRows = 3;
91 
92  // FIXME: load the settings from registry
93 
94  TRACE("CoolSwitch: %d\n", CoolSwitch);
95  TRACE("CoolSwitchRows: %d\n", CoolSwitchRows);
96  TRACE("CoolSwitchColumns: %d\n", CoolSwitchColumns);
97 
98  return TRUE;
99 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
int CoolSwitchColumns
Definition: appswitch.c:68
int CoolSwitchRows
Definition: appswitch.c:67
BOOL CoolSwitch
Definition: appswitch.c:66

Referenced by DoAppSwitch().

◆ MakeWindowActive()

void MakeWindowActive ( HWND  hwnd)

Definition at line 125 of file appswitch.c.

126 {
127  if (IsIconic(hwnd))
129 
130  BringWindowToTop(hwnd); // same as: SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ?
132 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SC_RESTORE
Definition: winuser.h:2573
BOOL WINAPI IsIconic(_In_ HWND)
BOOL WINAPI BringWindowToTop(_In_ HWND)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define WM_SYSCOMMAND
Definition: winuser.h:1723

Referenced by CompleteSwitch(), ProcessHotKey(), and RotateTasks().

◆ MoveDown()

static void MoveDown ( void  )
static

Definition at line 573 of file appswitch.c.

574 {
575  INT iRow = selectedWindow / nCols;
576  INT iCol = selectedWindow % nCols;
577 
578  ++iRow;
579  if (iRow >= nRows)
580  iRow = 0;
581 
582  selectedWindow = iRow * nCols + iCol;
586 }
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int nRows
Definition: appswitch.c:56
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveLeft()

static void MoveLeft ( void  )
static

Definition at line 544 of file appswitch.c.

545 {
547  if (selectedWindow < 0)
550 }
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
int windowCount
Definition: appswitch.c:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveRight()

static void MoveRight ( void  )
static

Definition at line 552 of file appswitch.c.

553 {
556 }
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
int windowCount
Definition: appswitch.c:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveUp()

static void MoveUp ( void  )
static

Definition at line 558 of file appswitch.c.

559 {
560  INT iRow = selectedWindow / nCols;
561  INT iCol = selectedWindow % nCols;
562 
563  --iRow;
564  if (iRow < 0)
565  iRow = nRows - 1;
566 
567  selectedWindow = iRow * nCols + iCol;
571 }
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int nRows
Definition: appswitch.c:56
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ OnPaint()

void OnPaint ( HWND  hWnd)

Definition at line 321 of file appswitch.c.

322 {
323  HDC dialogDC;
324  PAINTSTRUCT paint;
325  RECT cRC, textRC;
326  int i, xPos, yPos, CharCount;
327  HFONT dcFont;
328  HICON hIcon;
329  HPEN hPen;
330  COLORREF Color;
331 
332  // check
333  if (nCols == 0 || nItems == 0)
334  return;
335 
336  // begin painting
337  dialogDC = BeginPaint(hWnd, &paint);
338  if (dialogDC == NULL)
339  return;
340 
341  // fill the client area
342  GetClientRect(hWnd, &cRC);
343  FillRect(dialogDC, &cRC, (HBRUSH)(COLOR_3DFACE + 1));
344 
345  // if the selection index exceeded the display items, then
346  // do display item shifting
347  if (selectedWindow >= nItems)
348  nShift = selectedWindow - nItems + 1;
349  else
350  nShift = 0;
351 
352  for (i = 0; i < nItems; ++i)
353  {
354  // get the icon to display
355  hIcon = iconList[i + nShift];
356 
357  // calculate the position where we start drawing
358  xPos = DIALOG_MARGIN + CX_ITEM_SPACE * (i % nCols) + ITEM_MARGIN;
359  yPos = DIALOG_MARGIN + CY_ITEM_SPACE * (i / nCols) + ITEM_MARGIN;
360 
361  // centering
363  {
364  xPos += (itemsW - nItems * CX_ITEM_SPACE) / 2;
365  }
366 
367  // if this position is selected,
368  if (selectedWindow == i + nShift)
369  {
370  // create a solid pen
372  hPen = CreatePen(PS_SOLID, 1, Color);
373 
374  // draw a rectangle with using the pen
375  SelectObject(dialogDC, hPen);
377  Rectangle(dialogDC, xPos, yPos, xPos + CX_ITEM, yPos + CY_ITEM);
378  Rectangle(dialogDC, xPos + 1, yPos + 1,
379  xPos + CX_ITEM - 1, yPos + CY_ITEM - 1);
380 
381  // delete the pen
382  DeleteObject(hPen);
383  }
384 
385  // draw icon
386  DrawIconEx(dialogDC, xPos + ICON_MARGIN, yPos + ICON_MARGIN,
388  }
389 
390  // set the text rectangle
393 
394  // draw the sunken button around text
395  DrawFrameControl(dialogDC, &textRC, DFC_BUTTON,
397 
398  // get text
401 
402  // draw text
403  dcFont = SelectObject(dialogDC, dialogFont);
405  SetBkMode(dialogDC, TRANSPARENT);
406  DrawTextW(dialogDC, windowText, CharCount, &textRC,
408  SelectObject(dialogDC, dcFont);
409 
410  // end painting
411  EndPaint(hWnd, &paint);
412 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HFONT dialogFont
Definition: appswitch.c:43
static HICON
Definition: imagelist.c:84
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define DFC_BUTTON
Definition: winuser.h:476
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
#define CX_ICON
Definition: appswitch.c:24
int nCols
Definition: appswitch.c:56
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define _countof(array)
Definition: fontsub.cpp:30
#define NULL_BRUSH
Definition: wingdi.h:900
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
#define ITEM_MARGIN
Definition: appswitch.c:30
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define ICON_MARGIN
Definition: appswitch.c:26
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
DWORD WINAPI GetSysColor(_In_ int)
struct Color Color
#define PS_SOLID
Definition: wingdi.h:585
#define DFCS_PUSHED
Definition: winuser.h:503
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define COLOR_3DFACE
Definition: winuser.h:919
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define CX_ITEM_SPACE
Definition: appswitch.c:32
#define TRANSPARENT
Definition: wingdi.h:949
int nItems
Definition: appswitch.c:56
#define DT_END_ELLIPSIS
Definition: winuser.h:529
smooth NULL
Definition: ftsmooth.c:416
int totalW
Definition: appswitch.c:58
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52
#define DT_VCENTER
Definition: winuser.h:543
#define DIALOG_MARGIN
Definition: appswitch.c:22
int itemsW
Definition: appswitch.c:57
#define CY_ITEM
Definition: appswitch.c:29
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
int itemsH
Definition: appswitch.c:57
DWORD COLORREF
Definition: windef.h:285
int totalH
Definition: appswitch.c:58
int nShift
Definition: appswitch.c:62
int CoolSwitchColumns
Definition: appswitch.c:68
#define DI_NORMAL
Definition: wingdi.h:72
#define CY_ICON
Definition: appswitch.c:25
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
HICON hIcon
Definition: msconfig.c:44
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR windowText[1024]
Definition: appswitch.c:49
#define CX_ITEM
Definition: appswitch.c:28
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_BTNTEXT
Definition: winuser.h:923
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int selectedWindow
Definition: appswitch.c:44
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProc_common().

◆ PrepareWindow()

void PrepareWindow ( VOID  )

Definition at line 450 of file appswitch.c.

451 {
453 
456  if (nRows > CoolSwitchRows)
457  {
459  nItems = nRows * nCols;
460  }
461 
464 
465  totalW = itemsW + 2 * DIALOG_MARGIN;
466  totalH = itemsH + 2 * DIALOG_MARGIN;
468 
470 }
void ResizeAndCenter(HWND hwnd, int width, int height)
Definition: appswitch.c:101
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
int windowCount
Definition: appswitch.c:53
#define CY_TEXT_MARGIN
Definition: appswitch.c:35
#define CX_ITEM_SPACE
Definition: appswitch.c:32
int nItems
Definition: appswitch.c:56
int totalW
Definition: appswitch.c:58
#define DIALOG_MARGIN
Definition: appswitch.c:22
int itemsW
Definition: appswitch.c:57
int fontHeight
Definition: appswitch.c:47
int itemsH
Definition: appswitch.c:57
int totalH
Definition: appswitch.c:58
int CoolSwitchColumns
Definition: appswitch.c:68
int CoolSwitchRows
Definition: appswitch.c:67
int nRows
Definition: appswitch.c:56
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProc_common().

◆ ProcessHotKey()

BOOL ProcessHotKey ( VOID  )

Definition at line 472 of file appswitch.c.

473 {
474  if (!isOpen)
475  {
476  windowCount = 0;
478 
479  if (windowCount == 0)
480  return FALSE;
481 
482  if (windowCount == 1)
483  {
485  return FALSE;
486  }
487 
489  return FALSE;
490 
491  selectedWindow = 1;
492 
493  TRACE("[ATbot] HotKey Received. Opening window.\n");
496  isOpen = TRUE;
497  }
498  else
499  {
500  TRACE("[ATbot] HotKey Received Rotating.\n");
503  }
504  return TRUE;
505 }
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
DWORD CreateSwitcherWindow(HINSTANCE hInstance)
Definition: appswitch.c:414
int windowCount
Definition: appswitch.c:53
BOOL isOpen
Definition: appswitch.c:45
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HINSTANCE User32Instance
Definition: dllmain.c:27
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
#define SW_SHOWNORMAL
Definition: winuser.h:764
void MakeWindowActive(HWND hwnd)
Definition: appswitch.c:125
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
int selectedWindow
Definition: appswitch.c:44
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: appswitch.c:284

Referenced by DoAppSwitch().

◆ ProcessMouseMessage()

void ProcessMouseMessage ( UINT  message,
LPARAM  lParam 
)

Definition at line 294 of file appswitch.c.

295 {
296  int xPos = LOWORD(lParam);
297  int yPos = HIWORD(lParam);
298 
299  int xIndex = (xPos - DIALOG_MARGIN) / CX_ITEM_SPACE;
300  int yIndex = (yPos - DIALOG_MARGIN) / CY_ITEM_SPACE;
301 
302  if (xIndex < 0 || nCols <= xIndex ||
303  yIndex < 0 || nRows <= yIndex)
304  {
305  return;
306  }
307 
308  selectedWindow = (yIndex*nCols) + xIndex;
309  if (message == WM_MOUSEMOVE)
310  {
312  //RedrawWindow(switchdialog, NULL, NULL, 0);
313  }
314  else
315  {
316  selectedWindow = (yIndex*nCols) + xIndex;
318  }
319 }
Definition: tftpd.h:59
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:134
#define TRUE
Definition: types.h:120
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
#define CX_ITEM_SPACE
Definition: appswitch.c:32
smooth NULL
Definition: ftsmooth.c:416
#define DIALOG_MARGIN
Definition: appswitch.c:22
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define WM_MOUSEMOVE
Definition: winuser.h:1757
int nRows
Definition: appswitch.c:56
#define HIWORD(l)
Definition: typedefs.h:246
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by DoAppSwitch(), and SwitchWndProc_common().

◆ ResizeAndCenter()

void ResizeAndCenter ( HWND  hwnd,
int  width,
int  height 
)

Definition at line 101 of file appswitch.c.

102 {
103  int x, y;
104  RECT Rect;
105 
106  int screenwidth = GetSystemMetrics(SM_CXSCREEN);
107  int screenheight = GetSystemMetrics(SM_CYSCREEN);
108 
109  x = (screenwidth - width) / 2;
110  y = (screenheight - height) / 2;
111 
112  SetRect(&Rect, x, y, x + width, y + height);
114 
115  x = Rect.left;
116  y = Rect.top;
117  width = Rect.right - Rect.left;
118  height = Rect.bottom - Rect.top;
120 
121  ptStart.x = x;
122  ptStart.y = y;
123 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint GLint GLsizei width
Definition: gl.h:1546
POINT ptStart
Definition: appswitch.c:60
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define SM_CXSCREEN
Definition: winuser.h:949
#define SM_CYSCREEN
Definition: winuser.h:950
const DWORD Style
Definition: appswitch.c:71
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
struct Rect Rect
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by PrepareWindow().

◆ RotateTasks()

void RotateTasks ( BOOL  bShift)

Definition at line 507 of file appswitch.c.

508 {
509  HWND hwndFirst, hwndLast;
510  DWORD Size;
511 
512  if (windowCount < 2 || !Esc)
513  return;
514 
515  hwndFirst = windowList[0];
516  hwndLast = windowList[windowCount - 1];
517 
518  if (bShift)
519  {
520  SetWindowPos(hwndLast, HWND_TOP, 0, 0, 0, 0,
523 
524  MakeWindowActive(hwndLast);
525 
526  Size = (windowCount - 1) * sizeof(HWND);
528  windowList[0] = hwndLast;
529  }
530  else
531  {
532  SetWindowPos(hwndFirst, hwndLast, 0, 0, 0, 0,
535 
537 
538  Size = (windowCount - 1) * sizeof(HWND);
540  windowList[windowCount - 1] = hwndFirst;
541  }
542 }
BOOL Esc
Definition: appswitch.c:64
int windowCount
Definition: appswitch.c:53
volatile BOOLEAN bShift
Definition: shell.c:71
#define HWND_TOP
Definition: winuser.h:1193
#define MoveMemory
Definition: winbase.h:1632
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define SWP_NOSIZE
Definition: winuser.h:1230
void MakeWindowActive(HWND hwnd)
Definition: appswitch.c:125
#define SWP_NOREPOSITION
Definition: winuser.h:1235
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234

Referenced by DoAppSwitch().

◆ SwitchWndProc_common()

LRESULT WINAPI SwitchWndProc_common ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 764 of file appswitch.c.

765 {
766  PWND pWnd;
767  PALTTABINFO ati;
768  pWnd = ValidateHwnd(hWnd);
769  if (pWnd)
770  {
771  if (!pWnd->fnid)
772  {
774  }
775  }
776 
777  switch (uMsg)
778  {
779  case WM_NCCREATE:
780  if (!(ati = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ati))))
781  return 0;
782  SetWindowLongPtrW( hWnd, 0, (LONG_PTR)ati );
783  return TRUE;
784 
785  case WM_SHOWWINDOW:
786  if (wParam)
787  {
788  PrepareWindow();
790  ati->cbSize = sizeof(ALTTABINFO);
791  ati->cItems = nItems;
792  ati->cColumns = nCols;
793  ati->cRows = nRows;
794  if (nCols)
795  {
796  ati->iColFocus = (selectedWindow - nShift) % nCols;
797  ati->iRowFocus = (selectedWindow - nShift) / nCols;
798  }
799  else
800  {
801  ati->iColFocus = 0;
802  ati->iRowFocus = 0;
803  }
804  ati->cxItem = CX_ITEM_SPACE;
805  ati->cyItem = CY_ITEM_SPACE;
806  ati->ptStart = ptStart;
807  }
808  return 0;
809 
810  case WM_MOUSEMOVE:
812  return 0;
813 
814  case WM_ACTIVATE:
815  if (wParam == WA_INACTIVE)
816  {
818  }
819  return 0;
820 
821  case WM_PAINT:
822  OnPaint(hWnd);
823  return 0;
824 
825  case WM_DESTROY:
826  isOpen = FALSE;
828  HeapFree( GetProcessHeap(), 0, ati );
829  SetWindowLongPtrW( hWnd, 0, 0 );
832  return 0;
833  }
834  return DefWindowProcW(hWnd, uMsg, wParam, lParam);
835 }
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:134
#define TRUE
Definition: types.h:120
POINT ptStart
Definition: appswitch.c:60
int nCols
Definition: appswitch.c:56
HWND hWnd
Definition: settings.c:17
BOOL isOpen
Definition: appswitch.c:45
#define WM_SHOWWINDOW
Definition: winuser.h:1610
#define GetWindowLongPtrW
Definition: winuser.h:4730
#define FNID_DESTROY
Definition: ntuser.h:859
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct tagALTTABINFO * PALTTABINFO
POINT ptStart
Definition: winuser.h:3679
DWORD fnid
Definition: ntuser.h:673
#define CX_ITEM_SPACE
Definition: appswitch.c:32
int nItems
Definition: appswitch.c:56
struct tagALTTABINFO ALTTABINFO
#define WM_DESTROY
Definition: winuser.h:1591
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define FNID_SWITCH
Definition: ntuser.h:827
int nShift
Definition: appswitch.c:62
#define WM_PAINT
Definition: winuser.h:1602
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
void PrepareWindow(VOID)
Definition: appswitch.c:450
Definition: ntuser.h:657
#define WM_ACTIVATE
Definition: winuser.h:1594
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
void ProcessMouseMessage(UINT message, LPARAM lParam)
Definition: appswitch.c:294
int nRows
Definition: appswitch.c:56
DWORD cbSize
Definition: winuser.h:3671
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4122
#define SetWindowLongPtrW
Definition: winuser.h:5247
#define WA_INACTIVE
Definition: winuser.h:2597
void OnPaint(HWND hWnd)
Definition: appswitch.c:321
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:394
VOID DestroyAppWindows(VOID)
Definition: appswitch.c:589
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProcA(), and SwitchWndProcW().

◆ SwitchWndProcA()

LRESULT WINAPI SwitchWndProcA ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 837 of file appswitch.c.

838 {
839  return SwitchWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
840 }
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI SwitchWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: appswitch.c:764
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ SwitchWndProcW()

LRESULT WINAPI SwitchWndProcW ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 842 of file appswitch.c.

843 {
844  return SwitchWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
845 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI SwitchWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: appswitch.c:764
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )

◆ wtodw()

DWORD wtodw ( const WCHAR psz)

Definition at line 74 of file appswitch.c.

75 {
76  const WCHAR *pch = psz;
77  DWORD Value = 0;
78  while ('0' <= *pch && *pch <= '9')
79  {
80  Value *= 10;
81  Value += *pch - L'0';
82  }
83  return Value;
84 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define pch(ap)
Definition: match.c:418
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250

Variable Documentation

◆ CoolSwitch

BOOL CoolSwitch = TRUE

Definition at line 66 of file appswitch.c.

Referenced by DoAppSwitch(), and LoadCoolSwitchSettings().

◆ CoolSwitchColumns

int CoolSwitchColumns = 7

Definition at line 68 of file appswitch.c.

Referenced by LoadCoolSwitchSettings(), OnPaint(), and PrepareWindow().

◆ CoolSwitchRows

int CoolSwitchRows = 3

Definition at line 67 of file appswitch.c.

Referenced by LoadCoolSwitchSettings(), and PrepareWindow().

◆ cxBorder

int cxBorder

Definition at line 55 of file appswitch.c.

◆ cyBorder

int cyBorder

Definition at line 55 of file appswitch.c.

◆ dialogFont

HFONT dialogFont

Definition at line 43 of file appswitch.c.

Referenced by GetDialogFont(), and OnPaint().

◆ Esc

BOOL Esc = FALSE

Definition at line 64 of file appswitch.c.

Referenced by DoAppSwitch(), and RotateTasks().

◆ ExStyle

◆ fontHeight

int fontHeight =0

Definition at line 47 of file appswitch.c.

Referenced by add_font(), GetDialogFont(), PrepareWindow(), and realize_font().

◆ iconList

HICON iconList[MAX_WINDOWS]

Definition at line 52 of file appswitch.c.

Referenced by DestroyAppWindows(), EnumerateCallback(), and OnPaint().

◆ isOpen

BOOL isOpen = FALSE

◆ itemsH

int itemsH

Definition at line 57 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ itemsW

int itemsW

Definition at line 57 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ nCols

◆ nItems

◆ nRows

◆ nShift

int nShift = 0

Definition at line 62 of file appswitch.c.

Referenced by OnPaint(), and SwitchWndProc_common().

◆ ptStart

POINT ptStart

Definition at line 60 of file appswitch.c.

Referenced by ResizeAndCenter(), SwitchWndProc_common(), and test_CPoint().

◆ selectedWindow

◆ Style

◆ switchdialog

◆ totalH

int totalH

Definition at line 58 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ totalW

int totalW

Definition at line 58 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ windowCount

◆ windowList

HWND windowList[MAX_WINDOWS]

Definition at line 51 of file appswitch.c.

Referenced by CompleteSwitch(), EnumerateCallback(), OnPaint(), ProcessHotKey(), and RotateTasks().

◆ windowText

◆ xOffset

int xOffset

◆ yOffset