ReactOS  0.4.15-dev-313-g8fde48b
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
 

Functions

static struct appbar_dataget_appbar (HWND hwnd)
 
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)
 

Function Documentation

◆ appbar_cliprect()

static void appbar_cliprect ( HWND  hwnd,
RECT rect 
)
static

Definition at line 92 of file appbar.cpp.

93 {
94  struct appbar_data* data;
96  {
97  if (data->hwnd == hwnd)
98  {
99  /* we only care about appbars that were added before this one */
100  return;
101  }
102  if (data->space_reserved)
103  {
104  /* move in the side that corresponds to the other appbar's edge */
105  switch (data->edge)
106  {
107  case ABE_BOTTOM:
108  rect->bottom = min(rect->bottom, data->rc.top);
109  break;
110  case ABE_LEFT:
111  rect->left = max(rect->left, data->rc.right);
112  break;
113  case ABE_RIGHT:
114  rect->right = min(rect->right, data->rc.left);
115  break;
116  case ABE_TOP:
117  rect->top = max(rect->top, data->rc.bottom);
118  break;
119  }
120  }
121  }
122 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ABE_TOP
Definition: shellapi.h:18
#define max(a, b)
Definition: svc.c:63
#define ABE_LEFT
Definition: shellapi.h:17
& rect
Definition: startmenu.cpp:1413
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define ABE_RIGHT
Definition: shellapi.h:19
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
#define ABE_BOTTOM
Definition: shellapi.h:20
#define min(a, b)
Definition: monoChain.cc:55
static struct list appbars
Definition: appbar.cpp:63

Referenced by handle_appbarmessage().

◆ appbar_message()

LRESULT appbar_message ( COPYDATASTRUCT cds)

Definition at line 220 of file appbar.cpp.

221 {
222  struct appbar_cmd cmd;
224  HANDLE return_hproc;
226  LPVOID return_view;
227  struct appbar_response* response;
228 
229  if (cds->cbData != sizeof(struct appbar_cmd))
230  return TRUE;
231 
232  RtlCopyMemory(&cmd, cds->lpData, cds->cbData);
233 
234  result = handle_appbarmessage(cmd.dwMsg, &cmd.abd);
235 
236  return_hproc = OpenProcess(PROCESS_DUP_HANDLE, FALSE, cmd.return_process);
237  if (return_hproc == NULL)
238  {
239  ERR("couldn't open calling process\n");
240  return TRUE;
241  }
242 
243  if (!DuplicateHandle(return_hproc, UlongToHandle(cmd.return_map), GetCurrentProcess(), &return_map, 0, FALSE, DUPLICATE_SAME_ACCESS))
244  {
245  ERR("couldn't duplicate handle\n");
246  CloseHandle(return_hproc);
247  return TRUE;
248  }
249  CloseHandle(return_hproc);
250 
251  return_view = MapViewOfFile(return_map, FILE_MAP_WRITE, 0, 0, sizeof(struct appbar_response));
252 
253  if (return_view)
254  {
255  response = (struct appbar_response*)return_view;
256  response->result = result;
257  response->abd = cmd.abd;
258 
259  UnmapViewOfFile(return_view);
260  }
261  else
262  {
263  ERR("couldn't map view of file\n");
264  }
265 
266  CloseHandle(return_map);
267  return TRUE;
268 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:407
#define MapViewOfFile
Definition: compat.h:411
Definition: ftp_var.h:139
#define DUPLICATE_SAME_ACCESS
#define PROCESS_DUP_HANDLE
smooth NULL
Definition: ftsmooth.c:416
struct _AppBarData abd
Definition: appbar.cpp:49
static UINT_PTR handle_appbarmessage(DWORD msg, _AppBarData *abd)
Definition: appbar.cpp:124
#define UlongToHandle(ul)
Definition: basetsd.h:97
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define FILE_MAP_WRITE
Definition: winbase.h:154
ULONG return_map
Definition: appbar.cpp:41
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
ULONGLONG result
Definition: appbar.cpp:48
#define ERR(fmt,...)
Definition: debug.h:110
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define UnmapViewOfFile
Definition: compat.h:412
GLuint64EXT * result
Definition: glext.h:11304
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

Referenced by CSysPagerWnd::OnCopyData().

◆ get_appbar()

static struct appbar_data* get_appbar ( HWND  hwnd)
static

Definition at line 65 of file appbar.cpp.

66 {
67  struct appbar_data* data;
68 
70  {
71  if (data->hwnd == hwnd)
72  return data;
73  }
74 
75  return NULL;
76 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
static struct list appbars
Definition: appbar.cpp:63

Referenced by handle_appbarmessage().

◆ handle_appbarmessage()

static UINT_PTR handle_appbarmessage ( DWORD  msg,
_AppBarData abd 
)
static

Definition at line 124 of file appbar.cpp.

125 {
126  struct appbar_data* data;
127  HWND hwnd = abd->hWnd;
128 
129  switch (msg)
130  {
131  case ABM_NEW:
132  if (get_appbar(hwnd))
133  {
134  /* fail when adding an hwnd the second time */
135  return FALSE;
136  }
137 
138  data = (struct appbar_data*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct appbar_data));
139  if (!data)
140  {
141  ERR("out of memory\n");
142  return FALSE;
143  }
144  data->hwnd = hwnd;
145  data->callback_msg = abd->uCallbackMessage;
146 
147  list_add_tail(&appbars, &data->entry);
148 
149  return TRUE;
150  case ABM_REMOVE:
151  if ((data = get_appbar(hwnd)))
152  {
153  list_remove(&data->entry);
154 
156 
158  }
159  else
160  WARN("removing hwnd %p not on the list\n", hwnd);
161  return TRUE;
162  case ABM_QUERYPOS:
163  if (abd->uEdge > ABE_BOTTOM)
164  WARN("invalid edge %i for %p\n", abd->uEdge, hwnd);
165  appbar_cliprect( hwnd, &abd->rc );
166  return TRUE;
167  case ABM_SETPOS:
168  if (abd->uEdge > ABE_BOTTOM)
169  {
170  WARN("invalid edge %i for %p\n", abd->uEdge, hwnd);
171  return TRUE;
172  }
173  if ((data = get_appbar(hwnd)))
174  {
175  /* calculate acceptable space */
176  appbar_cliprect( hwnd, &abd->rc );
177 
178  if (!EqualRect(&abd->rc, &data->rc))
180 
181  /* reserve that space for this appbar */
182  data->edge = abd->uEdge;
183  data->rc = abd->rc;
184  data->space_reserved = TRUE;
185  }
186  else
187  {
188  WARN("app sent ABM_SETPOS message for %p without ABM_ADD\n", hwnd);
189  }
190  return TRUE;
191  case ABM_GETSTATE:
192  FIXME("SHAppBarMessage(ABM_GETSTATE): stub\n");
193  return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
194  case ABM_GETTASKBARPOS:
195  FIXME("SHAppBarMessage(ABM_GETTASKBARPOS, hwnd=%p): stub\n", hwnd);
196  /* Report the taskbar is at the bottom of the screen. */
197  abd->rc.left = 0;
200  abd->rc.top = abd->rc.bottom-1;
201  abd->uEdge = ABE_BOTTOM;
202  return TRUE;
203  case ABM_ACTIVATE:
204  return TRUE;
205  case ABM_GETAUTOHIDEBAR:
206  FIXME("SHAppBarMessage(ABM_GETAUTOHIDEBAR, hwnd=%p, edge=%x): stub\n", hwnd, abd->uEdge);
207  return 0;
208  case ABM_SETAUTOHIDEBAR:
209  FIXME("SHAppBarMessage(ABM_SETAUTOHIDEBAR, hwnd=%p, edge=%x, lparam=%s): stub\n",
210  hwnd, abd->uEdge, wine_dbgstr_longlong(abd->lParam));
211  return TRUE;
213  return TRUE;
214  default:
215  FIXME("SHAppBarMessage(%x) unimplemented\n", msg);
216  return FALSE;
217  }
218 }
#define ABM_GETAUTOHIDEBAR
Definition: shellapi.h:66
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define ABS_AUTOHIDE
Definition: shellapi.h:21
#define WARN(fmt,...)
Definition: debug.h:112
LONG top
Definition: windef.h:307
UINT uCallbackMessage
Definition: shellapi.h:217
#define ABM_GETTASKBARPOS
Definition: shellapi.h:64
HWND hWnd
Definition: shellapi.h:216
static void appbar_cliprect(HWND hwnd, RECT *rect)
Definition: appbar.cpp:92
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
LPARAM lParam
Definition: shellapi.h:220
#define ABM_ACTIVATE
Definition: shellapi.h:65
static struct appbar_data * get_appbar(HWND hwnd)
Definition: appbar.cpp:65
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define SM_CXSCREEN
Definition: winuser.h:949
#define ABM_GETSTATE
Definition: shellapi.h:63
#define FIXME(fmt,...)
Definition: debug.h:111
#define ABS_ALWAYSONTOP
Definition: shellapi.h:22
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define SM_CYSCREEN
Definition: winuser.h:950
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ABM_NEW
Definition: shellapi.h:59
int WINAPI GetSystemMetrics(_In_ int)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ABM_SETAUTOHIDEBAR
Definition: shellapi.h:67
#define ERR(fmt,...)
Definition: debug.h:110
#define ABE_BOTTOM
Definition: shellapi.h:20
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:68
static void send_poschanged(HWND hwnd)
Definition: appbar.cpp:79
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static struct list appbars
Definition: appbar.cpp:63
#define msg(x)
Definition: auth_time.c:54
#define ABM_QUERYPOS
Definition: shellapi.h:61
#define ABM_REMOVE
Definition: shellapi.h:60
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
LONG bottom
Definition: windef.h:309
#define ABM_SETPOS
Definition: shellapi.h:62
UINT uEdge
Definition: shellapi.h:218
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by appbar_message().

◆ send_poschanged()

static void send_poschanged ( HWND  hwnd)
static

Definition at line 79 of file appbar.cpp.

80 {
81  struct appbar_data* data;
83  {
84  if (data->hwnd != hwnd)
85  {
86  PostMessageW(data->hwnd, data->callback_msg, ABN_POSCHANGED, 0);
87  }
88  }
89 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
#define ABN_POSCHANGED
Definition: shellapi.h:70
static struct list appbars
Definition: appbar.cpp:63
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by handle_appbarmessage().

Variable Documentation

◆ appbars

struct list appbars = LIST_INIT(appbars)
static

Definition at line 63 of file appbar.cpp.

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