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
|
#ifdef OTHER_TYPES_DEFINED
|
||||||
#undef OTHER_TYPES_DEFINED
|
#undef OTHER_TYPES_DEFINED
|
||||||
#else
|
#else
|
||||||
typedef int MwI32;
|
typedef int MwI32;
|
||||||
typedef unsigned int MwU32;
|
typedef unsigned int MwU32;
|
||||||
|
|
||||||
typedef short MwI16;
|
typedef short MwI16;
|
||||||
typedef unsigned short MwU16;
|
typedef unsigned short MwU16;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
||||||
#define __MW_LOWLEVEL_WAYLAND_H__
|
#define __MW_LOWLEVEL_WAYLAND_H__
|
||||||
|
|
||||||
#include "Mw/BaseTypes.h"
|
|
||||||
#include <Mw/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Mw/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Mw/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
|
@ -29,6 +28,8 @@ MWDECL int MwLLWaylandCallInit(void);
|
||||||
#include "Wayland/cursor-shape-client-protocol.h"
|
#include "Wayland/cursor-shape-client-protocol.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct _MwLLWayland;
|
||||||
|
|
||||||
typedef struct wayland_protocol {
|
typedef struct wayland_protocol {
|
||||||
void* listener;
|
void* listener;
|
||||||
void* context;
|
void* context;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
@ -43,6 +44,7 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef M_PI
|
#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");
|
use_backend("wayland", "x11");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
use_backend("x11");
|
use_backend("x11");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
22
pl/rules.pl
22
pl/rules.pl
|
|
@ -29,12 +29,19 @@ if (grep(/^gdi$/, @backends)) {
|
||||||
if (grep(/^wayland$/, @backends)) {
|
if (grep(/^wayland$/, @backends)) {
|
||||||
add_cflags("-DUSE_WAYLAND");
|
add_cflags("-DUSE_WAYLAND");
|
||||||
new_object("src/backend/wayland.c");
|
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", "xdg-shell", "");
|
||||||
scan_wayland_protocol("stable", "tablet","-v2");
|
scan_wayland_protocol("stable", "tablet", "-v2");
|
||||||
scan_wayland_protocol("staging", "cursor-shape","-v1");
|
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
||||||
scan_wayland_protocol("unstable", "xdg-decoration","-unstable-v1");
|
scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1");
|
||||||
|
|
||||||
$gl_libs = "-lGL -lGLU";
|
$gl_libs = "-lGL -lGLU";
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +54,10 @@ if (param_get("stb-truetype")) {
|
||||||
}
|
}
|
||||||
if (param_get("freetype2")) {
|
if (param_get("freetype2")) {
|
||||||
add_cflags("-DUSE_FREETYPE2");
|
add_cflags("-DUSE_FREETYPE2");
|
||||||
if (not($cross)) {
|
if ($cross) {
|
||||||
|
add_libs("-lfreetype");
|
||||||
|
}
|
||||||
|
else {
|
||||||
add_cflags(`pkg-config --cflags freetype2`);
|
add_cflags(`pkg-config --cflags freetype2`);
|
||||||
add_libs(`pkg-config --libs 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 {
|
sub scan_wayland_protocol {
|
||||||
my $tier = $_[0];
|
my $tier = $_[0];
|
||||||
my $proto = $_[1];
|
my $proto = $_[1];
|
||||||
my $ver = $_[2];
|
my $ver = $_[2];
|
||||||
|
|
||||||
my $proto_c = "src/backend/wayland-${proto}-protocol.c";
|
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) {
|
if (
|
||||||
print("^ Error on getting private code for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n");
|
system(
|
||||||
} else {
|
"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);
|
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")) {
|
if (
|
||||||
print("^ Error on getting client header for /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml\n");
|
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 = ();
|
our %params = ();
|
||||||
|
|
|
||||||
|
|
@ -277,8 +277,13 @@ static void MwLLDestroyImpl(MwLL handle) {
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLBeginDrawImpl(MwLL handle) {}
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
static void MwLLEndDrawImpl(MwLL handle) {}
|
(void)handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
|
(void)handle;
|
||||||
|
}
|
||||||
|
|
||||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
POINT* p = malloc(sizeof(*p) * points_count);
|
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_CONTEXT_MINOR_VERSION, 1,
|
||||||
EGL_NONE};
|
EGL_NONE};
|
||||||
|
|
||||||
EGLDisplay display = eglGetDisplay(self->wayland.display);
|
EGLDisplay display;
|
||||||
|
display = eglGetDisplay(self->wayland.display);
|
||||||
if(display == EGL_NO_DISPLAY) {
|
if(display == EGL_NO_DISPLAY) {
|
||||||
printf("ERROR: eglGetDisplay, %0X\n", eglGetError());
|
printf("ERROR: eglGetDisplay, %0X\n", eglGetError());
|
||||||
return MwFALSE;
|
return MwFALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize EGL
|
// Initialize EGL
|
||||||
if(!eglInitialize(display, &majorVersion, &minorVersion)) {
|
if(!eglInitialize(display, &majorVersion, &minorVersion)) {
|
||||||
printf("ERROR: eglInitialize, %0X\n", eglGetError());
|
printf("ERROR: eglInitialize, %0X\n", eglGetError());
|
||||||
|
|
@ -274,6 +274,11 @@ static MwBool egl_setup(MwLL self, int width, int height) {
|
||||||
return MwFALSE;
|
return MwFALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!eglMakeCurrent(display, surface, surface, context)) {
|
||||||
|
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)eglGetProcAddress("glGenFramebuffers");
|
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)eglGetProcAddress("glGenFramebuffers");
|
||||||
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)eglGetProcAddress("glFramebufferTexture2D");
|
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)eglGetProcAddress("glFramebufferTexture2D");
|
||||||
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)eglGetProcAddress("glGenRenderbuffers");
|
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)eglGetProcAddress("glGenRenderbuffers");
|
||||||
|
|
@ -320,6 +325,11 @@ static MwBool egl_setup(MwLL self, int width, int height) {
|
||||||
static void egl_resetup(MwLL handle) {
|
static void egl_resetup(MwLL handle) {
|
||||||
int err;
|
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);
|
glDeleteTextures(1, &handle->wayland.fbo_texture);
|
||||||
glGenTextures(1, &handle->wayland.fbo_texture);
|
glGenTextures(1, &handle->wayland.fbo_texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, 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) {
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) {
|
if(handle->wayland.parent == NULL)
|
||||||
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
|
if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) {
|
||||||
return;
|
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLEndDrawImpl(MwLL handle) {
|
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);
|
wl_surface_damage(handle->wayland.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
||||||
|
|
||||||
if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) {
|
if(handle->wayland.parent == NULL)
|
||||||
printf("error swapping buffers! %0X\n", eglGetError());
|
if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) {
|
||||||
} else {
|
printf("error swapping buffers! %0X\n", eglGetError());
|
||||||
wl_surface_commit(handle->wayland.surface);
|
} else {
|
||||||
}
|
wl_surface_commit(handle->wayland.surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
|
|
|
||||||
|
|
@ -259,8 +259,13 @@ static void MwLLDestroyImpl(MwLL handle) {
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLBeginDrawImpl(MwLL handle) {}
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
static void MwLLEndDrawImpl(MwLL handle) {}
|
(void)handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
|
(void)handle;
|
||||||
|
}
|
||||||
|
|
||||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
static void lldrawhandler(MwLL handle, void* data) {
|
static void lldrawhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
int ind;
|
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
if(handle->wayland.parent == NULL)
|
if(handle->wayland.parent == NULL)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@ static int create(MwWidget handle) {
|
||||||
attribs[3] = 24;
|
attribs[3] = 24;
|
||||||
attribs[4] = None;
|
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->glXChooseVisual = (MWglXChooseVisual)MwDynamicSymbol(o->lib, "glXChooseVisual");
|
||||||
o->glXCreateContext = (MWglXCreateContext)MwDynamicSymbol(o->lib, "glXCreateContext");
|
o->glXCreateContext = (MWglXCreateContext)MwDynamicSymbol(o->lib, "glXCreateContext");
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ static void draw(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_move(MwWidget handle) {
|
static void mouse_move(MwWidget handle) {
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
|
|
||||||
if(!handle->pressed) return;
|
if(!handle->pressed) return;
|
||||||
|
|
@ -170,9 +170,9 @@ static void mouse_move(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse_down(MwWidget handle, void* ptr) {
|
static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
int ww = MwGetInteger(handle, MwNwidth);
|
int ww = MwGetInteger(handle, MwNwidth);
|
||||||
int wh = MwGetInteger(handle, MwNheight);
|
int wh = MwGetInteger(handle, MwNheight);
|
||||||
int or = MwGetInteger(handle, MwNorientation);
|
int or = MwGetInteger(handle, MwNorientation);
|
||||||
scrollbar_t* scr = handle->internal;
|
scrollbar_t* scr = handle->internal;
|
||||||
MwLLMouse* m = ptr;
|
MwLLMouse* m = ptr;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue