Skip to content

Commit

Permalink
store image on each commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Feb 5, 2024
1 parent 503bc26 commit 9e7dd93
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/view/xdg-shell/xdg-toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <wayfire/txn/transaction-manager.hpp>
#include <wlr/util/edges.h>
#include "wayfire/geometry.hpp"
#include "wayfire/img.hpp"
#include "wayfire/scene-render.hpp"
#include "wayfire/toplevel-view.hpp"
#include "wayfire/toplevel.hpp"
Expand Down Expand Up @@ -147,6 +148,17 @@ void wf::xdg_toplevel_t::handle_surface_commit()
{
pending_state.merge_state(toplevel->base->surface);

if (toplevel->base->surface->buffer)
{
static int counter = 0;
counter++;
wf::texture_t tex{toplevel->base->surface->buffer->texture};
image_io::write_to_file("img" + std::to_string(counter) + ".png", tex, wf::dimensions_t{
toplevel->base->surface->current.width,
toplevel->base->surface->current.height,
});
}

const bool is_committed = wf::get_core().tx_manager->is_object_committed(shared_from_this());
if (is_committed)
{
Expand Down

0 comments on commit 9e7dd93

Please sign in to comment.