summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-10-07 21:18:21 +0200
committerxengineering <me@xengineering.eu>2022-10-07 21:18:21 +0200
commitd7e9d2932e4497711fffa2d649a036b7581e2c89 (patch)
tree5125a520b8b525189a5f366c3a0b5323e9fbf74f
parentb726bd936ce416044d447ce81409dcc0a9d9aaae (diff)
downloadlimox-d7e9d2932e4497711fffa2d649a036b7581e2c89.tar
limox-d7e9d2932e4497711fffa2d649a036b7581e2c89.tar.zst
limox-d7e9d2932e4497711fffa2d649a036b7581e2c89.zip
Add SDL2 version (X11 only)
There seems to be a bug in SDL2. Window creation is successful under Wayland (window pointer not NULL) but there is no window visible. Tested with Sway and Weston. The same implementation works fine under Cinnamon with X11.
-rw-r--r--meson.build2
-rw-r--r--sdl2.c67
2 files changed, 69 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 9a5f339..205b210 100644
--- a/meson.build
+++ b/meson.build
@@ -2,5 +2,7 @@ project('LimoX', 'c')
gtkdep = dependency('gtk4')
strophedep = dependency('libstrophe')
sdldep = dependency('sdl')
+sdl2dep = dependency('sdl2')
executable('limox', ['main.c', 'gtk.c', 'net.c', 'data.c'], dependencies : [gtkdep, strophedep])
executable('limox_sdl', ['main.c', 'sdl.c', 'net.c', 'data.c'], dependencies : [sdldep, strophedep])
+executable('limox_sdl2', ['main.c', 'sdl2.c', 'net.c', 'data.c'], dependencies : [sdl2dep, strophedep])
diff --git a/sdl2.c b/sdl2.c
new file mode 100644
index 0000000..bbabd51
--- /dev/null
+++ b/sdl2.c
@@ -0,0 +1,67 @@
+
+
+/* mention the SDL2 documentation at http://wiki.libsdl.org/APIByCategory */
+
+/* WARNING this seems to be not working on Wayland! */
+
+
+#include <SDL2/SDL.h>
+#include <stdbool.h>
+
+#include "net.h"
+#include "data.h"
+
+
+void gui_run(void) {
+
+ bool quit = false;
+ SDL_Event event;
+ SDL_Window* window;
+
+ // init SDL2 and create window
+ SDL_Init(SDL_INIT_VIDEO);
+ window = SDL_CreateWindow("LimoX",
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480,
+ 0
+ );
+
+ // handle failed window creation
+ if (window == NULL) {
+ fprintf(stderr, "Failed to create SDL2 window!\n");
+ return;
+ } else {
+ while (!quit) {
+ SDL_WaitEvent(&event);
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ quit = true;
+ break;
+ }
+ }
+ SDL_DestroyWindow(window);
+ }
+
+ SDL_Quit();
+
+}
+
+void gui_connected(char* jid, char* password) {
+
+}
+
+void gui_disconnected(void) {
+
+}
+
+void gui_add_roster_item_widget(roster_item_t* item) {
+
+}
+
+void gui_add_chat_widget(chat_t* chat) {
+
+}
+
+void gui_add_message_widget(message_t* message, chat_t* chat) {
+
+}