void ShellSurface::resize(struct wl_client *client,
                  struct wl_resource *shell_surface_resource,
                  struct wl_resource *input_device_super,
                  uint32_t time,
                  uint32_t edges)
{
    Q_UNUSED(shell_surface_resource);
    Q_UNUSED(client);
    Q_UNUSED(time);
    Q_UNUSED(edges);
    ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data);
    InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data);
    if (self->m_moveGrabber || self->m_resizeGrabber) {
        qDebug() << "invalid state2";
        return;
    }
    self->m_resizeGrabber = new ShellSurfaceResizeGrabber(self);
    wl_pointer *pointer = input_device->pointerDevice();
    self->m_resizeGrabber->base()->x = pointer->x;
    self->m_resizeGrabber->base()->y = pointer->y;
    self->m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges);
    self->m_resizeGrabber->width = self->surface()->size().width();
    self->m_resizeGrabber->height = self->surface()->size().height();

    wl_pointer_start_grab(pointer, self->m_resizeGrabber->base());
}
void ShellSurface::set_title(struct wl_client *client,
                             struct wl_resource *resource,
                             const char *title)
{
    Q_UNUSED(client);
    ShellSurface *self = static_cast<ShellSurface *>(resource->data);
    self->surface()->setTitle(QString::fromUtf8(title));
}
Exemple #3
0
ShellSurface *XWlShell::getShellSurface(weston_surface *surface, const weston_shell_client *client)
{
    ShellSurface *shsurf = Shell::instance()->createShellSurface(surface, client);

    XWlShellSurface *iface = new XWlShellSurface;
    shsurf->addInterface(iface);
    surface->configure_private = iface;

    return shsurf;
}
Exemple #4
0
XWayland::XWayland(Shell *shell)
        : Interface(shell)
        , m_shell(shell)
{
    weston_compositor *compositor = shell->compositor()->m_compositor;
    m_xwayland = weston_xserver_create(compositor);
    m_xwayland->spawn_xserver = spawn_xserver;

    compositor->shell_interface.shell = this;
    compositor->shell_interface.create_shell_surface = [](void *shell, weston_surface *surface, const weston_shell_client *client) {
        XWayland *xwl = static_cast<XWayland *>(shell);
        Surface *surf = Surface::fromSurface(surface);
        surf->setRole("xwayland_surface");
        ShellSurface *shsurf = xwl->m_shell->createShellSurface(surf);
        shsurf->setConfigureSender([client, surface](int w, int h) {
            client->send_configure(surface, w, h);
        });
        XWlSurface *xs = new XWlSurface(client, shsurf);
        shsurf->addInterface(xs);
        return (shell_surface *)xs;
    };

#define _this reinterpret_cast<XWlSurface *>(shsurf)->shsurf
    compositor->shell_interface.set_toplevel = [](shell_surface *shsurf) { _this->setToplevel(); };
    compositor->shell_interface.set_transient = [](shell_surface *shsurf, weston_surface *parent, int x, int y, uint32_t flags) {
        _this->setTransient(Surface::fromSurface(parent), x, y, flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
    };
    compositor->shell_interface.set_fullscreen = [](shell_surface *shsurf, uint32_t method, uint32_t framerate, weston_output *output) {
        _this->setFullscreen();
    };
    compositor->shell_interface.resize = [](shell_surface *shsurf, weston_seat *ws, uint32_t edges) {
        if (ws) {
            _this->resize(Seat::fromSeat(ws), (ShellSurface::Edges)edges);
        }
        return 0;
    };
    compositor->shell_interface.move = [](shell_surface *shsurf, weston_seat *ws) {
        if (ws) {
            _this->move(Seat::fromSeat(ws));
        }
        return 0;
    };
    compositor->shell_interface.set_xwayland = [](shell_surface *shsurf, int x, int y, uint32_t flags) {
        _this->setXWayland(x, y, flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
    };
    compositor->shell_interface.set_title = [](shell_surface *shsurf, const char *t) {
        _this->setTitle(t);
    };
    compositor->shell_interface.set_window_geometry = [](shell_surface *shsurf, int32_t x, int32_t y, int32_t w, int32_t h) {
        _this->setGeometry(x, y, w, h);
    };
    compositor->shell_interface.set_maximized = [](shell_surface *shsurf) { _this->setMaximized(); };
    compositor->shell_interface.set_pid = [](shell_surface *shsurf, pid_t pid) { _this->setPid(pid); };
#undef _this
}
Exemple #5
0
void Dashboard::toggleSurface(Seat *seat)
{
    if (seat->pointer()->isGrabActive()) {
        return;
    }

    Orbital::View *focus = m_shell->compositor()->pickView(seat->pointer()->x(), seat->pointer()->y());
    if (!focus) {
        return;
    }

    ShellSurface *shsurf = focus->surface()->shellSurface();
    if (!shsurf) {
        return;
    }

    if (shsurf->workspace() == this) {
        Output *output = m_shell->selectPrimaryOutput();
        shsurf->setWorkspace(output->currentWorkspace());
    } else {
        shsurf->setWorkspace(this);
    }

    // Install a grab to eat the button events
    class Grab : public PointerGrab
    {
    public:
        void motion(uint32_t time, Pointer::MotionEvent evt) override
        {
            pointer()->move(evt);
        }
        void button(uint32_t time, PointerButton button, Pointer::ButtonState state) override
        {
            if (pointer()->buttonCount() == 0) {
                end();
            }
        }
        void ended() override
        {
            delete this;
        }
    };

    Grab *grab = new Grab;
    grab->start(seat);
}
Exemple #6
0
ShellSurface *WlShell::getShellSurface(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface_resource)
{
    weston_surface *surface = static_cast<weston_surface *>(wl_resource_get_user_data(surface_resource));

    if (surface->configure) {
        wl_resource_post_error(surface_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "The surface has a role already");
        return nullptr;
    }

    ShellSurface *shsurf = m_shell->createShellSurface(surface);
    WlShellSurface *wlss = new WlShellSurface(this, shsurf, client, id);
    shsurf->addInterface(wlss);

//     wlss->responsivenessChangedSignal.connect(this, &WlShell::surfaceResponsiveness);
//
    return shsurf;
}
void ShellSurface::move(struct wl_client *client,
                struct wl_resource *shell_surface_resource,
                struct wl_resource *input_device_super,
                uint32_t time)
{
    Q_UNUSED(client);
    Q_UNUSED(time);
    ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data);
    InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data);
    if (self->m_resizeGrabber || self->m_moveGrabber) {
        qDebug() << "invalid state";
        return;
    }

    self->m_moveGrabber = new ShellSurfaceMoveGrabber(self);
    wl_pointer *pointer = input_device->pointerDevice();
    self->m_moveGrabber->base()->x = pointer->x;
    self->m_moveGrabber->base()->y = pointer->y;
    self->m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - self->surface()->pos().x();
    self->m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - self->surface()->pos().y();

    wl_pointer_start_grab(pointer, self->m_moveGrabber->base());
}