Skip to content

Commit

Permalink
Merge pull request #11 from werererer/development
Browse files Browse the repository at this point in the history
Fix some annoying bugs
  • Loading branch information
werererer authored May 3, 2021
2 parents 97e5bf5 + 9743c2c commit 7e0b545
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 11 deletions.
3 changes: 3 additions & 0 deletions include/clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

#include <wayland-server.h>


void set_primary_selection(struct wl_listener *listener, void *data);
void set_selection(struct wl_listener *listener, void *data);

extern struct wl_listener request_set_psel;
extern struct wl_listener request_set_sel;
#endif /* CLIPBOARD_H */
4 changes: 0 additions & 4 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ void create_notify(struct wl_listener *listener, void *data)

void destroy_notify(struct wl_listener *listener, void *data)
{
printf("destroy\n");
/* Called when the surface is destroyed and should never be shown again. */
struct client *c = wl_container_of(listener, c, destroy);

Expand All @@ -353,7 +352,6 @@ void destroy_notify(struct wl_listener *listener, void *data)

free(c);
c = NULL;
printf("destroy end\n");
}

void maprequest(struct wl_listener *listener, void *data)
Expand All @@ -380,7 +378,6 @@ void maprequest(struct wl_listener *listener, void *data)

void unmap_notify(struct wl_listener *listener, void *data)
{
printf("unmap\n");
/* Called when the surface is unmapped, and should no longer be shown. */
struct client *c = wl_container_of(listener, c, unmap);

Expand All @@ -393,5 +390,4 @@ void unmap_notify(struct wl_listener *listener, void *data)
arrange();
struct monitor *m = selected_monitor;
focus_most_recent_container(get_workspace(m->ws_id), FOCUS_NOOP);
printf("unmapend\n");
}
3 changes: 3 additions & 0 deletions src/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_data_device.h>

struct wl_listener request_set_psel = {.notify = set_primary_selection};
struct wl_listener request_set_sel = {.notify = set_selection};

void set_primary_selection(struct wl_listener *listener, void *data)
{
/* This event is raised by the seat when a client wants to set the selection,
Expand Down
3 changes: 2 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void execute_command(const char *_exec)
bool handled = false;
int i;
for (i = 0; i < server.workspaces.length; i++) {
if (strcmp(get_workspace(i)->name, argv[2]) == 0) {
struct workspace *ws = get_workspace(i);
if (strcmp(ws->name, argv[1]) == 0) {
handled = true;
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ inline int absolute_y_to_container_relative(struct container *con, int y)

int get_position_in_container_stack(struct container *con)
{
if (!con)
return INVALID_POSITION;

struct monitor *m = con->m;
struct workspace *ws = monitor_get_active_workspace(m);
int position = find_in_composed_list(&ws->container_lists, &cmp_ptr, con);
Expand Down
1 change: 0 additions & 1 deletion src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

struct layout *create_layout(lua_State *L)
{
printf("create_layout\n");
struct layout *lt = calloc(1, sizeof(struct layout));
lt->nmaster = 1;
*lt = (struct layout) {
Expand Down
5 changes: 2 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ static struct wl_listener new_output = {.notify = create_monitor};
static struct wl_listener new_xdeco = {.notify = createxdeco};
static struct wl_listener new_xdg_surface = {.notify = create_notify};
static struct wl_listener new_layer_shell_surface = {.notify = create_notify_layer_shell};
static struct wl_listener request_set_psel = {.notify = set_primary_selection};
static struct wl_listener request_set_sel = {.notify = set_selection};

static struct wl_listener new_xwayland_surface = {.notify = create_notifyx11};

Expand Down Expand Up @@ -268,8 +266,8 @@ static int setup()
wl_signal_add(&server.backend->events.new_input, &new_input);
server.seat = wlr_seat_create(server.wl_display, "seat0");
wl_signal_add(&server.seat->events.request_set_cursor, &request_set_cursor);
wl_signal_add(&server.seat->events.request_set_selection, &request_set_sel);
wl_signal_add(&server.seat->events.request_set_primary_selection, &request_set_psel);
wl_signal_add(&server.seat->events.request_set_selection, &request_set_sel);

/*
* Initialise the XWayland X server.
Expand All @@ -281,6 +279,7 @@ static int setup()
server.xwayland_ready.notify = handle_xwayland_ready;
wl_signal_add(&server.xwayland.wlr_xwayland->events.ready, &server.xwayland_ready);
wl_signal_add(&server.xwayland.wlr_xwayland->events.new_surface, &new_xwayland_surface);
wlr_xwayland_set_seat(server.xwayland.wlr_xwayland, server.seat);

setenv("DISPLAY", server.xwayland.wlr_xwayland->display_name, true);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/scratchpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ void remove_container_from_scratchpad(struct container *con)

void show_scratchpad()
{
if (server.scratchpad.length <= 0)
return;

struct monitor *m = selected_monitor;
struct workspace *ws = monitor_get_active_workspace(m);
struct container *sel = get_focused_container(m);
Expand Down
2 changes: 0 additions & 2 deletions src/workspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,10 @@ void add_container_to_focus_stack(struct container *con, struct workspace *ws)
}
if (con->on_top) {
wlr_list_insert(&ws->focus_stack_on_top, 0, con);
printf("insert on top\n");
return;
}
if (!con->focusable) {
wlr_list_insert(&ws->focus_stack_not_focusable, 0, con);
printf("insert on focus_stack\n");
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/xwayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <wlr/util/log.h>

#include "clipboard.h"
#include "container.h"
#include "server.h"
#include "tile/tileUtils.h"
Expand Down
6 changes: 6 additions & 0 deletions test/container_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ START_TEST(focus_container_test)
{
} END_TEST

START_TEST(get_position_in_container_stack_crash_test)
{
get_position_in_container_stack(NULL);
} END_TEST

START_TEST(get_focused_container_crash_test)
{
get_focused_container(NULL);
Expand All @@ -130,6 +135,7 @@ Suite *suite()
tcase_add_test(tc, test_exist_on);
tcase_add_test(tc, focus_on_hidden_stack_test);
tcase_add_test(tc, focus_container_test);
tcase_add_test(tc, get_position_in_container_stack_crash_test);
tcase_add_test(tc, get_focused_container_crash_test);
suite_add_tcase(s, tc);

Expand Down
1 change: 1 addition & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_files = files(
'utils/gapUtils_test.c',
'utils/stringUtils_test.c',
'workspace_test.c',
'scratchpad_test.c',
)

foreach test_file: test_files
Expand Down
41 changes: 41 additions & 0 deletions test/scratchpad_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <stdlib.h>
#include <check.h>

#include "scratchpad.h"

START_TEST(show_scratchpad_crash_test)
{
show_scratchpad();
} END_TEST

Suite *suite()
{
Suite *s;
TCase *tc;

s = suite_create("scratchpad");
tc = tcase_create("Core");

tcase_add_test(tc, show_scratchpad_crash_test);

suite_add_tcase(s, tc);

return s;
}

int main()
{
int numberFailed;
Suite *s;
SRunner *sr;

s = suite();
sr = srunner_create(s);

srunner_run_all(sr, CK_NORMAL);
srunner_ntests_run(sr);
numberFailed = srunner_ntests_failed(sr);
srunner_free(sr);

return (numberFailed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

0 comments on commit 7e0b545

Please sign in to comment.