Selaa lähdekoodia

A few changes concerning wxGTK.

For one, I added a new member gs_window for future use.
The member is "display" which represents our connection to X11.
Ideally, we should use this specific connection to deal with our Window.
For now, it's disabled. Read comment for more information.

Secondly, wxGTK apparently doesn't map our window in some cases.
This causes the window ID passed to be bad and will stop (or segfault)
our program. This might be related to the first commit above.

For now, all this commit does is realize the window manually.
Zachary Lund 12 vuotta sitten
vanhempi
sitoutus
d283f24cbb
3 muutettua tiedostoa jossa 10 lisäystä ja 22 poistoa
  1. 1 14
      libobs-opengl/gl-x11.c
  2. 2 0
      libobs/graphics/graphics.h
  3. 7 8
      obs/wx-wrappers.cpp

+ 1 - 14
libobs-opengl/gl-x11.c

@@ -26,8 +26,6 @@ static const GLenum ctx_attribs[] = {
 	None, 
 };
 
-#define ERROR_TEXT_LEN 1024
-
 struct gl_windowinfo {
 	uint32_t id;
 	Display *display;
@@ -38,16 +36,6 @@ struct gl_platform {
 	struct gs_swap_chain swap;
 };
 
-static int GLXErrorHandler(Display *disp, XErrorEvent *error)
-{
-	char error_buf[ERROR_TEXT_LEN];
-	
-	XGetErrorText(disp, error->error_code, error_buf, ERROR_TEXT_LEN);
-	blog(LOG_ERROR, "GLX error: %s\n", error_buf);
-	
-	return 0;
-}
-
 extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform) 
 {
 	return &platform->swap;
@@ -59,6 +47,7 @@ extern struct gl_windowinfo *gl_windowinfo_create(struct gs_init_data *info)
 	memset(wi, 0, sizeof(struct gl_windowinfo));
 	
 	wi->id = info->window.id;
+	/* wi->display = info->window.display; */
 	
 	return wi;
 }
@@ -118,8 +107,6 @@ struct gl_platform *gl_platform_create(device_t device,
 		goto fail0;
 	}
 	
-	XSetErrorHandler(GLXErrorHandler);
-	
 	/* We require glX version 1.4 */
 	{
 		int major = 0, minor = 0;

+ 2 - 0
libobs/graphics/graphics.h

@@ -415,7 +415,9 @@ struct gs_window {
 #elif defined(__APPLE__)
 	__unsafe_unretained id  view;
 #elif defined(__linux__)
+	/* I'm not sure how portable defining id to uint32_t is. */
 	uint32_t id;
+	void* display;
 #endif
 };
 

+ 7 - 8
obs/wx-wrappers.cpp

@@ -39,16 +39,15 @@ gs_window WxToGSWindow(wxWindow *wxwin)
 	window.hwnd     = wxwin->GetHandle();
 #else
 	GtkWidget* hndl = wxwin->GetHandle();
-	gtk_widget_realize(hndl);
-	GdkWindow* gdkwin = gtk_widget_get_window(hndl);
 
-	if (gdkwin)
-		window.id = GDK_DRAWABLE_XID(gdkwin);
-	else {
-		window.id = 0;
-		blog(LOG_ERROR, "Window is not realized...?");
-	}
+	/* I don't really understand why wxWidgets doesn't do this during Show() */
+	gtk_widget_realize(hndl); 
+
+	GdkWindow* gdkwin = gtk_widget_get_window(hndl);
+	window.id = GDK_DRAWABLE_XID(gdkwin);
+	window.display = GDK_DRAWABLE_XDISPLAY(gdkwin);
 #endif
+	
 	return window;
 }