예제 #1
0
Compositor::Compositor()
    : m_display(wl_display_create())
    , m_time(0)
{
    wl_list_init(&m_outputResources);

    if (wl_display_add_socket(m_display, 0)) {
        fprintf(stderr, "Fatal: Failed to open server socket\n");
        exit(EXIT_FAILURE);
    }

    wl_display_add_global(m_display, &wl_compositor_interface, this, bindCompositor);

    m_data_device_manager.reset(new DataDeviceManager(this, m_display));

    wl_display_init_shm(m_display);

    m_seat.reset(new Seat(this, m_display));
    m_pointer = m_seat->pointer();
    m_keyboard = m_seat->keyboard();

    wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
    wl_display_add_global(m_display, &wl_shell_interface, this, bindShell);

    m_loop = wl_display_get_event_loop(m_display);
    m_fd = wl_event_loop_get_fd(m_loop);
}
예제 #2
0
JNIEXPORT void JNICALL
Java_net_jlekstrand_wheatley_wayland_Compositor_addToLooperNative(JNIEnv *env,
        jclass cls, jlong nativeHandle)
{
    struct wheatley_compositor *wc =
        (struct wheatley_compositor *)(intptr_t)nativeHandle;
    ALooper *looper;

    if (wc->looper) {
        jni_util_throw_by_name(env, "java/lang/IllegalStateException",
                               "Compositor already assigned to a looper");
        return;
    }

    looper = ALooper_forThread();
    if (looper == NULL) {
        jni_util_throw_by_name(env, "java/lang/RuntimeException",
                               "Current thread does not have a Looper");
        return;
    }

    ALooper_addFd(looper,
                  wl_event_loop_get_fd(wl_display_get_event_loop(wc->display)),
                  ALOOPER_POLL_CALLBACK, ALOOPER_EVENT_INPUT | ALOOPER_EVENT_OUTPUT,
                  wheatley_compositor_ALooper_func, wc);

    wc->looper = looper;
}
예제 #3
0
JNIEXPORT void JNICALL
Java_net_jlekstrand_wheatley_wayland_Compositor_removeFromLooperNative(
    JNIEnv *env, jclass cls, jlong nativeHandle)
{
    struct wheatley_compositor *wc =
        (struct wheatley_compositor *)(intptr_t)nativeHandle;
    ALooper *looper;

    if (!wc->looper)
        return;

    looper = ALooper_forThread();
    if (looper == NULL) {
        jni_util_throw_by_name(env, "java/lang/RuntimeException",
                               "Current thread does not have a Looper");
        return;
    }

    if (wc->looper != looper) {
        jni_util_throw_by_name(env, "java/lang/IllegalStateException",
                               "Compositor is not assigned to this looper");
        return;
    }

    wc->looper = NULL;
    ALooper_removeFd(looper,
                     wl_event_loop_get_fd(wl_display_get_event_loop(wc->display)));
}
예제 #4
0
static GSource *
wayland_event_source_new (struct wl_event_loop *loop)
{
  WaylandEventSource *source;

  source = (WaylandEventSource *) g_source_new (&wayland_event_source_funcs,
                                                sizeof (WaylandEventSource));
  source->loop = loop;
  source->pfd.fd = wl_event_loop_get_fd (loop);
  source->pfd.events = G_IO_IN | G_IO_ERR;
  g_source_add_poll (&source->source, &source->pfd);

  return &source->source;
}
예제 #5
0
Compositor::Compositor(QWaylandCompositor *qt_compositor)
    : m_display(new Display)
    , m_default_input_device(0)
    , m_pageFlipper(0)
    , m_current_frame(0)
    , m_last_queued_buf(-1)
    , m_qt_compositor(qt_compositor)
    , m_orientation(Qt::PrimaryOrientation)
    , m_directRenderSurface(0)
    , m_directRenderContext(0)
    , m_directRenderActive(false)
#if defined (QT_COMPOSITOR_WAYLAND_GL)
    , m_graphics_hw_integration(0)
#endif
    , m_outputExtension(0)
    , m_surfaceExtension(0)
    , m_subSurfaceExtension(0)
    , m_touchExtension(0)
    , m_retainNotify(0)
{
    compositor = this;

#if defined (QT_COMPOSITOR_WAYLAND_GL)
    QWindow *window = qt_compositor->window();
    if (window && window->surfaceType() != QWindow::RasterSurface) {
        QStringList keys = QWaylandGraphicsHardwareIntegrationFactory::keys();
        QString targetKey;
        QByteArray hardwareIntegration = qgetenv("QT_WAYLAND_HARDWARE_INTEGRATION");
        if (keys.contains(QString::fromLocal8Bit(hardwareIntegration.constData()))) {
            targetKey = QString::fromLocal8Bit(hardwareIntegration.constData());
        } else if (keys.contains(QString::fromLatin1("wayland-egl"))) {
            targetKey = QString::fromLatin1("wayland-egl");
        } else if (!keys.isEmpty()) {
            targetKey = keys.first();
        }

        if (!targetKey.isEmpty()) {
            m_graphics_hw_integration = QWaylandGraphicsHardwareIntegrationFactory::create(targetKey, QStringList());
            if (m_graphics_hw_integration) {
                m_graphics_hw_integration->setCompositor(qt_compositor);
            }
        }
        //BUG: if there is no hw_integration, bad things will probably happen

    }
#endif
    m_windowManagerIntegration = new WindowManagerServerIntegration(qt_compositor, this);

    wl_display_add_global(m_display->handle(),&wl_compositor_interface,this,Compositor::bind_func);

    m_data_device_manager =  new DataDeviceManager(this);

    wl_display_init_shm(m_display->handle());

    m_output_global = new OutputGlobal(m_display->handle());

    m_shell = new Shell();
    wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func);

    m_outputExtension = new OutputExtensionGlobal(this);
    m_surfaceExtension = new SurfaceExtensionGlobal(this);
    m_qtkeyExtension = new QtKeyExtensionGlobal(this);
    m_touchExtension = new TouchExtensionGlobal(this);

    if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) {
        fprintf(stderr, "Fatal: Failed to open server socket\n");
        exit(EXIT_FAILURE);
    }

    m_loop = wl_display_get_event_loop(m_display->handle());

    int fd = wl_event_loop_get_fd(m_loop);

    QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, this);
    connect(sockNot, SIGNAL(activated(int)), this, SLOT(processWaylandEvents()));

    QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
    connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processWaylandEvents()));

    qRegisterMetaType<SurfaceBuffer*>("SurfaceBuffer*");
    //initialize distancefieldglyphcache here
}