Beispiel #1
0
void wxIOCPThread::ProcessNativeEvents(wxVector<wxEventProcessingData>& events)
{
    wxVector<wxEventProcessingData>::iterator it = events.begin();
    for ( ; it != events.end(); ++it )
    {
        const FILE_NOTIFY_INFORMATION& e = *(it->nativeEvent);
        const wxFSWatchEntryMSW* watch = it->watch;

        wxLogTrace( wxTRACE_FSWATCHER, "[iocp] %s",
                    FileNotifyInformationToString(e));

        int nativeFlags = e.Action;
        int flags = Native2WatcherFlags(nativeFlags);
        if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
        {
            wxFileSystemWatcherEvent
                event(flags,
                      flags & wxFSW_EVENT_ERROR ? wxFSW_WARNING_NONE
                                                : wxFSW_WARNING_GENERAL);
            SendEvent(event);
        }
        // filter out ignored events and those not asked for.
        // we never filter out warnings or exceptions
        else if ((flags == 0) || !(flags & watch->GetFlags()))
        {
            return;
        }
        // rename case
        else if (nativeFlags == FILE_ACTION_RENAMED_OLD_NAME)
        {
            wxFileName oldpath = GetEventPath(*watch, e);
            wxFileName newpath;

            // newpath should be in the next entry. what if there isn't?
            ++it;
            if ( it != events.end() )
            {
                newpath = GetEventPath(*(it->watch), *(it->nativeEvent));
            }
            wxFileSystemWatcherEvent event(flags, oldpath, newpath);
            SendEvent(event);
        }
        // all other events
        else
        {
            // CHECK I heard that returned path can be either in short on long
            // form...need to account for that!
            wxFileName path = GetEventPath(*watch, e);
            // For files, check that it matches any filespec
            if ( m_service->MatchesFilespec(path, watch->GetFilespec()) )
            {
                wxFileSystemWatcherEvent event(flags, path, path);
                SendEvent(event);
            }
        }
    }
}
// window procedure of a hidden window which is created just to receive
// the notification message when a process exits
LRESULT APIENTRY
wxExecuteWindowCbk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    if ( message == wxWM_PROC_TERMINATED )
    {
        DestroyWindow(hWnd);    // we don't need it any more

        wxExecuteData * const data = (wxExecuteData *)lParam;
        if ( data->handler )
        {
            data->handler->OnTerminate((int)data->dwProcessId,
                                       (int)data->dwExitCode);
        }

        if ( data->state )
        {
            // we're executing synchronously, tell the waiting thread
            // that the process finished
            data->state = false;
        }
        else
        {
            // asynchronous execution - we should do the clean up
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            for ( wxVector<HANDLE>::iterator it = gs_asyncThreads.begin();
                  it != gs_asyncThreads.end();
                  ++it )
            {
                if ( *it == data->hThread )
                {
                    gs_asyncThreads.erase(it);
                    if ( !::CloseHandle(data->hThread) )
                    {
                        wxLogLastError(wxT("CloseHandle(hThread)"));
                    }
                    break;
                }
            }

            delete data;
        }

        return 0;
    }
    else
    {
        return ::DefWindowProc(hWnd, message, wParam, lParam);
    }
}
Beispiel #3
0
// Notification when a sound has stopped
void wxSound::SoundStopped(const wxSoundData* data)
{
    for ( wxVector<wxSoundData*>::iterator s = s_soundsPlaying.begin();
         s != s_soundsPlaying.end(); ++s )
    {
        if ( (*s) == data )
        {
            s_soundsPlaying.erase(s);
            break;
        }
    }
}
Beispiel #4
0
void wxNotificationMessageWindow::RemoveVisibleNotification(wxNotificationMessageWindow* notif)
{
    for ( wxVector<wxNotificationMessageWindow*>::iterator it = ms_visibleNotifications.begin();
        it != ms_visibleNotifications.end(); ++it )
    {
        if ( *it == notif )
        {
            ms_visibleNotifications.erase(it);
            break;
        }
    }
    ResizeAndFitVisibleNotifications();
}
Beispiel #5
0
void wxNotificationMessageWindow::AddVisibleNotification(wxNotificationMessageWindow* notif)
{
    bool found = false;
    for ( wxVector<wxNotificationMessageWindow*>::iterator it = ms_visibleNotifications.begin();
        it != ms_visibleNotifications.end(); ++it )
    {
        if ( *it == notif )
        {
            found = true;
            break;
        }
    }

    if ( !found )
        ms_visibleNotifications.push_back(notif);

    ResizeAndFitVisibleNotifications();
}
Beispiel #6
0
void wxNotificationMessageWindow::ResizeAndFitVisibleNotifications()
{
    if ( ms_presentationDirection == 0 )
    {
        // Determine presentation position

        wxDisplay display;
        wxRect clientArea = display.GetClientArea();
        wxRect geom = display.GetGeometry();
        if ( clientArea.y > 0 ) // Taskbar is at top
        {
            ms_presentationDirection = 1;
            ms_presentationPos = clientArea.GetTopRight();
        }
        else if ( clientArea.GetHeight() != geom.GetHeight() ) // Taskbar at bottom
        {
            ms_presentationDirection = -1;
            ms_presentationPos = clientArea.GetBottomRight();
        }
        else // Default to upper right screen corner with some padding
        {
            ms_presentationDirection = 1;
            ms_presentationPos.x = geom.GetWidth() - 30;
            ms_presentationPos.y = 30;
        }
    }

    int maxWidth = -1;

    // Determine max width
    for (wxVector<wxNotificationMessageWindow*>::iterator notif = ms_visibleNotifications.begin();
        notif != ms_visibleNotifications.end(); ++notif)
    {
        wxSize notifSize = (*notif)->GetSize();
        if ( notifSize.GetWidth() > maxWidth )
            maxWidth = notifSize.GetWidth();
    }

    int notifPadding = 2;

    wxPoint presentPos = ms_presentationPos;
    presentPos.x -= notifPadding + maxWidth;

    int prevNotifHeight = 0;

    for (wxVector<wxNotificationMessageWindow*>::iterator notif = ms_visibleNotifications.begin();
        notif != ms_visibleNotifications.end(); ++notif)
    {
        // Modify existing maxwidth
        wxSize notifSize = (*notif)->GetSize();
        if ( notifSize.GetWidth() < maxWidth )
        {
            notifSize.SetWidth(maxWidth);
            (*notif)->SetSize(notifSize);
            (*notif)->Layout();
        }

        if ( ms_presentationDirection > 0 )
        {
            presentPos.y += (notifPadding + prevNotifHeight);
            prevNotifHeight = notifSize.GetHeight();
        }
        else
        {
            presentPos.y -= (notifPadding + notifSize.GetHeight());
        }

        (*notif)->SetPosition(presentPos);
    }
}