ReactOS 0.4.16-dev-319-g6cf4263
appbar.cpp File Reference
#include "precomp.h"
#include <wine/list.h>
Include dependency graph for appbar.cpp:

Go to the source code of this file.

Classes

struct  appbar_cmd
 
struct  appbar_response
 
struct  appbar_data
 

Macros

#define GetPrimaryTaskbar()   FindWindowW(L"Shell_TrayWnd", NULL)
 

Functions

static struct appbar_dataget_appbar (HWND hwnd)
 
void appbar_notify_all (HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam)
 
static void send_poschanged (HWND hwnd)
 
static void appbar_cliprect (HWND hwnd, RECT *rect)
 
static UINT_PTR handle_appbarmessage (DWORD msg, _AppBarData *abd)
 
LRESULT appbar_message (COPYDATASTRUCT *cds)
 

Variables

static struct list appbars = LIST_INIT(appbars)
 

Macro Definition Documentation

◆ GetPrimaryTaskbar

#define GetPrimaryTaskbar ( )    FindWindowW(L"Shell_TrayWnd", NULL)

Definition at line 38 of file appbar.cpp.

Function Documentation

◆ appbar_cliprect()

static void appbar_cliprect ( HWND  hwnd,
RECT rect 
)
static

Definition at line 103 of file appbar.cpp.

104{
105 struct appbar_data* data;
107 {
108 if (data->hwnd == hwnd)
109 {
110 /* we only care about appbars that were added before this one */
111 return;
112 }
113 if (data->space_reserved)
114 {
115 /* move in the side that corresponds to the other appbar's edge */
116 switch (data->edge)
117 {
118 case ABE_BOTTOM:
119 rect->bottom = min(rect->bottom, data->rc.top);
120 break;
121 case ABE_LEFT:
122 rect->left = max(rect->left, data->rc.right);
123 break;
124 case ABE_RIGHT:
125 rect->right = min(rect->right, data->rc.left);
126 break;
127 case ABE_TOP:
128 rect->top = max(rect->top, data->rc.bottom);
129 break;
130 }
131 }
132 }
133}
static struct list appbars
Definition: appbar.cpp:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
#define min(a, b)
Definition: monoChain.cc:55
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABE_RIGHT
Definition: shellapi.h:19
#define ABE_TOP
Definition: shellapi.h:18
#define ABE_LEFT
Definition: shellapi.h:17
& rect
Definition: startmenu.cpp:1413
#define max(a, b)
Definition: svc.c:63
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by handle_appbarmessage().

◆ appbar_message()

LRESULT appbar_message ( COPYDATASTRUCT cds)

Definition at line 242 of file appbar.cpp.

243{
244 struct appbar_cmd cmd;
246 HANDLE return_hproc;
248 LPVOID return_view;
249 struct appbar_response* response;
250
251 if (cds->cbData != sizeof(struct appbar_cmd))
252 return TRUE;
253
254 RtlCopyMemory(&cmd, cds->lpData, cds->cbData);
255
256 result = handle_appbarmessage(cmd.dwMsg, &cmd.abd);
257
258 return_hproc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, cmd.return_process);
259 if (return_hproc == NULL)
260 {
261 ERR("couldn't open calling process\n");
262 return TRUE;
263 }
264
265 if (!DuplicateHandle(return_hproc, UlongToHandle(cmd.return_map), GetCurrentProcess(), &return_map, 0, FALSE, DUPLICATE_SAME_ACCESS))
266 {
267 ERR("couldn't duplicate handle\n");
268 CloseHandle(return_hproc);
269 return TRUE;
270 }
271 CloseHandle(return_hproc);
272
273 return_view = MapViewOfFile(return_map, FILE_MAP_WRITE, 0, 0, sizeof(struct appbar_response));
274
275 if (return_view)
276 {
277 response = (struct appbar_response*)return_view;
278 response->result = result;
279 response->abd = cmd.abd;
280
281 UnmapViewOfFile(return_view);
282 }
283 else
284 {
285 ERR("couldn't map view of file\n");
286 }
287
288 CloseHandle(return_map);
289 return TRUE;
290}
static UINT_PTR handle_appbarmessage(DWORD msg, _AppBarData *abd)
Definition: appbar.cpp:135
#define ERR(fmt,...)
Definition: precomp.h:57
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746
#define GetCurrentProcess()
Definition: compat.h:759
#define MapViewOfFile
Definition: compat.h:745
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
GLuint64EXT * result
Definition: glext.h:11304
#define PROCESS_DUP_HANDLE
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
ULONG return_map
Definition: appbar.cpp:43
struct _AppBarData abd
Definition: appbar.cpp:51
ULONGLONG result
Definition: appbar.cpp:50
Definition: ftp_var.h:139
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define FILE_MAP_WRITE
Definition: winbase.h:155
#define DUPLICATE_SAME_ACCESS

