<commit_before>#include <stdlib.h>
#include <swc.h>
#include <wayland-server.h>
#include <wayland-util.h>
#include <X11/keysym.h>

#include "util.h"
#include "wayland.h"
#include "wm.h"

void
move_right()
{
	struct swc_window *win = wm.active_window->swc;
	struct swc_rectangle *geo = swc_window_get_geometry(win);

	geo->x += 10;
	swc_window_set_geometry(win, geo);
}

struct wl_connection *
wayland_init()
{
	debug("Connecting to Wayland");
	struct wl_connection *conn = malloc(sizeof(struct wl_connection));
	if (!conn)
		die("Failed to allocate connection struct");

	debug("Creating display");
	conn->display = wl_display_create();
	if (!conn->display)
		die("Failed to create a Wayland display");

	debug("Adding socket");
	if (wl_display_add_socket(conn->display, NULL) != 0)
		die("Failed to add a socket to the Wayland connection");

	debug("Initializing swc");
	if (!swc_initialize(conn->display, NULL, &manager))
		die("Failed to initialize swc");

	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XK_l,
	                &move_right, NULL);

	debug("Getting event loop");
	conn->event_loop = wl_display_get_event_loop(conn->display);

	debug("Starting Wayland display");
	wl_display_run(conn->display);

	return conn;
}

void
wayland_exit(struct wl_connection *conn)
{
	debug("Terminating Wayland display");
	wl_display_terminate(conn->display);
	debug("Destroying Wayland display");
	wl_display_destroy(conn->display);
}

<commit_msg>use swc_window_set_position() because it flushed immediately<commit_after>#include <stdlib.h>
#include <swc.h>
#include <wayland-server.h>
#include <wayland-util.h>
#include <X11/keysym.h>

#include "util.h"
#include "wayland.h"
#include "wm.h"

void
move_right()
{
	struct swc_window *win = wm.active_window->swc;
	struct swc_rectangle *geo = swc_window_get_geometry(win);

	swc_window_set_position(win, geo->x + 10, geo->y);
}

struct wl_connection *
wayland_init()
{
	debug("Connecting to Wayland");
	struct wl_connection *conn = malloc(sizeof(struct wl_connection));
	if (!conn)
		die("Failed to allocate connection struct");

	debug("Creating display");
	conn->display = wl_display_create();
	if (!conn->display)
		die("Failed to create a Wayland display");

	debug("Adding socket");
	if (wl_display_add_socket(conn->display, NULL) != 0)
		die("Failed to add a socket to the Wayland connection");

	debug("Initializing swc");
	if (!swc_initialize(conn->display, NULL, &manager))
		die("Failed to initialize swc");

	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XK_l,
	                &move_right, NULL);

	debug("Getting event loop");
	conn->event_loop = wl_display_get_event_loop(conn->display);

	debug("Starting Wayland display");
	wl_display_run(conn->display);

	return conn;
}

void
wayland_exit(struct wl_connection *conn)
{
	debug("Terminating Wayland display");
	wl_display_terminate(conn->display);
	debug("Destroying Wayland display");
	wl_display_destroy(conn->display);
}


{'fraction_non_alphanumeric': 0.13989108236895847, 'fraction_numerical': 0.0034036759700476512, 'mean_word_length': 5.834883720930232, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2793781', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1034, 'n_words': 231}