Changeset 281 for trunk/src/3rdparty/os2/xsystray/xsystray_api.c
- Timestamp:
- Nov 2, 2009, 11:32:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/3rdparty/os2/xsystray/xsystray_api.c
r280 r281 26 26 #define INCL_WINPOINTERS 27 27 #define INCL_WINHOOKS 28 28 29 #include <os2.h> 29 30 … … 33 34 #include <string.h> 34 35 #include <sys/builtin.h> // atomics 36 37 35 38 36 39 static ULONG WM_XST_CREATED = 0; … … 56 59 // sounds sane 57 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 58 80 // @todo to be on the safe side with casting in __atomic_cmpxchg32() we need 59 81 // compile-time assertions like this: … … 78 100 } 79 101 80 static BOOLSendSysTrayCtlMsg(PSYSTRAYCTLDATA pData)102 static SendSysTrayCtlMsg(PSYSTRAYCTLDATA pData) 81 103 { 82 104 APIRET arc; … … 112 134 113 135 mrc = WinSendMsg(G_hwndSysTray, WM_XST_CONTROL, pData, NULL); 114 if ( mrc == (MRESULT)TRUE &&pData->bAcknowledged)115 return TRUE;136 if (pData->bAcknowledged) 137 return ; 116 138 117 139 // if we failed to send the message, it may mean that XCenter was restarted … … 126 148 break; 127 149 } 128 while ( TRUE);129 130 return FALSE;150 while (); 151 152 return ; 131 153 } 132 154 … … 183 205 /* 184 206 *@@ InputHook: 185 * This is used to intercept posted XST_NOTIFY messages and apply special186 * processing to them (compose a client window-specific notification187 * message, free the NOTIFYDATA structure and post the composed message to188 * the target window).207 * This is used to intercept posted 208 * 209 * 210 * the target window). 189 211 */ 190 212 … … 243 265 pData->hwndSender = NULLHANDLE; 244 266 245 brc = SendSysTrayCtlMsg(pData) ;267 brc = SendSysTrayCtlMsg(pData); 246 268 if (brc) 247 269 { … … 302 324 ULONG ulFlags) // in: flags (not currently used, must be 0) 303 325 { 304 BOOL brc; 305 PPIB ppib; 326 BOOL brc; 327 ULONG xrc; 328 PPIB ppib; 329 HAB hab; 330 HMQ hmq; 331 size_t i; 332 306 333 PSYSTRAYCTLDATA pData = AllocSysTrayCtlDataPtr(); 307 334 if (!pData) 308 335 return FALSE; 309 336 310 // install the message hook if not already done so311 // @todo the code is temporary and incorrect, it's just for testing312 // (we should use an array of HMQ to check if we already installed the filter)313 337 if (WM_XST_NOTIFY == 0) 314 {315 338 WM_XST_NOTIFY = WinAddAtom(WinQuerySystemAtomTable(), 316 339 WM_XST_NOTIFY_ATOM); 317 340 318 brc = WinSetHook(WinQueryAnchorBlock(hwnd), 319 HMQ_CURRENT, HK_INPUT, (PFN)InputHook, NULLHANDLE); 320 if (!brc) 341 hab = WinQueryAnchorBlock(hwnd); 342 hmq = WinQueryWindowULong(hwnd, QWL_HMQ); 343 if (hmq == NULLHANDLE) 344 return FALSE; 345 346 // initialize the HMQ refs array 347 // @todo remove _smutex usage when we get into the DLL and initialize 348 // _fmutex + array in the DLL init routine 349 _smutex_request(&G_smtx); 350 if (!G_pHmqRefs) 351 { 352 if (_fmutex_create(&G_fmtx, 0)) 321 353 return FALSE; 322 } 354 G_pHmqRefs = malloc(sizeof(*G_pHmqRefs) * HMQREFS_GROW); 355 if (!G_pHmqRefs) 356 return FALSE; 357 G_cHmqRefs = 0; 358 G_cHmqRefsMax = HMQREFS_GROW; 359 } 360 _smutex_release(&G_smtx); 323 361 324 362 // give all processes temporary access to hIcon … … 332 370 pData->u.icon.ulMsgId = ulMsgId; 333 371 334 brc = SendSysTrayCtlMsg(pData); 372 xrc = SendSysTrayCtlMsg(pData); 373 brc = xrc == XST_OK || xrc == XST_REPLACED; 335 374 336 375 // revoke temporary access to hIcon … … 341 380 FreeSysTrayCtlDataPtr(pData); 342 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 343 423 return brc; 344 424 } … … 355 435 BOOL xstRemoveSysTrayIcon(HWND hwnd, // in: window handle associated with the icon 356 436 USHORT usId) // in: icon ID to remove 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 357 503 { 358 504 BOOL brc; … … 361 507 return FALSE; 362 508 363 pData->ulCommand = SYSTRAYCMD_REMOVEICON;364 pData->hwndSender = hwnd;365 pData->u.icon.usId = usId;366 367 brc = SendSysTrayCtlMsg(pData);368 369 FreeSysTrayCtlDataPtr(pData);370 371 return brc;372 }373 374 /*375 *@@ xstSetSysTrayIconToolTip:376 *377 * Sets the tooltip text for the given icon in the system tray. This text378 * is shown when the mouse pointer is held still over the icon area for379 * some time.380 *381 * If pszText is NULL, the tooltip text is reset and will not be shown next382 * time. The old tooltip is hidden if it is being currently shown.383 *384 * Returns TRUE on success and FALSE otherwise.385 *386 * NOTE: The maximum tooltip text length (including terminating null) is387 * limited to a value returned by xstGetSysTrayMaxTextLen(). If the388 * supplied string is longer, it will be truncated.389 */390 391 BOOL xstSetSysTrayIconToolTip(HWND hwnd, // in: window handle associated with the icon392 USHORT usId, // in: icon ID to set the tooltip for393 PSZ pszText) // in: tooltip text394 {395 BOOL brc;396 PSYSTRAYCTLDATA pData = AllocSysTrayCtlDataPtr();397 if (!pData)398 return FALSE;399 400 509 pData->ulCommand = SYSTRAYCMD_SETTOOLTIP; 401 510 pData->hwndSender = hwnd; … … 412 521 } 413 522 414 brc = SendSysTrayCtlMsg(pData) ;523 brc = SendSysTrayCtlMsg(pData); 415 524 416 525 FreeSysTrayCtlDataPtr(pData);
Note:
See TracChangeset
for help on using the changeset viewer.