Referenced by CTrayWindow::OnCopyData().

◆ appbar_notify_all()

void appbar_notify_all ( HMONITOR  hMon,
UINT  uMsg,
HWND  hwndExclude,
LPARAM  lParam 
)

Definition at line 80 of file appbar.cpp.

81{
82 struct appbar_data* data;
83
85 {
86 if (data->hwnd == hwndExclude)
87 continue;
88
89 if (hMon && hMon != MonitorFromWindow(data->hwnd, MONITOR_DEFAULTTONULL))
90 continue;
91
92 SendMessageW(data->hwnd, data->callback_msg, uMsg, lParam);
93 }
94}
LPARAM lParam
Definition: combotst.c:139
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CTrayWindow::ExecContextMenuCmd(), and send_poschanged().

◆ get_appbar()

static struct appbar_data * get_appbar ( HWND  hwnd)
static

Definition at line 67 of file appbar.cpp.

68{
69 struct appbar_data* data;
70
72 {
73 if (data->hwnd == hwnd)
74 return data;
75 }
76
77 return NULL;
78}

Referenced by handle_appbarmessage().

◆ handle_appbarmessage()

static UINT_PTR handle_appbarmessage ( DWORD  msg,
_AppBarData abd 
)
static

Definition at line 135 of file appbar.cpp.

