Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed May 14, 2024
1 parent 40d4956 commit e127e7f
Show file tree
Hide file tree
Showing 56 changed files with 5,433 additions and 5,747 deletions.
26 changes: 12 additions & 14 deletions examples/vk-shadertoy/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@

#include <linux/input.h>

#include <thread>


void App::draw_frame(void *data, const uint32_t time) {
auto window = static_cast<Window *>(data);
auto shadertoy = static_cast<ShaderToy *>(window->get_user_data());
shadertoy->draw_frame(time);
auto shader_toy = static_cast<ShaderToy *>(window->get_user_data());
shader_toy->draw_frame(time);
}

App::App(const Configuration &config) : logging_(std::make_unique<Logging>()) {
Expand All @@ -47,8 +45,7 @@ App::App(const Configuration &config) : logging_(std::make_unique<Logging>()) {
wm_ = std::make_unique<XdgWindowManager>(display_, config.disable_cursor);
auto seat = wm_->get_seat();
if (seat.has_value()) {
seat.value()->set_user_data(this);
seat.value()->register_observer(this);
seat.value()->register_observer(this, this);
}

spdlog::debug("XDG Window Manager Version: {}", wm_->get_version());
Expand All @@ -68,11 +65,12 @@ App::App(const Configuration &config) : logging_(std::make_unique<Logging>()) {
config.reload_shaders,
static_cast<VkPresentModeKHR>(config.present_mode));

toplevel_->set_user_data(shadertoy_.get());

/// paint padding
toplevel_->set_surface_damage(0, 0, config.width, config.height);
toplevel_->start_frame_callbacks();

/// start frame callbacks with user_data pointing to shadertoy
toplevel_->start_frame_callbacks(shadertoy_.get());
}

App::~App() {
Expand All @@ -91,15 +89,14 @@ void App::notify_seat_capabilities(Seat *seat,
uint32_t /* caps */) {
if (seat) {
auto keyboard = seat->get_keyboard();

if (keyboard.has_value()) {
keyboard.value()->set_user_data(this);
keyboard.value()->register_observer(this);
keyboard.value()->register_observer(this, this);
}

auto pointer = seat->get_pointer();
if (pointer.has_value()) {
pointer.value()->set_user_data(this);
pointer.value()->register_observer(this);
pointer.value()->register_observer(this, this);
}
}
}
Expand Down Expand Up @@ -180,7 +177,7 @@ void App::notify_pointer_enter(Pointer *pointer,
wl_surface * /* surface */,
double /* sx */,
double /* sy */) {
pointer->set_cursor(serial);
pointer->set_cursor(serial, "left_ptr");
}

void App::notify_pointer_leave(Pointer * /* pointer */,
Expand All @@ -194,6 +191,7 @@ void App::notify_pointer_motion(Pointer *pointer,
uint32_t /* time */,
double sx,
double sy) {

auto app = static_cast<App *>(pointer->get_user_data());
auto shader_toy = app->shadertoy_.get();
auto os_window = shader_toy->get_app_os_window();
Expand All @@ -207,7 +205,7 @@ void App::notify_pointer_button(Pointer *pointer,
uint32_t /* time */,
uint32_t button,
uint32_t state) {
// spdlog::info("Pointer Button: pointer: {}, time: {}, button: {}, state: {}", serial, time, button, state);

auto app = static_cast<App *>(pointer->get_user_data());
auto shader_toy = app->shadertoy_.get();
auto os_window = shader_toy->get_app_os_window();
Expand Down
Loading

0 comments on commit e127e7f

Please sign in to comment.