Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/x11_in_gtk2.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <string.h>
#include <X11/Xatom.h>

#include "lv2/options/options.h"
#include "lv2/urid/urid.h"
Expand Down Expand Up @@ -83,10 +84,36 @@ x_window_is_valid(SuilX11Wrapper* socket)
return true;
}
}
XFree(children);
if (children) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? XFree(3): "If data is NULL, no operation is performed."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://tronche.com/gui/x/xlib/display/XFree.html
A NULL pointer cannot be passed to this function.

Maybe xlib vs. xcb?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Weird.

XFree(children);
}
return false;
}

static Window
get_parent_window(Display* display, Window child)
{
Window root = 0;
Window parent = 0;
Window* children = NULL;
unsigned childcount = 0;

if (!child) {
return 0;
}

if (0 != XQueryTree(display, child,
&root, &parent,
&children, &childcount))
{
if (children) {
XFree(children);
}
}

return (parent == root) ? 0 : parent;
}

static gboolean
on_plug_removed(GtkSocket* sock, gpointer data)
{
Expand Down Expand Up @@ -131,6 +158,20 @@ suil_x11_wrapper_realize(GtkWidget* w)
gtk_widget_set_sensitive(GTK_WIDGET(wrap->plug), TRUE);
gtk_widget_set_can_focus(GTK_WIDGET(wrap->plug), TRUE);
gtk_widget_grab_focus(GTK_WIDGET(wrap->plug));

// Setup drag/drop proxy from parent/grandparent window
Atom xdnd_proxy_atom = gdk_x11_get_xatom_by_name_for_display(gdk_display_get_default(), "XdndProxy");
GdkWindow* g_window = gtk_widget_get_window(GTK_WIDGET(wrap->plug));

Window window = GDK_WINDOW_XID(g_window);
Window plugin = (Window)wrap->instance->ui_widget;

while (window) {
XChangeProperty(GDK_WINDOW_XDISPLAY(g_window), window,
xdnd_proxy_atom, XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&plugin, 1);
window = get_parent_window(GDK_WINDOW_XDISPLAY(g_window), window);
};
}

static void
Expand Down