Sat, 08 Sep 2007 03:09:35 +0000
The FSF changed its address a while ago; our files were out of date.
This is a quick update done with a for loop, find, and sed.
| 14286 | 1 | /* |
| 15884 | 2 | * purple - WinPurple Options Plugin |
| 14286 | 3 | * |
| 4 | * File: gtkappbar.c | |
| 5 | * Date: August 2, 2003 | |
| 6 | * Description: Appbar functionality for Windows GTK+ applications | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
7 | * |
| 14286 | 8 | * Copyright (C) 2003, Herman Bloggs <hermanator12002@yahoo.com> |
| 9 | * | |
| 10 | * This program is free software; you can redistribute it and/or modify | |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19395
diff
changeset
|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 14286 | 23 | * |
| 24 | */ | |
| 25 | /* | |
| 26 | * TODO: | |
| 27 | * - Move 'App on top' feature from Trans plugin to here | |
| 28 | * - Bug: Multiple Show/Hide Desktop calls causes client area to disappear | |
| 29 | */ | |
| 30 | #include <windows.h> | |
| 31 | #include <winver.h> | |
| 32 | #include <stdio.h> | |
| 33 | #include <gtk/gtk.h> | |
| 34 | #include <gdk/gdkwin32.h> | |
| 35 | #include "gtkappbar.h" | |
| 36 | #include "debug.h" | |
| 37 | ||
| 38 | #define APPBAR_CALLBACK WM_USER + 1010 | |
| 39 | ||
| 15884 | 40 | typedef HMONITOR WINAPI purple_MonitorFromPoint(POINT, DWORD); |
| 41 | typedef HMONITOR WINAPI purple_MonitorFromWindow(HWND, DWORD); | |
| 42 | typedef BOOL WINAPI purple_GetMonitorInfo(HMONITOR, LPMONITORINFO); | |
| 14286 | 43 | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
44 | static void gtk_appbar_do_dock(GtkAppBar *ab, UINT side); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
45 | |
| 14286 | 46 | /* Retrieve the rectangular display area from the specified monitor |
| 47 | * Return TRUE if successful, otherwise FALSE | |
| 48 | */ | |
| 49 | static gboolean | |
| 50 | get_rect_from_monitor(HMODULE hmod, HMONITOR monitor, RECT *rect) { | |
| 15884 | 51 | purple_GetMonitorInfo *the_GetMonitorInfo; |
| 14286 | 52 | MONITORINFO info; |
| 53 | ||
| 15884 | 54 | if (!(the_GetMonitorInfo = (purple_GetMonitorInfo*) |
| 14286 | 55 | GetProcAddress(hmod, "GetMonitorInfoA"))) { |
| 56 | return FALSE; | |
| 57 | } | |
| 58 | ||
| 59 | info.cbSize = sizeof(info); | |
| 60 | if (!the_GetMonitorInfo(monitor, &info)) { | |
| 61 | return FALSE; | |
| 62 | } | |
| 63 | ||
| 64 | CopyRect(rect, &(info.rcMonitor)); | |
| 65 | ||
| 66 | return TRUE; | |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * This will only work on Win98+ and Win2K+ | |
| 71 | * Return TRUE if successful, otherwise FALSE | |
| 72 | */ | |
| 73 | static gboolean | |
| 74 | get_rect_at_point_multimonitor(POINT pt, RECT *rect) { | |
| 75 | HMODULE hmod; | |
| 15884 | 76 | purple_MonitorFromPoint *the_MonitorFromPoint; |
| 14286 | 77 | HMONITOR monitor; |
| 78 | ||
| 79 | if (!(hmod = GetModuleHandle("user32"))) { | |
| 80 | return FALSE; | |
| 81 | } | |
| 82 | ||
| 15884 | 83 | if (!(the_MonitorFromPoint = (purple_MonitorFromPoint*) |
| 14286 | 84 | GetProcAddress(hmod, "MonitorFromPoint"))) { |
| 85 | return FALSE; | |
| 86 | } | |
| 87 | ||
| 88 | monitor = | |
| 89 | the_MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); | |
| 90 | ||
| 91 | return get_rect_from_monitor(hmod, monitor, rect); | |
| 92 | } | |
| 93 | ||
| 94 | /** | |
| 95 | * This will only work on Win98+ and Win2K+ | |
| 96 | * Return TRUE if successful, otherwise FALSE | |
| 97 | */ | |
| 98 | static gboolean | |
| 99 | get_rect_of_window_multimonitor(HWND window, RECT *rect) { | |
| 100 | HMODULE hmod; | |
| 15884 | 101 | purple_MonitorFromWindow *the_MonitorFromWindow; |
| 14286 | 102 | HMONITOR monitor; |
| 103 | ||
| 104 | if (!(hmod = GetModuleHandle("user32"))) { | |
| 105 | return FALSE; | |
| 106 | } | |
| 107 | ||
| 15884 | 108 | if (!(the_MonitorFromWindow = (purple_MonitorFromWindow*) |
| 14286 | 109 | GetProcAddress(hmod, "MonitorFromWindow"))) { |
| 110 | return FALSE; | |
| 111 | } | |
| 112 | ||
| 113 | monitor = | |
| 114 | the_MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); | |
| 115 | ||
| 116 | return get_rect_from_monitor(hmod, monitor, rect); | |
| 117 | } | |
| 118 | ||
| 119 | /* | |
| 120 | * Fallback if cannot get the RECT from the monitor directly | |
| 121 | */ | |
| 122 | static void get_default_workarea(RECT *rect) { | |
| 123 | if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, FALSE)) { | |
| 124 | /* I don't think this will ever happen */ | |
| 125 | rect->left = 0; | |
| 126 | rect->top = 0; | |
| 127 | rect->bottom = GetSystemMetrics(SM_CYSCREEN); | |
| 128 | rect->right = GetSystemMetrics(SM_CXSCREEN); | |
| 129 | } | |
| 130 | } | |
| 131 | ||
| 132 | /* Retrieve the rectangle of the active work area at a point */ | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
133 | static void get_rect_at_point(POINT pt, RECT *rc) { |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
134 | if (!get_rect_at_point_multimonitor(pt, rc)) { |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
135 | get_default_workarea(rc); |
| 14286 | 136 | } |
| 137 | } | |
| 138 | ||
| 139 | /* Retrieve the rectangle of the active work area of a window*/ | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
140 | static void get_rect_of_window(HWND window, RECT *rc) { |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
141 | if (!get_rect_of_window_multimonitor(window, rc)) { |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
142 | get_default_workarea(rc); |
| 14286 | 143 | } |
| 144 | } | |
| 145 | ||
| 146 | static void get_window_normal_rc(HWND hwnd, RECT *rc) { | |
| 147 | WINDOWPLACEMENT wplc; | |
| 148 | GetWindowPlacement(hwnd, &wplc); | |
| 149 | CopyRect(rc, &wplc.rcNormalPosition); | |
| 150 | } | |
| 151 | #if 0 | |
| 152 | static void print_rect(RECT *rc) { | |
| 15884 | 153 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "RECT: L:%ld R:%ld T:%ld B:%ld\n", |
| 14286 | 154 | rc->left, rc->right, rc->top, rc->bottom); |
| 155 | } | |
| 156 | #endif | |
| 157 | /** Set the window style to be the "Tool Window" style - small header, no min/max buttons */ | |
| 158 | static void set_toolbar(HWND hwnd, gboolean val) { | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
159 | LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); |
| 14286 | 160 | |
| 161 | if(val && !(style & WS_EX_TOOLWINDOW)) | |
| 162 | style |= WS_EX_TOOLWINDOW; | |
| 163 | else if(!val && style & WS_EX_TOOLWINDOW) | |
| 164 | style &= ~WS_EX_TOOLWINDOW; | |
| 165 | else | |
| 166 | return; | |
| 167 | SetWindowLong(hwnd, GWL_EXSTYLE, style); | |
| 168 | SetWindowPos(hwnd, 0, 0, 0, 0, 0, | |
| 169 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
| 170 | ||
| 171 | /* This really should be the following, but SWP_FRAMECHANGED strangely causes initermittent problems "Show Desktop" done more than once. | |
| 172 | * Not having SWP_FRAMECHANGED *should* cause the Style not to be applied, but i haven't noticed any problems | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
173 | * SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); |
| 14286 | 174 | */ |
| 175 | } | |
| 176 | /** Register the window as an appbar */ | |
| 177 | static gboolean gtk_appbar_register(GtkAppBar *ab, HWND hwnd) { | |
| 178 | APPBARDATA abd; | |
| 179 | ||
| 180 | abd.cbSize = sizeof(APPBARDATA); | |
| 181 | abd.hWnd = hwnd; | |
| 182 | abd.uCallbackMessage = APPBAR_CALLBACK; | |
| 183 | ||
| 184 | ab->registered = SHAppBarMessage(ABM_NEW, &abd); | |
| 185 | ||
| 186 | return ab->registered; | |
| 187 | } | |
| 188 | /** Unregister the window as an appbar */ | |
| 189 | static gboolean gtk_appbar_unregister(GtkAppBar *ab, HWND hwnd) { | |
| 190 | APPBARDATA abd; | |
| 191 | ||
| 192 | if(!ab->registered) | |
| 193 | return TRUE; | |
| 194 | ||
| 195 | abd.cbSize = sizeof(APPBARDATA); | |
| 196 | abd.hWnd = hwnd; | |
| 197 | ||
| 198 | SHAppBarMessage(ABM_REMOVE, &abd); /** This always returns TRUE */ | |
| 199 | ||
| 200 | ab->registered = FALSE; | |
| 201 | ||
| 202 | ab->docked = FALSE; | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
203 | ab->undocking = FALSE; |
| 14286 | 204 | ab->docking = FALSE; |
| 205 | ||
| 206 | return TRUE; | |
| 207 | } | |
| 208 | ||
| 209 | static void gtk_appbar_querypos(GtkAppBar *ab, HWND hwnd, RECT rcWorkspace) { | |
| 210 | APPBARDATA abd; | |
| 211 | guint iWidth = 0; | |
| 212 | ||
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
213 | if(!ab->registered) |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
214 | gtk_appbar_register(ab, hwnd); |
| 14286 | 215 | |
| 216 | abd.hWnd = hwnd; | |
| 217 | abd.cbSize = sizeof(APPBARDATA); | |
| 218 | abd.uEdge = ab->side; | |
| 219 | ||
| 220 | iWidth = ab->docked_rect.right - ab->docked_rect.left; | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
221 | |
| 14286 | 222 | abd.rc.top = rcWorkspace.top; |
| 223 | abd.rc.bottom = rcWorkspace.bottom; | |
| 224 | switch (abd.uEdge) | |
| 225 | { | |
| 226 | case ABE_LEFT: | |
| 227 | abd.rc.left = rcWorkspace.left; | |
| 228 | abd.rc.right = rcWorkspace.left + iWidth; | |
| 229 | break; | |
| 230 | ||
| 231 | case ABE_RIGHT: | |
| 232 | abd.rc.right = rcWorkspace.right; | |
| 233 | abd.rc.left = rcWorkspace.right - iWidth; | |
| 234 | break; | |
| 235 | } | |
| 236 | ||
| 237 | /* Ask the system for the screen space */ | |
| 238 | SHAppBarMessage(ABM_QUERYPOS, &abd); | |
| 239 | ||
| 240 | switch (abd.uEdge) | |
| 241 | { | |
| 242 | case ABE_LEFT: | |
| 243 | abd.rc.right = abd.rc.left + iWidth; | |
| 244 | break; | |
| 245 | ||
| 246 | case ABE_RIGHT: | |
| 247 | abd.rc.left = abd.rc.right - iWidth; | |
| 248 | break; | |
| 249 | } | |
| 250 | ||
| 251 | CopyRect(&(ab->docked_rect), &abd.rc); | |
| 252 | } | |
| 253 | /* Actually set the size and screen location of the appbar */ | |
| 254 | static void gtk_appbar_setpos(GtkAppBar *ab, HWND hwnd) { | |
| 255 | APPBARDATA abd; | |
| 256 | ||
| 257 | if(!ab->registered) | |
| 258 | gtk_appbar_register(ab, hwnd); | |
| 259 | ||
| 260 | abd.hWnd = hwnd; | |
| 261 | abd.cbSize = sizeof(APPBARDATA); | |
| 262 | CopyRect(&abd.rc, &(ab->docked_rect)); | |
| 263 | abd.uEdge = ab->side; | |
| 264 | ||
| 265 | SHAppBarMessage(ABM_SETPOS, &abd); | |
| 266 | } | |
| 267 | /** Let any callbacks know that we have docked or undocked */ | |
| 268 | static void gtk_appbar_dispatch_dock_cbs(GtkAppBar *ab, gboolean val) { | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
269 | GSList *lst = ab->dock_cbs; |
| 14286 | 270 | |
| 271 | while(lst) { | |
| 272 | GtkAppBarDockCB dock_cb = lst->data; | |
| 273 | dock_cb(val); | |
| 274 | lst = lst->next; | |
| 275 | } | |
| 276 | } | |
| 277 | ||
| 278 | static GdkFilterReturn wnd_moving(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 279 | MSG *msg = (MSG*)xevent; | |
| 280 | POINT cp; | |
| 281 | RECT *rc = (RECT*)msg->lParam; | |
| 282 | RECT monRect; | |
| 283 | int side = -1; | |
| 284 | long dockAreaWidth = 0; | |
| 285 | ||
| 15884 | 286 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_moving\n"); |
| 14286 | 287 | |
| 288 | GetCursorPos(&cp); | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
289 | get_rect_at_point(cp, &monRect); |
| 14286 | 290 | |
| 291 | dockAreaWidth = (monRect.right - monRect.left) / 10; | |
| 292 | /* Which part of the screen are we in ? */ | |
| 293 | if (cp.x > (monRect.right - dockAreaWidth)) { | |
| 294 | side = ABE_RIGHT; | |
| 295 | } else if (cp.x < (monRect.left + dockAreaWidth)) { | |
| 296 | side = ABE_LEFT; | |
| 297 | } | |
| 298 | ||
| 299 | if(!ab->docked) { | |
| 300 | if( (side == ABE_RIGHT || side == ABE_LEFT) ) { | |
| 301 | if( !ab->docking ) { | |
| 302 | ab->side = side; | |
| 303 | GetWindowRect(msg->hwnd, &(ab->docked_rect)); | |
| 304 | gtk_appbar_querypos(ab, msg->hwnd, monRect); | |
| 305 | ||
| 306 | /* save pre-docking height */ | |
| 307 | ab->undocked_height = rc->bottom - rc->top; | |
| 308 | ab->docking = TRUE; | |
| 309 | } | |
| 310 | } | |
| 311 | else | |
| 312 | ab->docking = FALSE; | |
| 313 | } | |
| 314 | else if(side < 0) { | |
| 315 | gtk_appbar_unregister(ab, msg->hwnd); | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
316 | ab->undocking = TRUE; |
| 14286 | 317 | rc->bottom = rc->top + ab->undocked_height; |
| 318 | } | |
| 319 | ||
| 320 | return GDK_FILTER_CONTINUE; | |
| 321 | } | |
| 322 | ||
| 323 | static GdkFilterReturn wnd_sizing(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 324 | MSG *msg = (MSG*)xevent; | |
| 325 | ||
| 15884 | 326 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_sizing\n"); |
| 14286 | 327 | if(ab->docked) { |
| 328 | RECT *rc = (RECT*)msg->lParam; | |
| 329 | if(ab->side == ABE_LEFT && msg->wParam == WMSZ_RIGHT) { | |
| 330 | ab->docked_rect.right = rc->right; | |
| 331 | gtk_appbar_setpos(ab, msg->hwnd); | |
| 332 | } | |
| 333 | else if(ab->side == ABE_RIGHT && msg->wParam == WMSZ_LEFT) { | |
| 334 | ab->docked_rect.left = rc->left; | |
| 335 | gtk_appbar_setpos(ab, msg->hwnd); | |
| 336 | } | |
| 337 | return GDK_FILTER_REMOVE; | |
| 338 | } | |
| 339 | return GDK_FILTER_CONTINUE; | |
| 340 | } | |
| 341 | /** Notify the system that the appbar has been activated */ | |
| 342 | static GdkFilterReturn wnd_activate(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 343 | if (ab->registered) { | |
| 344 | APPBARDATA abd; | |
| 345 | MSG *msg = (MSG*)xevent; | |
| 15884 | 346 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_activate\n"); |
| 14286 | 347 | |
| 348 | abd.hWnd = msg->hwnd; | |
| 349 | abd.cbSize = sizeof(APPBARDATA); | |
| 350 | ||
| 351 | SHAppBarMessage(ABM_ACTIVATE, &abd); | |
| 352 | } | |
| 353 | return GDK_FILTER_CONTINUE; | |
| 354 | } | |
| 355 | /** Notify the system that the appbar's position has changed */ | |
| 356 | static GdkFilterReturn wnd_poschanged(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 357 | if (ab->registered) { | |
| 358 | APPBARDATA abd; | |
| 359 | MSG *msg = (MSG*)xevent; | |
| 15884 | 360 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_poschanged\n"); |
| 14286 | 361 | |
| 362 | abd.hWnd = msg->hwnd; | |
| 363 | abd.cbSize = sizeof(APPBARDATA); | |
| 364 | ||
| 365 | SHAppBarMessage(ABM_WINDOWPOSCHANGED, &abd); | |
| 366 | } | |
| 367 | return GDK_FILTER_CONTINUE; | |
| 368 | } | |
| 369 | /** The window is about to change */ | |
| 370 | static GdkFilterReturn wnd_poschanging(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 371 | MSG *msg = (MSG*)xevent; | |
| 372 | WINDOWPOS *wpos = (WINDOWPOS*)msg->lParam; | |
| 373 | ||
| 15884 | 374 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_poschanging\n"); |
| 14286 | 375 | |
| 376 | if(ab->docked || ab->docking) { | |
| 377 | wpos->x = ab->docked_rect.left; | |
| 378 | wpos->y = ab->docked_rect.top; | |
| 379 | wpos->cx = ab->docked_rect.right - ab->docked_rect.left; | |
| 380 | wpos->cy = ab->docked_rect.bottom - ab->docked_rect.top; | |
| 381 | if(IsIconic(msg->hwnd)) | |
| 382 | set_toolbar(msg->hwnd, FALSE); | |
| 383 | /*return GDK_FILTER_REMOVE;*/ | |
| 384 | } | |
| 385 | return GDK_FILTER_CONTINUE; | |
| 386 | } | |
| 387 | ||
| 388 | static GdkFilterReturn wnd_exitsizemove(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 389 | MSG *msg = (MSG*)xevent; | |
| 390 | ||
| 15884 | 391 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_exitsizemove\n"); |
| 14286 | 392 | if(ab->docking) { |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
393 | gtk_appbar_setpos(ab, msg->hwnd); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
394 | ab->docking = FALSE; |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
395 | ab->docked = TRUE; |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
396 | ShowWindow(msg->hwnd, SW_HIDE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
397 | set_toolbar(msg->hwnd, TRUE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
398 | ShowWindow(msg->hwnd, SW_SHOW); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
399 | gtk_appbar_dispatch_dock_cbs(ab, TRUE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
400 | } else if(ab->undocking) { |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
401 | ShowWindow(msg->hwnd, SW_HIDE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
402 | set_toolbar(msg->hwnd, FALSE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
403 | ShowWindow(msg->hwnd, SW_SHOW); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
404 | gtk_appbar_dispatch_dock_cbs(ab, FALSE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
405 | ab->undocking = FALSE; |
| 14286 | 406 | } |
| 407 | ||
| 408 | return GDK_FILTER_CONTINUE; | |
| 409 | } | |
| 410 | ||
| 411 | static GdkFilterReturn wnd_showwindow(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 412 | MSG *msg = (MSG*)xevent; | |
| 413 | ||
| 15884 | 414 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_showwindow\n"); |
| 14286 | 415 | if(msg->wParam && ab->docked) { |
| 416 | ab->iconized = FALSE; | |
| 15884 | 417 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "shown\n"); |
| 14286 | 418 | ab->docked = FALSE; |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
419 | gtk_appbar_do_dock(ab, ab->side); |
| 14286 | 420 | } |
| 421 | else if(!msg->wParam && ab->docked) { | |
| 15884 | 422 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "hidden\n"); |
| 14286 | 423 | gtk_appbar_unregister(ab, GDK_WINDOW_HWND(ab->win->window)); |
| 424 | ab->docked = TRUE; | |
| 425 | ab->iconized = TRUE; | |
| 426 | } | |
| 427 | return GDK_FILTER_CONTINUE; | |
| 428 | } | |
| 429 | /** The window's size has changed */ | |
| 430 | static GdkFilterReturn wnd_size(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 431 | MSG *msg = (MSG*)xevent; | |
| 432 | ||
| 15884 | 433 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_size\n"); |
| 14286 | 434 | |
| 435 | if(msg->wParam == SIZE_MINIMIZED) { | |
| 15884 | 436 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "Minimize\n"); |
| 14286 | 437 | if(ab->docked) { |
| 438 | gtk_appbar_unregister(ab, GDK_WINDOW_HWND(ab->win->window)); | |
| 439 | ab->docked = TRUE; | |
| 440 | } | |
| 441 | } | |
| 442 | else if(msg->wParam == SIZE_RESTORED) { | |
| 15884 | 443 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "Restore\n"); |
| 14286 | 444 | if (!ab->iconized && ab->docked) { |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
445 | gtk_appbar_do_dock(ab, ab->side); |
| 14286 | 446 | } |
| 447 | } | |
| 448 | return GDK_FILTER_CONTINUE; | |
| 449 | } | |
| 450 | ||
| 451 | static GdkFilterReturn wnd_nchittest(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 452 | MSG *msg = (MSG*)xevent; | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
453 | |
| 14286 | 454 | if(ab->docked) { |
| 455 | UINT ret = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam); | |
| 456 | ||
| 457 | switch(ret) { | |
| 458 | case HTBOTTOM: | |
| 459 | case HTBOTTOMLEFT: | |
| 460 | case HTBOTTOMRIGHT: | |
| 461 | case HTTOP: | |
| 462 | case HTTOPLEFT: | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
463 | case HTTOPRIGHT: |
| 14286 | 464 | return GDK_FILTER_REMOVE; |
| 465 | case HTLEFT: | |
| 466 | if(ab->side == ABE_LEFT) | |
| 467 | return GDK_FILTER_REMOVE; | |
| 468 | break; | |
| 469 | case HTRIGHT: | |
| 470 | if(ab->side == ABE_RIGHT) | |
| 471 | return GDK_FILTER_REMOVE; | |
| 472 | break; | |
| 473 | } | |
| 474 | } | |
| 475 | return GDK_FILTER_CONTINUE; | |
| 476 | } | |
| 477 | ||
| 478 | #if 0 | |
| 479 | static GdkFilterReturn wnd_initmenupopup(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 480 | MSG *msg = (MSG*)xevent; | |
| 481 | ||
| 482 | if(ab->docked && HIWORD(msg->lParam)) { | |
| 483 | HMENU sysmenu = GetSystemMenu(msg->hwnd, FALSE); | |
| 15884 | 484 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "wnd_initpopupmenu: docked: %d ismenu: %d\n", ab->docked, IsMenu(sysmenu)); |
| 14286 | 485 | if(EnableMenuItem(sysmenu, SC_MAXIMIZE, MF_BYCOMMAND|MF_GRAYED)<0) |
| 15884 | 486 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "SC_MAXIMIZE Menu item does not exist\n"); |
| 14286 | 487 | if(EnableMenuItem(sysmenu, SC_MOVE, MF_BYCOMMAND|MF_GRAYED)<0) |
| 15884 | 488 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "SC_MOVE Menu item does not exist\n"); |
| 14286 | 489 | return GDK_FILTER_CONTINUE; |
| 490 | } | |
| 491 | else | |
| 492 | GetSystemMenu(msg->hwnd, TRUE); | |
| 493 | return GDK_FILTER_CONTINUE; | |
| 494 | } | |
| 495 | #endif | |
| 496 | ||
| 497 | static GdkFilterReturn gtk_appbar_callback(GtkAppBar *ab, GdkXEvent *xevent) { | |
| 498 | MSG *msg = (MSG*)xevent; | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
499 | RECT orig, windowRect; |
| 14286 | 500 | |
| 501 | switch (msg->wParam) { | |
| 502 | case ABN_STATECHANGE: | |
| 15884 | 503 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_STATECHANGE\n"); |
| 14286 | 504 | break; |
| 505 | ||
| 506 | case ABN_FULLSCREENAPP: | |
| 15884 | 507 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_FULLSCREENAPP: %d\n", (BOOL)msg->lParam); |
| 14286 | 508 | if (!ab->iconized && ab->docked) { |
| 509 | if ((BOOL)msg->lParam) { | |
| 510 | SetWindowPos(msg->hwnd, HWND_BOTTOM, 0, 0, 0, 0, | |
| 511 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
| 512 | } else { | |
| 513 | SetWindowPos(msg->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, | |
| 514 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED); | |
| 515 | } | |
| 516 | } | |
| 517 | ||
| 518 | break; | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
519 | case ABN_POSCHANGED: |
| 15884 | 520 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_POSCHANGED\n"); |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
521 | CopyRect(&orig, &(ab->docked_rect)); |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
522 | get_rect_of_window(msg->hwnd, &windowRect); |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
523 | gtk_appbar_querypos(ab, msg->hwnd, windowRect); |
| 14286 | 524 | if (EqualRect(&orig, &(ab->docked_rect)) == 0) { |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
525 | MoveWindow(msg->hwnd, ab->docked_rect.left, ab->docked_rect.top, |
| 14286 | 526 | ab->docked_rect.right - ab->docked_rect.left, |
| 527 | ab->docked_rect.bottom - ab->docked_rect.top, TRUE); | |
| 528 | } | |
| 529 | gtk_appbar_setpos(ab, msg->hwnd); | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
530 | break; |
| 14286 | 531 | #if 0 |
| 532 | default: | |
| 15884 | 533 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: %d\n", msg->wParam); |
| 14286 | 534 | #endif |
| 535 | } | |
| 536 | return GDK_FILTER_CONTINUE; | |
| 537 | } | |
| 538 | ||
| 539 | static GdkFilterReturn gtk_appbar_event_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) { | |
| 540 | MSG *msg = (MSG*)xevent; | |
| 541 | ||
| 542 | /*printf("MSG: %s\n", message_to_string (msg->message));*/ | |
| 543 | switch(msg->message) { | |
| 544 | case WM_EXITSIZEMOVE: | |
| 545 | return wnd_exitsizemove(data, xevent); | |
| 546 | case WM_WINDOWPOSCHANGING: | |
| 547 | return wnd_poschanging(data, xevent); | |
| 548 | case WM_WINDOWPOSCHANGED: | |
| 549 | return wnd_poschanged(data, xevent); | |
| 550 | case WM_ACTIVATE: | |
| 551 | return wnd_activate(data, xevent); | |
| 552 | case WM_SIZING: | |
| 553 | return wnd_sizing(data, xevent); | |
| 554 | case WM_MOVING: | |
| 555 | return wnd_moving(data, xevent); | |
| 556 | case WM_SHOWWINDOW: | |
| 557 | return wnd_showwindow(data, xevent); | |
| 558 | case WM_NCHITTEST: | |
| 559 | return wnd_nchittest(data, xevent); | |
| 560 | #if 0 | |
| 561 | case WM_INITMENUPOPUP: | |
| 562 | return wnd_initmenupopup(data, xevent); | |
| 563 | #endif | |
| 564 | case WM_SIZE: | |
| 565 | return wnd_size(data, xevent); | |
| 566 | case APPBAR_CALLBACK: | |
| 567 | return gtk_appbar_callback(data, xevent); | |
| 568 | #if 0 | |
| 569 | default: | |
| 15884 | 570 | purple_debug_info("gtkappbar", "gtk_appbar_event_filter %d\n", msg->message); |
| 14286 | 571 | #endif |
| 572 | } | |
| 573 | return GDK_FILTER_CONTINUE; | |
| 574 | } | |
| 575 | ||
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
576 | static void gtk_appbar_do_dock(GtkAppBar *ab, UINT side) { |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
577 | RECT orig, windowRect; |
| 14286 | 578 | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
579 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_do_dock\n"); |
| 14286 | 580 | |
| 581 | if(!ab || !IsWindow(GDK_WINDOW_HWND(ab->win->window))) | |
| 582 | return; | |
| 583 | ||
| 584 | ab->side = side; | |
| 585 | get_window_normal_rc(GDK_WINDOW_HWND(ab->win->window), &(ab->docked_rect)); | |
| 586 | CopyRect(&orig, &(ab->docked_rect)); | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
587 | get_rect_of_window(GDK_WINDOW_HWND(ab->win->window), &windowRect); |
|
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
588 | gtk_appbar_querypos(ab, GDK_WINDOW_HWND(ab->win->window), windowRect); |
| 14286 | 589 | if(EqualRect(&orig, &(ab->docked_rect)) == 0) |
| 590 | MoveWindow(GDK_WINDOW_HWND(ab->win->window), | |
| 591 | ab->docked_rect.left, | |
|
15697
78ddac185d80
winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
592 | ab->docked_rect.top, |
| 14286 | 593 | ab->docked_rect.right - ab->docked_rect.left, |
| 594 | ab->docked_rect.bottom - ab->docked_rect.top, TRUE); | |
| 595 | gtk_appbar_setpos(ab, GDK_WINDOW_HWND(ab->win->window)); | |
| 596 | ab->docked = TRUE; | |
| 597 | } | |
| 598 | ||
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
599 | void gtk_appbar_dock(GtkAppBar *ab, UINT side) { |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
600 | HWND hwnd; |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
601 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
602 | g_return_if_fail(ab != NULL); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
603 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
604 | hwnd = GDK_WINDOW_HWND(ab->win->window); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
605 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
606 | g_return_if_fail(IsWindow(hwnd)); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
607 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
608 | ab->iconized = IsIconic(hwnd); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
609 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
610 | if (!ab->docked && !ab->iconized) |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
611 | ShowWindow(hwnd, SW_HIDE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
612 | gtk_appbar_do_dock(ab, side); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
613 | set_toolbar(hwnd, TRUE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
614 | if (!ab->iconized) |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
615 | ShowWindow(hwnd, SW_SHOW); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
616 | } |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
617 | |
| 14286 | 618 | void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb) { |
| 619 | if(!ab) | |
| 620 | return; | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
621 | ab->dock_cbs = g_slist_prepend(ab->dock_cbs, dock_cb); |
| 14286 | 622 | } |
| 623 | ||
| 624 | GtkAppBar *gtk_appbar_add(GtkWidget *win) { | |
| 625 | GtkAppBar *ab; | |
| 626 | ||
| 15884 | 627 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_add\n"); |
| 14286 | 628 | |
| 629 | if(!win) | |
| 630 | return NULL; | |
| 631 | ab = g_new0(GtkAppBar, 1); | |
| 632 | ab->win = win; | |
| 633 | ||
| 634 | /* init docking coords */ | |
| 635 | get_window_normal_rc(GDK_WINDOW_HWND(win->window), &(ab->docked_rect)); | |
| 636 | ||
| 637 | /* Add main window filter */ | |
| 638 | gdk_window_add_filter(win->window, | |
| 639 | gtk_appbar_event_filter, | |
| 640 | ab); | |
| 641 | return ab; | |
| 642 | } | |
| 643 | ||
| 644 | void gtk_appbar_remove(GtkAppBar *ab) { | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
645 | HWND hwnd; |
| 15884 | 646 | purple_debug(PURPLE_DEBUG_INFO, "gtkappbar", "gtk_appbar_remove\n"); |
| 14286 | 647 | |
| 648 | if(!ab) | |
| 649 | return; | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
650 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
651 | hwnd = GDK_WINDOW_HWND(ab->win->window); |
| 14286 | 652 | gdk_window_remove_filter(ab->win->window, |
| 653 | gtk_appbar_event_filter, | |
| 654 | ab); | |
| 655 | if(ab->docked) { | |
| 656 | gtk_window_resize(GTK_WINDOW(ab->win), | |
| 657 | ab->docked_rect.right - ab->docked_rect.left, | |
| 658 | ab->undocked_height); | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
659 | if (!ab->iconized) |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
660 | ShowWindow(hwnd, SW_HIDE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
661 | set_toolbar(hwnd, FALSE); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
662 | if (!ab->iconized) |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
663 | ShowWindow(hwnd, SW_SHOW); |
| 14286 | 664 | } |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
665 | gtk_appbar_unregister(ab, hwnd); |
| 14286 | 666 | |
|
19395
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
667 | while (ab->dock_cbs) |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
668 | ab->dock_cbs = g_slist_remove(ab->dock_cbs, ab->dock_cbs->data); |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
669 | |
|
13e591244b33
Fix the docked buddy list to consistently not have a taskbar entry thanks to some tips from "imiganai." This took *way* too long because of how arcane dealing with Windows on Windows is (the unnecessary complexity of our gtkappbar implementation doesn't help). Hopefully this doesn't break anything. Fixes #575.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
670 | g_free(ab); |
| 14286 | 671 | } |