Skip to content

Commit

Permalink
Update mag.cpp to work with wlroots 0.15.1 (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusbritanicus committed May 30, 2022
1 parent 5c4ed0d commit cf95ac7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ubuntu-latest
container: alpine:edge
steps:
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev eudev-dev libxml2-dev libexecinfo-dev glibmm-dev
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev eudev-dev libxml2-dev libexecinfo-dev glibmm-dev pango-dev libseat-dev
- name: Wayfire
uses: actions/checkout@v2
with:
repository: WayfireWM/wayfire
path: wayfire
- run: cd wayfire && git submodule sync --recursive && git submodule update --init --force --recursive && meson build --prefix=/usr && ninja -v -Cbuild && ninja -v -Cbuild install && cd ..
- run: cd wayfire && git pull --all && git checkout 0.7.x && git submodule sync --recursive && git submodule update --init --force --recursive && meson build --prefix=/usr && ninja -v -Cbuild && ninja -v -Cbuild install && cd ..
- name: Wayfire Plugins Extra
uses: actions/checkout@v2
with:
Expand All @@ -31,13 +31,13 @@ jobs:
steps:
- run: (pacman-key --keyserver hkp://keys.gnupg.net --recv-key EA50C866329648EE || pacman-key --keyserver hkp://pool.sks-keyservers.net --recv-key EA50C866329648EE || pacman-key --keyserver hkp://pgp.mit.edu --recv-key EA50C866329648EE) && echo "[andontie-aur]" >> /etc/pacman.conf && echo "Server = https://aur.andontie.net/\$arch" >> /etc/pacman.conf && echo "SigLevel = Never" >> /etc/pacman.conf
- run: pacman --noconfirm --noprogressbar -Syyu
- run: pacman --noconfirm --noprogressbar -Sy git clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo glibmm
- run: pacman --noconfirm --noprogressbar -Sy git clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo glibmm pango seatd systemd
- name: Wayfire
uses: actions/checkout@v2
with:
repository: WayfireWM/wayfire
path: wayfire
- run: cd wayfire && git submodule sync --recursive && git submodule update --init --force --recursive && meson build --prefix=/usr && ninja -v -Cbuild && ninja -v -Cbuild install && cd ..
- run: cd wayfire && git pull --all && git checkout 0.7.x && git submodule sync --recursive && git submodule update --init --force --recursive && meson build --prefix=/usr && ninja -v -Cbuild && ninja -v -Cbuild install && cd ..
- name: Wayfire Plugins Extra
uses: actions/checkout@v2
with:
Expand Down
51 changes: 13 additions & 38 deletions src/mag.cpp
Expand Up @@ -35,16 +35,6 @@
#include "wayfire/opengl.hpp"
#include <glm/gtc/matrix_transform.hpp>

extern "C"
{
#define static
#include <wlr/config.h>
#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h>
#undef static
}

#include <wayfire/util/log.hpp>


Expand Down Expand Up @@ -171,19 +161,6 @@ class wayfire_magnifier : public wf::plugin_interface_t

wf::effect_hook_t post_hook = [=] ()
{
wlr_dmabuf_attributes dmabuf_attribs;

/* This plugin only works if this function succeeds. It will not
* work with the x11 backend but works with drm, for example. */
if (!wlr_output_export_dmabuf(output->handle, &dmabuf_attribs))
{
LOGE("Failed reading output contents");
deactivate();
active = false;

return;
}

auto cursor_position = output->get_cursor_position();

auto ortho = output->render->get_target_framebuffer()
Expand All @@ -201,9 +178,6 @@ class wayfire_magnifier : public wf::plugin_interface_t
float y = cursor.y;

auto og = output->get_relative_geometry();
gl_geometry src_geometry = {0, 0, (float)og.width, (float)og.height};
auto transform = output->render->get_target_framebuffer().transform;
transform = glm::inverse(transform);

width = og.width;
height = og.height;
Expand All @@ -220,6 +194,9 @@ class wayfire_magnifier : public wf::plugin_interface_t
/* Compute zoom_box, forcing the zoom to stay on the output */
gl_geometry zoom_box;

/* Y-invert */
y = 1.0 - y;

zoom_box.x1 = x - level;
zoom_box.y1 = y - level;
zoom_box.x2 = x + level;
Expand Down Expand Up @@ -249,27 +226,25 @@ class wayfire_magnifier : public wf::plugin_interface_t
zoom_box.y2 = 1.0;
}

zoom_box.x1 *= width - 1;
zoom_box.x2 *= width - 1;
zoom_box.y1 *= height - 1;
zoom_box.y2 *= height - 1;

/* Copy zoom_box part of the output to our own texture to be
* read by the mag_view_t. */
auto wlr_texture = wlr_texture_from_dmabuf(
wf::get_core().renderer, &dmabuf_attribs);

wf::texture_t texture{wlr_texture};

OpenGL::render_begin();
mag_view->mag_tex.allocate(width, height);
mag_view->mag_tex.geometry = og;
mag_view->mag_tex.bind();

OpenGL::render_transformed_texture(texture, src_geometry, zoom_box,
transform * mag_view->mag_tex.get_orthographic_projection(),
glm::vec4(1.0),
OpenGL::TEXTURE_USE_TEX_GEOMETRY);
GL_CALL(glBindFramebuffer(GL_READ_FRAMEBUFFER,
output->render->get_target_framebuffer().fb));
GL_CALL(glBlitFramebuffer(zoom_box.x1, zoom_box.y2, zoom_box.x2, zoom_box.y1,
0, 0, width, height,
GL_COLOR_BUFFER_BIT, GL_LINEAR));
OpenGL::render_end();

wlr_texture_destroy(wlr_texture);
wlr_dmabuf_attributes_finish(&dmabuf_attribs);

mag_view->damage();
};

Expand Down

0 comments on commit cf95ac7

Please sign in to comment.