Skip to content

Commit

Permalink
update RGFW wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 11, 2025
1 parent d8e81a2 commit aceae42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ else
endif

ifeq ($(RGFW_WAYLAND),1)
NO_VULKAN = 1
LIBS = -D RGFW_WAYLAND relative-pointer-unstable-v1-client-protocol.c xdg-decoration-unstable-v1.c xdg-shell.c -lwayland-cursor -lwayland-client -lEGL -lxkbcommon -lGL -lwayland-egl
endif

Expand Down Expand Up @@ -173,7 +174,9 @@ else
endif

examples/minimal_links/minimal_links: examples/minimal_links/minimal_links.c RGFW.h
ifeq ($(CC),emcc)
ifeq ($(RGFW_WAYLAND), 1)
@echo nostl is not supported on this platform
else ifeq ($(CC),emcc)
@echo nostl is not supported on this platform
else ifeq ($(detected_OS),Linux)
$(CC) $(CFLAGS) -I. $< -o $@$(EXT)
Expand All @@ -187,7 +190,9 @@ endif


examples/nostl/nostl: examples/nostl/nostl.c RGFW.h
ifeq ($(CC),emcc)
ifeq ($(RGFW_WAYLAND), 1)
@echo nostl is not supported on this platform
else ifeq ($(CC),emcc)
@echo nostl is not supported on this platform
else ifeq ($(detected_OS),Linux)
$(CC) $(CFLAGS) -fno-stack-protector -lX11 -lXcursor -lGL -lXi -lXrandr -I. $< -o $@$(EXT)
Expand Down Expand Up @@ -218,7 +223,9 @@ examples/first-person-camera/camera: examples/first-person-camera/camera.c RGFW.


examples/gl33/gl33: examples/gl33/gl33.c RGFW.h
ifeq ($(detected_OS),Linux)
ifeq ($(RGFW_WAYLAND), 1)
$(CC) $(CFLAGS) $(LIBS) -I. $< -o $@$(EXT)
else ifeq ($(detected_OS),Linux)
$(CC) $(CFLAGS) -I. $< -o $@$(EXT)
else ifeq ($(detected_OS),windows)
$(CC) $(CFLAGS) $(WARNINGS) -I. $< -lgdi32 -o $@$(EXT)
Expand Down
33 changes: 16 additions & 17 deletions RGFW.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define RGFW_WAYLAND
/*
*
* RGFW 1.5-dev
Expand Down Expand Up @@ -347,7 +348,7 @@ int main() {
#endif

#elif defined(RGFW_WAYLAND)
#if !defined(RGFW_NO_API) && (!defined(RGFW_BUFFER) || defined(RGFW_OPENGL))
#if !defined(RGFW_NO_API) && (!defined(RGFW_BUFFER) || defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA)
#define RGFW_EGL
#define RGFW_OPENGL
#include <wayland-egl.h>
Expand Down Expand Up @@ -4698,8 +4699,6 @@ static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t ser
RGFW_ASSERT(RGFW_key_win != NULL);

xkb_keysym_t keysym = xkb_state_key_get_one_sym (xkb_state, key+8);
char name[16];
xkb_keysym_get_name(keysym, name, 16);

u32 RGFW_key = RGFW_apiKeyToRGFW(key);
RGFW_keyboard[RGFW_key].prev = RGFW_keyboard[RGFW_key].current;
Expand All @@ -4714,7 +4713,7 @@ static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t ser

RGFW_updateKeyMods(RGFW_key_win, xkb_keymap_mod_get_index(keymap, "Lock"), xkb_keymap_mod_get_index(keymap, "Mod2"));

RGFW_keyCallback(RGFW_key_win, RGFW_key, (u8)keysym, name, RGFW_key_win->event.keyMod, state);
RGFW_keyCallback(RGFW_key_win, RGFW_key, (u8)keysym, RGFW_key_win->event.keyMod, state);
}
static void keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {
RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial); RGFW_UNUSED(time);
Expand Down Expand Up @@ -4748,7 +4747,7 @@ static void wl_global_registry_handler(void *data,
} else if (RGFW_STRNCMP(interface, "xdg_wm_base", 12) == 0) {
xdg_wm_base = wl_registry_bind(registry,
id, &xdg_wm_base_interface, 1);
} else if (RGFW_STRNCMP(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
} else if (RGFW_STRNCMP(interface, zxdg_decoration_manager_v1_interface.name, 255) == 0) {
decoration_manager = wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1);
} else if (RGFW_STRNCMP(interface, "wl_shm", 7) == 0) {
shm = wl_registry_bind(registry,
Expand Down Expand Up @@ -5066,20 +5065,20 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
}

RGFW_event* RGFW_window_checkEvent(RGFW_window* win) {
if (win->_flags & RGFW_windowWindowHide)
if (win->_flags & RGFW_windowHide)
return NULL;

#if defined(__linux__)
if (RGFW_linux_updateGamepad(win)) { return &win->event; }
#endif

if (win->src.eventIndex == 0) {
if (wl_display_roundtrip(win->src.display) == -1) {
return NULL;
}
RGFW_resetKey();
}

#if defined(__linux__)
if (RGFW_linux_updateGamepad(win)) return &win->event;
#endif

if (win->src.eventLen == 0) {
return NULL;
}
Expand Down Expand Up @@ -5110,21 +5109,21 @@ void RGFW_window_move(RGFW_window* win, RGFW_point v) {

/* TODO wayland */
RGFW_ASSERT(win != NULL);
struct wl_pointer *pointer = wl_seat_get_pointer(win->seat);
struct wl_pointer *pointer = wl_seat_get_pointer(seat);
if (!pointer) {
return;
}

// Initiate the move operation
wl_shell_surface_move(win->shell_surface, pointer, win->serial);
//wl_shell_surface_move(win->src.surface, seat, 0);
win->r.x = v.x;
win->r.y = v.y;

wl_display_flush(win->display);
wl_display_flush(win->src.display);
}

b32 RGFW_window_setIcon(RGFW_window* win, u8* src, RGFW_area a, i32 channels) {
RGFW_UNUSED(win); RGFW_UNUSED(src); RGFW_UNUSED(a); RGFW_UNUSED(channels)
RGFW_UNUSED(win); RGFW_UNUSED(src); RGFW_UNUSED(a); RGFW_UNUSED(channels);
/* TODO wayland */
return 0;
}
Expand Down Expand Up @@ -5219,8 +5218,8 @@ b32 RGFW_window_setMouseStandard(RGFW_window* win, u8 mouse) {
return 1;
}

void* RGFW_loadMouse(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
RGFW_UNUSED(image); RGFW_UNUSED(a); RGFW_UNUSED(channels)
void* RGFW_loadMouse(u8* icon, RGFW_area a, i32 channels) {
RGFW_UNUSED(icon); RGFW_UNUSED(a); RGFW_UNUSED(channels);
//struct wl_cursor* cursor = wl_cursor_theme_get_cursor(RGFW_wl_cursor_theme, iconStrings[mouse]);
//RGFW_cursor_image = icon;
struct wl_buffer* cursor_buffer = wl_cursor_image_get_buffer(RGFW_cursor_image);
Expand All @@ -5236,7 +5235,7 @@ void RGFW_window_setMouse(RGFW_window* win, RGFW_mouse* mouse) {
}

void RGFW_freeMouse(RGFW_mouse* mouse) {
GFW_UNUSED(mouse);
RGFW_UNUSED(mouse);
}

void RGFW_window_setName(RGFW_window* win, const char* name) {
Expand Down

0 comments on commit aceae42

Please sign in to comment.