136{
137 struct appbar_data* data;
138 HWND hwnd = abd->hWnd;
139
140 switch (msg)
141 {
142 case ABM_NEW:
143 if (get_appbar(hwnd))
144 {
145 /* fail when adding an hwnd the second time */
146 return FALSE;
147 }
148
150 if (!data)
151 {
152 ERR("out of memory\n");
153 return FALSE;
154 }
155 data->hwnd = hwnd;
156 data->callback_msg = abd->uCallbackMessage;
157
158 list_add_tail(&appbars, &data->entry);
159
160 return TRUE;
161 case ABM_REMOVE:
162 if ((data = get_appbar(hwnd)))
163 {
164 list_remove(&data->entry);
165
167
169 }
170 else
171 WARN("removing hwnd %p not on the list\n", hwnd);
172 return TRUE;
173 case ABM_QUERYPOS:
174 if (abd->uEdge > ABE_BOTTOM)
175 WARN("invalid edge %i for %p\n", abd->uEdge, hwnd);
176 appbar_cliprect( hwnd, &abd->rc );
177 return TRUE;
178 case ABM_SETPOS:
179 if (abd->uEdge > ABE_BOTTOM)
180 {
181 WARN("invalid edge %i for %p\n", abd->uEdge, hwnd);
182 return TRUE;
183 }
184 if ((data = get_appbar(hwnd)))
185 {
186 /* calculate acceptable space */
187 appbar_cliprect( hwnd, &abd->rc );
188
189 if (!EqualRect(&abd->rc, &data->rc))
191
192 /* reserve that space for this appbar */
193 data->edge = abd->uEdge;
194 data->rc = abd->rc;
195 data->space_reserved = TRUE;
196 }
197 else
198 {
199 WARN("app sent ABM_SETPOS message for %p without ABM_ADD\n", hwnd);
200 }
201 return TRUE;
202 case ABM_GETSTATE:
203 TRACE("SHAppBarMessage(ABM_GETSTATE)\n");
206 case ABM_SETSTATE:
207 TRACE("SHAppBarMessage(ABM_SETSTATE lparam=%s)\n", wine_dbgstr_longlong(abd->lParam));
209 if (hwnd)
210 {
212 settings.sr.AutoHide = (abd->lParam & ABS_AUTOHIDE) != 0;
213 settings.sr.AlwaysOnTop = (abd->lParam & ABS_ALWAYSONTOP) != 0;
215 return TRUE;
216 }
217 return FALSE;
219 TRACE("SHAppBarMessage(ABM_GETTASKBARPOS, hwnd=%p)\n", hwnd);
221 abd->hWnd = GetPrimaryTaskbar();
222 return abd->hWnd && GetWindowRect(abd->hWnd, &abd->rc);
223 case ABM_ACTIVATE:
224 return TRUE;
226 FIXME("SHAppBarMessage(ABM_GETAUTOHIDEBAR, hwnd=%p, edge=%x): stub\n", hwnd, abd->uEdge);
228 return (SIZE_T)GetPrimaryTaskbar();
229 return NULL;
231 FIXME("SHAppBarMessage(ABM_SETAUTOHIDEBAR, hwnd=%p, edge=%x, lparam=%s): stub\n",
233 return TRUE;
235 return TRUE;
236 default:
237 FIXME("SHAppBarMessage(%x) unimplemented\n", msg);
238 return FALSE;
239 }
240}
struct mke2fs_defaults settings[]
#define GetPrimaryTaskbar()
Definition: appbar.cpp:38
static struct appbar_data * get_appbar(HWND hwnd)
Definition: appbar.cpp:67
static void appbar_cliprect(HWND hwnd, RECT *rect)
Definition: appbar.cpp:103
static void send_poschanged(HWND hwnd)
Definition: appbar.cpp:97
#define msg(x)
Definition: auth_time.c:54
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
#define TWM_SETTINGSCHANGED
Definition: precomp.h:133
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:71
#define ABM_GETTASKBARPOS
Definition: shellapi.h:67
#define ABM_GETSTATE
Definition: shellapi.h:66
#define ABM_SETAUTOHIDEBAR
Definition: shellapi.h:70
#define ABM_SETSTATE
Definition: shellapi.h:72
#define ABM_SETPOS
Definition: shellapi.h:65
#define ABM_ACTIVATE
Definition: shellapi.h:68
#define ABS_ALWAYSONTOP
Definition: shellapi.h:22
#define ABM_REMOVE
Definition: shellapi.h:63
#define ABS_AUTOHIDE
Definition: shellapi.h:21
#define ABM_NEW
Definition: shellapi.h:62
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:69
#define ABM_QUERYPOS
Definition: shellapi.h:64
#define TRACE(s)
Definition: solgame.cpp:4
TW_STRUCKRECTS2 sr
Definition: precomp.h:225
UINT uCallbackMessage
Definition: shellapi.h:220
LPARAM lParam
Definition: shellapi.h:223
HWND hWnd
Definition: shellapi.h:219
UINT uEdge
Definition: shellapi.h:221
DWORD AutoHide
Definition: precomp.h:204
DWORD AlwaysOnTop
Definition: precomp.h:205
DWORD Position
Definition: precomp.h:210
ULONG_PTR SIZE_T
Definition: typedefs.h:80
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by appbar_message().

◆ send_poschanged()

static void send_poschanged ( HWND  hwnd)
static

Definition at line 97 of file appbar.cpp.

98{
100}
void appbar_notify_all(HMONITOR hMon, UINT uMsg, HWND hwndExclude, LPARAM lParam)
Definition: appbar.cpp:80
#define ABN_POSCHANGED
Definition: shellapi.h:74

Referenced by handle_appbarmessage().

Variable Documentation

◆ appbars

struct list appbars = LIST_INIT(appbars)
static

Definition at line 65 of file appbar.cpp.

Referenced by appbar_cliprect(), appbar_notify_all(), get_appbar(), and handle_appbarmessage().