void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
{
   if( owner == NULL )
   {
      Con::warnf("PopupMenu::showPopup - Invalid canvas supplied!");
      return;
   }

   // [tom, 6/4/2007] showPopup() blocks until the menu is closed by the user, 
   // so the canvas pointer is not needed beyond the scope of this function
   // when working with context menus. Setting mCanvas here will cause undesired
   // behavior in relation to the menu bar.

   Win32Window *pWindow = dynamic_cast<Win32Window*>(owner->getPlatformWindow());
   if(pWindow == NULL)
      return;
   HWND hWindow = pWindow->getHWND();
   POINT p;
   if(x == -1 && y == -1)
      GetCursorPos(&p);
   else
   {
      p.x = x;
      p.y = y;
      ClientToScreen(hWindow, &p);
   }

   winState.renderThreadBlocked = true;
   U32 opt = (int)TrackPopupMenu(mData->mMenu, TPM_NONOTIFY|TPM_RETURNCMD, p.x, p.y, 0, hWindow, NULL);
   if(opt > 0)
      handleSelect(opt, NULL);
   winState.renderThreadBlocked = false;
}
Exemple #2
0
void processInotifyEvent(FileWatcher *watcher) {
    int ret;
    while (watcher->trigger && watcher->watched_item_number >= 0) {
        struct timeval time_to_wait;
        time_to_wait.tv_sec = watcher->timeout;
        time_to_wait.tv_usec = 0;

        int pid = getTracerpid(watcher->tracerPath, watcher->child);
        if (pid > 0) {
            LOGD("%d being traced, tracer pid is %d. Terminating...", watcher->pid, pid);
            watcher->trigger = false;
            break;
        }

        int r = handleSelect(watcher->fd, &time_to_wait);
        if (r < 0) {
            LOGE("select failed [error:%d, desc:%s]", errno, strerror(errno));
        } else if (r > 0) {
            //handle event
            int event = readEvents(watcher);
            if (event < 0) {
                LOGE("inotify_event read failed [errno:%d, desc:%s]", errno, strerror(errno));
                break;
            } else {
                handleEvents(watcher);
                // communicating
                if (watcher->sinfo) {
                    ret = communicate_send(watcher->sinfo);
                    if (ret == -1) {
                        LOGI("Lost connection.\n");
                        watcher->trigger = false;
                        if (watcher->sinfo->callback) {
                            (watcher->sinfo->callback)();
                        }
                        break;
                    }
                }
            }
        } else if (r == 0) {
            // communicating
            if (watcher->sinfo) {
                ret = communicate_send(watcher->sinfo);
                if (ret == -1) {
                    LOGI("Lost connection.\n");
                    watcher->trigger = false;
                    if (watcher->sinfo->callback) {
                        (watcher->sinfo->callback)();
                    }
                    break;
                }
            }
        }
    }
}
void PopupMenu::handleSelectEvent(U32 popID, U32 command)
{	
	if (popID == mPopupGUID && canHandleID(command))	
		if (handleSelect(command))
			smSelectionEventHandled = true;
}