Unfinished Wayland PR #1
12 changed files with 92 additions and 41 deletions
finished seperating opengl contexts, apply nishi patch
commit
6f1716151d
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
||||
#define __MW_LOWLEVEL_WAYLAND_H__
|
||||
|
||||
#include "Mw/BaseTypes.h"
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -43,6 +44,7 @@
|
|||
#include <dlfcn.h>
|
||||
#include <signal.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
22
pl/rules.pl
22
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`);
|
||||
}
|
||||
|
|
|
|||
33
pl/utils.pl
33
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 = ();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue