Example #1
0
void
Clock::Dispose ()
{
	if (!IsDisposed ()) {
		if (GetTimeline () && !Deployment::GetCurrent()->IsShuttingDown ()) {
			timeline->RemoveHandler (EventObject::DestroyedEvent, EventObject::ClearWeakRef, &timeline);

			GetTimeline()->TeardownClock ();
		}

		EventObject::Dispose ();
	}
}
task<bool> SandboxJSExecutor::SendMessageAsync(
    int64_t requestId,
    const std::string& methodName,
    folly::dynamic& arguments) {
  if (!IsDisposed()) {
    task_completion_event<bool> tce;
    m_sandboxEndpoint->SendRequest(requestId, methodName, arguments, [tce](bool sent) {
      tce.set(sent);
    });
    return create_task(tce);
  } else {
    CompleteRequest(requestId);
    return task_from_result(false);
  }
}
FxDriver::~FxDriver()
{
    // Make it always present right now even on free builds
    if (IsDisposed() == FALSE) {
        DoTraceLevelMessage(
            GetDriverGlobals(), TRACE_LEVEL_FATAL, TRACINGDRIVER,
            "FxDriver 0x%p not disposed: this maybe a driver reference count "
            "problem with WDFDRIVER 0x%p", this, GetObjectHandleUnchecked());

        FxVerifierBugCheck(GetDriverGlobals(),
                           WDF_OBJECT_ERROR,
                           (ULONG_PTR) GetObjectHandleUnchecked(),
                           (ULONG_PTR) this);
    }

    //
    // Free the memory for the registry path if required.
    //
    if (m_RegistryPath.Buffer) {
        FxPoolFree(m_RegistryPath.Buffer);
    }

    if (m_DisposeList != NULL) {
        m_DisposeList->DeleteObject();
    }

#if FX_IS_USER_MODE
    //
    // Close the R/W handle to the driver's service parameters key
    // that we opened during Initialize.
    //
    if (m_DriverParametersKey != NULL) {
        NTSTATUS status = FxRegKey::_Close(m_DriverParametersKey);
        if (!NT_SUCCESS(status)) {
            DoTraceLevelMessage(GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGDRIVER,
                                "Cannot close Driver Parameters key %!STATUS!",
                                status);
        }
        m_DriverParametersKey = NULL;
    }

    //
    // The host-created driver object holds a reference to this
    // FxDriver object. Clear it, since this object was deleted.
    //
    ClearDriverObjectFxDriver();
#endif
}
bool GLWindow::Create()
{
    assert ( !IsDestroyed() );
    assert ( IsDisposed() );

    XVisualInfo *vi;
    Colormap cmap;
    int dpyWidth, dpyHeight;
    int i;
    int glxMajorVersion, glxMinorVersion;
    int vidModeMajorVersion, vidModeMinorVersion;
    XF86VidModeModeInfo **modes;
    int modeNum;
    int bestMode;
    Atom wmDelete;
    Window winDummy;
    unsigned int borderDummy;

    /* set best mode to current */
    bestMode = 0;
    /* get a connection */
    hDC = XOpenDisplay(0);
    screen = DefaultScreen(hDC);
    XF86VidModeQueryVersion(hDC, &vidModeMajorVersion, &vidModeMinorVersion);
    printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion,
        vidModeMinorVersion);
    XF86VidModeGetAllModeLines(hDC, screen, &modeNum, &modes);
    /* save desktop-resolution before switching modes */
    deskMode = *modes[0];
    /* look for mode with requested resolution */
    for (i = 0; i < modeNum; i++)
        if ((modes[i]->hdisplay == Width) && (modes[i]->vdisplay == Height))
            bestMode = i;
    /* get an appropriate visual */
    vi = glXChooseVisual(hDC, screen, attrListDbl);
    if (vi == NULL)
    {
        vi = glXChooseVisual(hDC, screen, attrListSgl);
        printf("Only Singlebuffered Visual!\n");
    }
    else
        printf("Got Doublebuffered Visual!\n");
    glXQueryVersion(hDC, &glxMajorVersion, &glxMinorVersion);
    printf("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
    /* create a GLX context */
    glctx = glXCreateContext(hDC, vi, 0, GL_TRUE);
    /* create a color map */
    cmap = XCreateColormap(hDC, RootWindow(hDC, vi->screen),
        vi->visual, AllocNone);
    attr.colormap = cmap;
    attr.border_pixel = 0;

    if (FL_fullscreen)
    {
        XF86VidModeSwitchToMode(hDC, screen, modes[bestMode]);
        XF86VidModeSetViewPort(hDC, screen, 0, 0);
        dpyWidth = modes[bestMode]->hdisplay;
        dpyHeight = modes[bestMode]->vdisplay;
        printf("Resolution %dx%d\n", dpyWidth, dpyHeight);
        XFree(modes);

        /* create a fullscreen window */
        attr.override_redirect = True;
        attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
            FocusChangeMask | EnterWindowMask | StructureNotifyMask;
        win = XCreateWindow(hDC, RootWindow(hDC, vi->screen),
            0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
            &attr);
        XWarpPointer(hDC, None, win, 0, 0, 0, 0, 0, 0);
        XMapRaised(hDC, win);
        XGrabKeyboard(hDC, win, True, GrabModeAsync,
            GrabModeAsync, CurrentTime);
        XGrabPointer(hDC, win, True, ButtonPressMask,
            GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
    }
    else
    {
        /* create a window in window mode*/
        attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
            PointerMotionMask | FocusChangeMask | StructureNotifyMask;
        win = XCreateWindow(hDC, RootWindow(hDC, vi->screen),
            0, 0, Width, Height, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask, &attr);
        /* only set window title and handle wm_delete_events if in windowed mode */
        wmDelete = XInternAtom(hDC, "WM_DELETE_WINDOW", True);
        XSetWMProtocols(hDC, win, &wmDelete, 1);
        XSetStandardProperties(hDC, win, Title,
            Title, None, NULL, 0, NULL);
        XMapRaised(hDC, win);
    }
    /* connect the glx-context to the window */
    glXMakeCurrent(hDC, win, glctx);
    XGetGeometry(hDC, win, &winDummy, &x, &y,
        &Width, &Height, &borderDummy, &depth);
    printf("Depth %d\n", depth);
    if (glXIsDirect(hDC, glctx))
        printf("Congrats, you have Direct Rendering!\n");
    else
        printf("Sorry, no Direct Rendering possible!\n");

    OnCreate();
    this->Resize(Width, Height);

    return true;
}