aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/window_texture.h10
-rw-r--r--src/main.cpp15
-rw-r--r--src/window_manager.c1
-rw-r--r--src/window_texture.c13
4 files changed, 25 insertions, 14 deletions
diff --git a/include/window_texture.h b/include/window_texture.h
index d543a79..ea3ff10 100644
--- a/include/window_texture.h
+++ b/include/window_texture.h
@@ -1,8 +1,11 @@
#ifndef WINDOW_TEXTURE_H
#define WINDOW_TEXTURE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define GLX_GLXEXT_PROTOTYPES
-#include <GL/glew.h>
#include <GL/glx.h>
#include <GL/glxext.h>
#include <X11/Xlib.h>
@@ -13,6 +16,7 @@ typedef struct {
Pixmap pixmap;
GLXPixmap glx_pixmap;
GLuint texture_id;
+ int redirected;
} WindowTexture;
/* Returns 0 on success */
@@ -27,4 +31,8 @@ int window_texture_on_resize(WindowTexture *self);
GLuint window_texture_get_opengl_texture_id(WindowTexture *self);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* WINDOW_TEXTURE_H */
diff --git a/src/main.cpp b/src/main.cpp
index d14e3b5..75ae2a0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -31,15 +31,14 @@
// Modified by: DEC05EBA
-extern "C" {
+#include <GL/glew.h>
#include "../include/window_texture.h"
+extern "C" {
#include "../include/window_manager.h"
}
#include <SDL.h>
-#include <GL/glew.h>
#include <SDL_opengl.h>
-#include <GL/glu.h>
#include <openvr.h>
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
@@ -48,9 +47,7 @@ extern "C" {
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <X11/Xlib.h>
-#include <X11/Xproto.h>
#include <X11/extensions/Xfixes.h>
-#include <GL/glxproto.h>
#include <stdio.h>
#include <string>
@@ -590,7 +587,7 @@ static XErrorHandler xerrorxlib;
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
* default error handler, which may call exit. */
static int xerror(Display *dpy, XErrorEvent *ee) {
- if (ee->error_code == BadWindow
+ /*if (ee->error_code == BadWindow
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
@@ -600,9 +597,9 @@ static int xerror(Display *dpy, XErrorEvent *ee) {
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)
|| (ee->request_code == X_GLXCreatePixmap && ee->error_code == BadMatch))
- return 0;
- fprintf(stderr, "vrwm: fatal error: request code=%d, error code=%d\n",
- ee->request_code, ee->error_code);
+ return 0;*/
+ //fprintf(stderr, "vrwm: fatal error: request code=%d, error code=%d\n",
+ // ee->request_code, ee->error_code);
return 0; /* may call exit */ /* TODO: xerrorxlib(dpy, ee); */
}
diff --git a/src/window_manager.c b/src/window_manager.c
index a2285e0..ec26842 100644
--- a/src/window_manager.c
+++ b/src/window_manager.c
@@ -92,6 +92,7 @@ static int window_manager_show_window(WindowManager *self, Window window, Displa
int window_index = window_manager_get_window_index(self, window);
if(window_index != -1) {
self->window_data[window_index].visible = 1;
+ /* TODO: Also set NET_ACTIVE_WINDOW */
XMoveResizeWindow(display, window, 0, 0, self->window_width, self->window_height);
XRaiseWindow(display, window);
XSetInputFocus(display, window, RevertToPointerRoot, CurrentTime);
diff --git a/src/window_texture.c b/src/window_texture.c
index e2093b8..846ee0d 100644
--- a/src/window_texture.c
+++ b/src/window_texture.c
@@ -14,16 +14,18 @@ static int x11_supports_composite_named_window_pixmap(Display *display) {
}
int window_texture_init(WindowTexture *window_texture, Display *display, Window window) {
- if(!x11_supports_composite_named_window_pixmap(display))
- return 1;
-
window_texture->display = display;
window_texture->window = window;
window_texture->pixmap = None;
window_texture->glx_pixmap = None;
window_texture->texture_id = 0;
+ window_texture->redirected = 0;
+
+ if(!x11_supports_composite_named_window_pixmap(display))
+ return 1;
XCompositeRedirectWindow(display, window, CompositeRedirectAutomatic);
+ window_texture->redirected = 1;
return window_texture_on_resize(window_texture);
}
@@ -46,7 +48,10 @@ static void window_texture_cleanup(WindowTexture *self, int delete_texture) {
}
void window_texture_deinit(WindowTexture *self) {
- XCompositeUnredirectWindow(self->display, self->window, CompositeRedirectAutomatic);
+ if(self->redirected) {
+ XCompositeUnredirectWindow(self->display, self->window, CompositeRedirectAutomatic);
+ self->redirected = 0;
+ }
window_texture_cleanup(self, 1);
}