diff --git a/include/Mw/BaseTypes.h b/include/Mw/BaseTypes.h index e44c3bc..7b92c93 100644 --- a/include/Mw/BaseTypes.h +++ b/include/Mw/BaseTypes.h @@ -58,8 +58,8 @@ typedef unsigned long MwU64; #ifdef OTHER_TYPES_DEFINED #undef OTHER_TYPES_DEFINED #else -typedef int MwI32; -typedef unsigned int MwU32; +typedef int MwI32; +typedef unsigned int MwU32; typedef short MwI16; typedef unsigned short MwU16; diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index 75f208b..6ce73fb 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -6,7 +6,6 @@ #ifndef __MW_LOWLEVEL_WAYLAND_H__ #define __MW_LOWLEVEL_WAYLAND_H__ -#include "Mw/BaseTypes.h" #include #include #include @@ -29,6 +28,8 @@ MWDECL int MwLLWaylandCallInit(void); #include "Wayland/cursor-shape-client-protocol.h" #endif +struct _MwLLWayland; + typedef struct wayland_protocol { void* listener; void* context; diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h index cbc8bcd..6eb37be 100644 --- a/include/Mw/MachDep.h +++ b/include/Mw/MachDep.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #endif #ifndef M_PI diff --git a/pl/ostype/Linux.pl b/pl/ostype/Linux.pl index d79d182..42b6397 100644 --- a/pl/ostype/Linux.pl +++ b/pl/ostype/Linux.pl @@ -1,6 +1,7 @@ -if(system("wayland-scanner -v >/dev/null 2>&1") == 0){ +if (system("wayland-scanner -v >/dev/null 2>&1") == 0) { use_backend("wayland", "x11"); -} else { +} +else { use_backend("x11"); } diff --git a/pl/rules.pl b/pl/rules.pl index 8ba2206..ab5521b 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -29,12 +29,19 @@ if (grep(/^gdi$/, @backends)) { if (grep(/^wayland$/, @backends)) { add_cflags("-DUSE_WAYLAND"); new_object("src/backend/wayland.c"); - add_libs("-lGL -lEGL -lwayland-egl -lwayland-client -lxkbcommon"); + if ($cross) { + add_libs("-lGL -lEGL -lwayland-egl -lwayland-client -lxkbcommon"); + } + else { + add_libs("-lGL -lEGL"); + add_cflags(`pkg-config --cflags wayland-egl wayland-client xkbcommon`); + add_libs(`pkg-config --libs wayland-egl wayland-client xkbcommon`); + } - scan_wayland_protocol("stable", "xdg-shell",""); - scan_wayland_protocol("stable", "tablet","-v2"); - scan_wayland_protocol("staging", "cursor-shape","-v1"); - scan_wayland_protocol("unstable", "xdg-decoration","-unstable-v1"); + scan_wayland_protocol("stable", "xdg-shell", ""); + scan_wayland_protocol("stable", "tablet", "-v2"); + scan_wayland_protocol("staging", "cursor-shape", "-v1"); + scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1"); $gl_libs = "-lGL -lGLU"; } @@ -47,7 +54,10 @@ if (param_get("stb-truetype")) { } if (param_get("freetype2")) { add_cflags("-DUSE_FREETYPE2"); - if (not($cross)) { + if ($cross) { + add_libs("-lfreetype"); + } + else { add_cflags(`pkg-config --cflags freetype2`); add_libs(`pkg-config --libs freetype2`); } diff --git a/pl/utils.pl b/pl/utils.pl index 4b1b517..971c196 100644 --- a/pl/utils.pl +++ b/pl/utils.pl @@ -55,20 +55,35 @@ sub use_backend { } sub scan_wayland_protocol { - my $tier = $_[0]; + my $tier = $_[0]; my $proto = $_[1]; - my $ver = $_[2]; + my $ver = $_[2]; my $proto_c = "src/backend/wayland-${proto}-protocol.c"; - if(system("wayland-scanner private-code /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${proto_c}") != 0) { - print("^ Error on getting private code for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n"); - } else { + if ( + system( +"wayland-scanner private-code /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${proto_c}" + ) != 0 + ) + { + print( +"^ Error on getting private code for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n" + ); + } + else { new_object($proto_c); - }; - if(system("wayland-scanner client-header /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml include/Mw/LowLevel/Wayland/${proto}-client-protocol.h")) { - print("^ Error on getting client header for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n"); - }; + } + if ( + system( +"wayland-scanner client-header /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml include/Mw/LowLevel/Wayland/${proto}-client-protocol.h" + ) + ) + { + print( +"^ Error on getting client header for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n" + ); + } } our %params = (); diff --git a/src/backend/gdi.c b/src/backend/gdi.c index a527e09..ad6d338 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -277,8 +277,13 @@ static void MwLLDestroyImpl(MwLL handle) { free(handle); } -static void MwLLBeginDrawImpl(MwLL handle) {} -static void MwLLEndDrawImpl(MwLL handle) {} +static void MwLLBeginDrawImpl(MwLL handle) { + (void)handle; +} + +static void MwLLEndDrawImpl(MwLL handle) { + (void)handle; +} static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { POINT* p = malloc(sizeof(*p) * points_count); diff --git a/src/backend/wayland.c b/src/backend/wayland.c index cfd30f2..974a36e 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -227,12 +227,12 @@ static MwBool egl_setup(MwLL self, int width, int height) { EGL_CONTEXT_MINOR_VERSION, 1, EGL_NONE}; - EGLDisplay display = eglGetDisplay(self->wayland.display); + EGLDisplay display; + display = eglGetDisplay(self->wayland.display); if(display == EGL_NO_DISPLAY) { printf("ERROR: eglGetDisplay, %0X\n", eglGetError()); return MwFALSE; } - // Initialize EGL if(!eglInitialize(display, &majorVersion, &minorVersion)) { printf("ERROR: eglInitialize, %0X\n", eglGetError()); @@ -274,6 +274,11 @@ static MwBool egl_setup(MwLL self, int width, int height) { return MwFALSE; } + if(!eglMakeCurrent(display, surface, surface, context)) { + printf("ERROR: eglMakeCurrent, %0X\n", eglGetError()); + return MwFALSE; + } + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)eglGetProcAddress("glGenFramebuffers"); glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)eglGetProcAddress("glFramebufferTexture2D"); glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)eglGetProcAddress("glGenRenderbuffers"); @@ -320,6 +325,11 @@ static MwBool egl_setup(MwLL self, int width, int height) { static void egl_resetup(MwLL handle) { int err; + if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) { + printf("ERROR: eglMakeCurrent, %0X\n", eglGetError()); + return; + } + glDeleteTextures(1, &handle->wayland.fbo_texture); glGenTextures(1, &handle->wayland.fbo_texture); glBindTexture(GL_TEXTURE_2D, handle->wayland.fbo_texture); @@ -819,10 +829,11 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { } static void MwLLBeginDrawImpl(MwLL handle) { - if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) { - printf("ERROR: eglMakeCurrent, %0X\n", eglGetError()); - return; - } + if(handle->wayland.parent == NULL) + if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) { + printf("ERROR: eglMakeCurrent, %0X\n", eglGetError()); + return; + } } static void MwLLEndDrawImpl(MwLL handle) { @@ -859,11 +870,12 @@ static void MwLLEndDrawImpl(MwLL handle) { wl_surface_damage(handle->wayland.surface, 0, 0, handle->wayland.ww, handle->wayland.wh); - if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) { - printf("error swapping buffers! %0X\n", eglGetError()); - } else { - wl_surface_commit(handle->wayland.surface); - } + if(handle->wayland.parent == NULL) + if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) { + printf("error swapping buffers! %0X\n", eglGetError()); + } else { + wl_surface_commit(handle->wayland.surface); + } } static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) { diff --git a/src/backend/x11.c b/src/backend/x11.c index 3c54155..dcecf11 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -259,8 +259,13 @@ static void MwLLDestroyImpl(MwLL handle) { free(handle); } -static void MwLLBeginDrawImpl(MwLL handle) {} -static void MwLLEndDrawImpl(MwLL handle) {} +static void MwLLBeginDrawImpl(MwLL handle) { + (void)handle; +} + +static void MwLLEndDrawImpl(MwLL handle) { + (void)handle; +} static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { int i; diff --git a/src/core.c b/src/core.c index a734655..bd6faed 100644 --- a/src/core.c +++ b/src/core.c @@ -6,7 +6,6 @@ static void lldrawhandler(MwLL handle, void* data) { MwWidget h = (MwWidget)handle->common.user; - int ind; (void)data; if(handle->wayland.parent == NULL) diff --git a/src/widget/opengl.c b/src/widget/opengl.c index 552105a..05257e3 100644 --- a/src/widget/opengl.c +++ b/src/widget/opengl.c @@ -89,7 +89,8 @@ static int create(MwWidget handle) { attribs[3] = 24; attribs[4] = None; - while(glpath[glincr] != NULL && (o->lib = MwDynamicOpen(glpath[glincr++])) == NULL); + while(glpath[glincr] != NULL && (o->lib = MwDynamicOpen(glpath[glincr++])) == NULL) + ; o->glXChooseVisual = (MWglXChooseVisual)MwDynamicSymbol(o->lib, "glXChooseVisual"); o->glXCreateContext = (MWglXCreateContext)MwDynamicSymbol(o->lib, "glXCreateContext"); diff --git a/src/widget/scrollbar.c b/src/widget/scrollbar.c index 6490b06..ebfcb40 100644 --- a/src/widget/scrollbar.c +++ b/src/widget/scrollbar.c @@ -142,7 +142,7 @@ static void draw(MwWidget handle) { } static void mouse_move(MwWidget handle) { - int or = MwGetInteger(handle, MwNorientation); + int or = MwGetInteger(handle, MwNorientation); scrollbar_t* scr = handle->internal; if(!handle->pressed) return; @@ -170,9 +170,9 @@ static void mouse_move(MwWidget handle) { } static void mouse_down(MwWidget handle, void* ptr) { - int ww = MwGetInteger(handle, MwNwidth); - int wh = MwGetInteger(handle, MwNheight); - int or = MwGetInteger(handle, MwNorientation); + int ww = MwGetInteger(handle, MwNwidth); + int wh = MwGetInteger(handle, MwNheight); + int or = MwGetInteger(handle, MwNorientation); scrollbar_t* scr = handle->internal; MwLLMouse* m = ptr;