From 7faf7bdb157110975b7312691e786ca737487a7c Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:43:52 -0500
Subject: Disable code that uses direct X11 requests.


diff --git a/gdk/x11/gdkasync.c b/gdk/x11/gdkasync.c
index 6963213..bf61f6d 100644
--- a/gdk/x11/gdkasync.c
+++ b/gdk/x11/gdkasync.c
@@ -47,7 +47,7 @@ in this Software without prior written authorization from The Open Group.
 #include "gdkprivate-x11.h"
 
 #include <X11/Xlibint.h>
-
+#if 0
 
 typedef struct _ChildInfoChildState ChildInfoChildState;
 typedef struct _ChildInfoState ChildInfoState;
@@ -123,8 +123,8 @@ struct _RoundtripState
 static gboolean
 callback_idle (gpointer data)
 {
-  SendEventState *state = (SendEventState *)data;  
-  
+  SendEventState *state = (SendEventState *)data;
+
   state->callback (state->window, !state->have_error, state->data);
 
   g_free (state);
@@ -139,7 +139,7 @@ send_event_handler (Display *dpy,
 		    int      len,
 		    XPointer data)
 {
-  SendEventState *state = (SendEventState *)data;  
+  SendEventState *state = (SendEventState *)data;
 
   if (dpy->last_request_read == state->send_event_req)
     {
@@ -154,7 +154,7 @@ send_event_handler (Display *dpy,
     {
       xGetInputFocusReply replbuf;
       xGetInputFocusReply *repl G_GNUC_UNUSED;
-      
+
       if (rep->generic.type != X_Error)
 	{
 	  /* Actually does nothing, since there are no additional bytes
@@ -191,7 +191,7 @@ client_message_to_wire (XClientMessageEvent *ev,
   event->u.u.detail = ev->format;
   switch (ev->format)
     {
-    case 8:	
+    case 8:
       event->u.clientMessage.u.b.type   = ev->message_type;
       for (i = 0; i < 20; i++)
 	event->u.clientMessage.u.b.bytes[i] = ev->data.b[i];
@@ -224,8 +224,8 @@ client_message_to_wire (XClientMessageEvent *ev,
 }
 
 void
-_gdk_x11_send_client_message_async (GdkDisplay           *display, 
-				    Window                window, 
+_gdk_x11_send_client_message_async (GdkDisplay           *display,
+				    Window                window,
 				    gboolean              propagate,
 				    glong                 event_mask,
 				    XClientMessageEvent  *event_send,
@@ -234,7 +234,7 @@ _gdk_x11_send_client_message_async (GdkDisplay           *display,
 {
   Display *dpy;
   SendEventState *state;
-  
+
   dpy = GDK_DISPLAY_XDISPLAY (display);
 
   state = g_new (SendEventState, 1);
@@ -244,7 +244,7 @@ _gdk_x11_send_client_message_async (GdkDisplay           *display,
   state->callback = callback;
   state->data = data;
   state->have_error = FALSE;
-  
+
   LockDisplay(dpy);
 
   state->async.next = dpy->async_handlers;
@@ -255,20 +255,20 @@ _gdk_x11_send_client_message_async (GdkDisplay           *display,
   {
     register xSendEventReq *req;
     xEvent ev;
-    
+
     client_message_to_wire (event_send, &ev);
-      
+
     GetReq(SendEvent, req);
     req->destination = window;
     req->propagate = propagate;
     req->eventMask = event_mask;
     /* gross, matches Xproto.h */
-#ifdef WORD64			
+#ifdef WORD64
     memcpy ((char *) req->eventdata, (char *) &ev, SIZEOF(xEvent));
-#else    
+#else
     memcpy ((char *) &req->event, (char *) &ev, SIZEOF(xEvent));
 #endif
-    
+
     state->send_event_req = dpy->request;
   }
 
@@ -277,11 +277,11 @@ _gdk_x11_send_client_message_async (GdkDisplay           *display,
    */
   {
     G_GNUC_UNUSED xReq *req;
-    
+
     GetEmptyReq(GetInputFocus, req);
     state->get_input_focus_req = dpy->request;
   }
-  
+
   UnlockDisplay(dpy);
   SyncHandle();
 }
@@ -297,7 +297,7 @@ list_children_handler (Display *dpy,
 
   if (dpy->last_request_read != state->get_property_req)
     return False;
-  
+
   if (rep->generic.type == X_Error)
     {
       state->have_error = TRUE;
@@ -307,7 +307,7 @@ list_children_handler (Display *dpy,
     {
       xGetPropertyReply replbuf;
       xGetPropertyReply *repl;
-	    
+
       repl = (xGetPropertyReply *)
 	_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
 			(sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,
@@ -343,7 +343,7 @@ list_children_and_wm_state (Display      *dpy,
   *children = NULL;
   *nchildren = 0;
   *has_wm_state = FALSE;
-  
+
   state.have_error = FALSE;
   state.has_wm_state = FALSE;
 
@@ -361,10 +361,10 @@ list_children_and_wm_state (Display      *dpy,
       prop_req->delete = False;
       prop_req->longOffset = 0;
       prop_req->longLength = 0;
-      
+
       state.get_property_req = dpy->request;
     }
-  
+
   GetResReq(QueryTree, w, req);
   if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
     {
@@ -392,7 +392,7 @@ list_children_and_wm_state (Display      *dpy,
     DeqAsyncHandler(dpy, &async);
   UnlockDisplay(dpy);
   SyncHandle();
-  
+
   return !state.have_error;
 }
 
@@ -412,7 +412,7 @@ handle_get_geometry_reply (Display           *dpy,
 			   xGetGeometryReply *repl)
 {
   GdkChildInfoX11 *child = &state->child_info[state->n_children_found];
-  
+
   child->x = cvtINT16toInt (repl->x);
   child->y = cvtINT16toInt (repl->y);
   child->width = repl->width;
@@ -463,12 +463,12 @@ get_child_info_handler (Display *dpy,
 			XPointer data)
 {
   Bool result = True;
-  
+
   ChildInfoState *state = (ChildInfoState *)data;
 
   if (dpy->last_request_read != state->child_states[state->current_child].seq[state->current_request])
     return False;
-  
+
   if (rep->generic.type == X_Error)
     {
       state->child_has_error = TRUE;
@@ -487,12 +487,12 @@ get_child_info_handler (Display *dpy,
 	  {
 	    xGetPropertyReply replbuf;
 	    xGetPropertyReply *repl;
-	    
+
 	    repl = (xGetPropertyReply *)
 	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
 			      (sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,
 			      True);
-	    
+
 	    handle_get_property_reply (dpy, state, repl);
 	  }
 	  break;
@@ -500,12 +500,12 @@ get_child_info_handler (Display *dpy,
 	  {
 	    xGetWindowAttributesReply replbuf;
 	    xGetWindowAttributesReply *repl;
-	    
+
 	    repl = (xGetWindowAttributesReply *)
 	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
 			      (sizeof(xGetWindowAttributesReply) - sizeof(xReply)) >> 2,
 			      True);
-	    
+
 	    handle_get_wa_reply (dpy, state, repl);
 	  }
 	  break;
@@ -513,12 +513,12 @@ get_child_info_handler (Display *dpy,
 	  {
 	    xGetGeometryReply replbuf;
 	    xGetGeometryReply *repl;
-	    
+
 	    repl = (xGetGeometryReply *)
 	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
 			      (sizeof(xGetGeometryReply) - sizeof(xReply)) >> 2,
 			      True);
-	    
+
 	    handle_get_geometry_reply (dpy, state, repl);
 	  }
 	  break;
@@ -548,7 +548,7 @@ _gdk_x11_get_window_child_info (GdkDisplay       *display,
 
   *children = NULL;
   *nchildren = 0;
-  
+
   dpy = GDK_DISPLAY_XDISPLAY (display);
   if (get_wm_state)
     wm_state_atom = gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE");
@@ -601,13 +601,13 @@ _gdk_x11_get_window_child_info (GdkDisplay       *display,
   async.handler = get_child_info_handler;
   async.data = (XPointer) &state;
   dpy->async_handlers = &async;
-  
+
   for (i = 0; i < state.nchildren; i++)
     {
       xResourceReq *resource_req;
       xGetPropertyReq *prop_req;
       Window win = state.children[i];
-      
+
       if (get_wm_state)
 	{
 	  GetReq (GetProperty, prop_req);
@@ -620,10 +620,10 @@ _gdk_x11_get_window_child_info (GdkDisplay       *display,
 
 	  state.child_states[i].seq[CHILD_INFO_GET_PROPERTY] = dpy->request;
 	}
-      
+
       GetResReq(GetWindowAttributes, win, resource_req);
       state.child_states[i].seq[CHILD_INFO_GET_WA] = dpy->request;
-      
+
       GetResReq(GetGeometry, win, resource_req);
       state.child_states[i].seq[CHILD_INFO_GET_GEOMETRY] = dpy->request;
     }
@@ -654,7 +654,7 @@ _gdk_x11_get_window_child_info (GdkDisplay       *display,
 
   g_free (state.children);
   g_free (state.child_states);
-  
+
   DeqAsyncHandler(dpy, &async);
   UnlockDisplay(dpy);
   SyncHandle();
@@ -665,8 +665,8 @@ _gdk_x11_get_window_child_info (GdkDisplay       *display,
 static gboolean
 roundtrip_callback_idle (gpointer data)
 {
-  RoundtripState *state = (RoundtripState *)data;  
-  
+  RoundtripState *state = (RoundtripState *)data;
+
   state->callback (state->display, state->data, state->get_input_focus_req);
 
   g_free (state);
@@ -681,13 +681,13 @@ roundtrip_handler (Display *dpy,
 		   int      len,
 		   XPointer data)
 {
-  RoundtripState *state = (RoundtripState *)data;  
-  
+  RoundtripState *state = (RoundtripState *)data;
+
   if (dpy->last_request_read == state->get_input_focus_req)
     {
       xGetInputFocusReply replbuf;
       xGetInputFocusReply *repl G_GNUC_UNUSED;
-      
+
       if (rep->generic.type != X_Error)
 	{
 	  /* Actually does nothing, since there are no additional bytes
@@ -699,7 +699,7 @@ roundtrip_handler (Display *dpy,
 			    True);
 	}
 
-      
+
       if (state->callback)
         {
           guint id;
@@ -716,13 +716,13 @@ roundtrip_handler (Display *dpy,
 }
 
 void
-_gdk_x11_roundtrip_async (GdkDisplay           *display, 
+_gdk_x11_roundtrip_async (GdkDisplay           *display,
 			  GdkRoundTripCallback callback,
 			  gpointer              data)
 {
   Display *dpy;
   RoundtripState *state;
-  
+
   dpy = GDK_DISPLAY_XDISPLAY (display);
 
   state = g_new (RoundtripState, 1);
@@ -731,7 +731,7 @@ _gdk_x11_roundtrip_async (GdkDisplay           *display,
   state->dpy = dpy;
   state->callback = callback;
   state->data = data;
-  
+
   LockDisplay(dpy);
 
   state->async.next = dpy->async_handlers;
@@ -744,11 +744,12 @@ _gdk_x11_roundtrip_async (GdkDisplay           *display,
    */
   {
     G_GNUC_UNUSED xReq *req;
-    
+
     GetEmptyReq(GetInputFocus, req);
     state->get_input_focus_req = dpy->request;
   }
-  
+
   UnlockDisplay(dpy);
   SyncHandle();
 }
+#endif
diff --git a/gdk/x11/gdkasync.h b/gdk/x11/gdkasync.h
index f7be90f..b6ccc73 100644
--- a/gdk/x11/gdkasync.h
+++ b/gdk/x11/gdkasync.h
@@ -45,24 +45,24 @@ struct _GdkChildInfoX11
   guint window_class : 2;
 };
 
-void _gdk_x11_send_client_message_async (GdkDisplay            *display,
+static void _gdk_x11_send_client_message_async (GdkDisplay            *display,
 					 Window                 window,
 					 gboolean               propagate,
 					 glong                  event_mask,
 					 XClientMessageEvent   *event_send,
 					 GdkSendXEventCallback  callback,
-					 gpointer               data);
+					 gpointer               data) {}
 
-gboolean _gdk_x11_get_window_child_info (GdkDisplay       *display,
+static gboolean _gdk_x11_get_window_child_info (GdkDisplay       *display,
 					 Window            window,
 					 gboolean          get_wm_state,
 					 gboolean         *win_has_wm_state,
 					 GdkChildInfoX11 **children,
-					 guint            *nchildren);
+					 guint            *nchildren) { return FALSE; }
 
-void _gdk_x11_roundtrip_async           (GdkDisplay           *display, 
+static void _gdk_x11_roundtrip_async           (GdkDisplay           *display,
 					 GdkRoundTripCallback callback,
-					 gpointer              data);
+					 gpointer              data) {}
 
 G_END_DECLS
 
-- 
2.30.2


From 4e16e7eebd8518a485ea9dca4b872ca0f434fbd1 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:46:39 -0500
Subject: Make it possible to build without XI2.


diff --git a/configure b/configure
index edd41ad..887d6d5 100755
--- a/configure
+++ b/configure
@@ -26710,7 +26710,7 @@ fi
   fi
 
   if test "x$have_xinput2" != "xyes"; then :
-  as_fn_error $? "*** XInput2 extension not found. Check 'config.log' for more details." "$LINENO" 5
+  #as_fn_error $? "*** XInput2 extension not found. Check 'config.log' for more details." "$LINENO" 5
 fi
 
   # Check for the RANDR extension
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index cd1849c..99d1752 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
-
+#if 0
 #include "config.h"
 
 #include "gdkx11device-xi2.h"
@@ -930,3 +930,4 @@ gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
   else
     device->last_axes = NULL;
 }
+#endif
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 00e64d2..c602a1b 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
-
+#if 0
 #include "config.h"
 
 #include "gdkx11devicemanager-xi2.h"
@@ -2129,3 +2129,4 @@ _gdk_x11_device_manager_xi2_lookup (GdkX11DeviceManagerXI2 *device_manager_xi2,
   return g_hash_table_lookup (device_manager_xi2->id_table,
                               GINT_TO_POINTER (device_id));
 }
+#endif
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 96edea6..002d206 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -365,6 +365,7 @@ root_key_filter (GdkXEvent *xevent,
     ev->xkey.window = (Window)data;
   else if (ev->type == GenericEvent)
     {
+#if 0
       XGenericEventCookie *cookie;
       XIDeviceEvent *dev;
 
@@ -374,6 +375,7 @@ root_key_filter (GdkXEvent *xevent,
       if (dev->evtype == XI_KeyPress ||
           dev->evtype == XI_KeyRelease)
         dev->event = (Window)data;
+#endif
     }
 
   return GDK_FILTER_CONTINUE;
@@ -633,7 +635,7 @@ static guint32
 gtk_drag_get_event_time (GdkEvent *event)
 {
   guint32 tm = GDK_CURRENT_TIME;
-  
+
   if (event)
     switch (event->type)
       {
@@ -662,7 +664,7 @@ gtk_drag_get_event_time (GdkEvent *event)
       default:                  /* use current time */
         break;
       }
-  
+
   return tm;
 }
 
@@ -679,7 +681,7 @@ gtk_drag_get_event_actions (const GdkEvent *event,
   if (event)
     {
       GdkModifierType state = 0;
-      
+
       switch (event->type)
         {
         case GDK_MOTION_NOTIFY:
@@ -752,7 +754,7 @@ gtk_drag_get_event_actions (const GdkEvent *event,
   else
     {
       *possible_actions = actions;
-      
+
       if (actions & GDK_ACTION_COPY)
         *suggested_action =  GDK_ACTION_COPY;
       else if (actions & GDK_ACTION_MOVE)
@@ -919,7 +921,7 @@ gtk_drag_get_source_widget (GdkDragContext *context)
   GSList *tmp_list;
 
   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
-  
+
   tmp_list = source_widgets;
   while (tmp_list)
     {
@@ -950,7 +952,7 @@ gtk_drag_get_source_widget (GdkDragContext *context)
  * Informs the drag source that the drop is finished, and
  * that the data of the drag will no longer be required.
  */
-void 
+void
 gtk_drag_finish (GdkDragContext *context,
                  gboolean        success,
                  gboolean        del,
@@ -970,18 +972,18 @@ gtk_drag_finish (GdkDragContext *context,
       GtkWidget *selection_widget = gtk_drag_get_ipc_widget_for_screen (gdk_window_get_screen (gdk_drag_context_get_source_window (context)));
 
       g_object_ref (context);
-      
+
       g_object_set_data (G_OBJECT (selection_widget), I_("drag-context"), context);
       g_signal_connect (selection_widget, "selection-received",
                         G_CALLBACK (gtk_drag_selection_received),
                         NULL);
-      
+
       gtk_selection_convert (selection_widget,
                              gdk_drag_get_selection (context),
                              target,
                              time);
     }
-  
+
   if (!(success && del))
     gdk_drop_finish (context, success, time);
 }
-- 
2.30.2


From ae1208e0e1e201a0abc98522c875d0f5021ce08d Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:48:40 -0500
Subject: Disable GLX.


diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 0d0422e..482541f 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -39,10 +39,13 @@
 
 #include <cairo/cairo-xlib.h>
 
+#if 0
 #include <epoxy/glx.h>
+#endif
 
-G_DEFINE_TYPE (GdkX11GLContext, gdk_x11_gl_context, GDK_TYPE_GL_CONTEXT)
+//G_DEFINE_TYPE (GdkX11GLContext, gdk_x11_gl_context, GDK_TYPE_GL_CONTEXT)
 
+#if 0
 typedef struct {
   GdkDisplay *display;
 
@@ -117,11 +120,13 @@ maybe_wait_for_vblank (GdkDisplay  *display,
       glXWaitVideoSyncSGI (2, (current_count + 1) % 2, &current_count);
     }
 }
+#endif
 
 void
 gdk_x11_window_invalidate_for_new_frame (GdkWindow      *window,
                                          cairo_region_t *update_area)
 {
+#if 0
   cairo_rectangle_int_t window_rect;
   GdkDisplay *display = gdk_window_get_display (window);
   GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
@@ -194,9 +199,10 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow      *window,
          buffer is fully up-to-date for the swapbuffer */
       cairo_region_union_rectangle (update_area, &window_rect);
     }
-
+#endif
 }
 
+#if 0
 static void
 gdk_gl_blit_region (GdkWindow *window, cairo_region_t *region)
 {
@@ -842,10 +848,14 @@ gdk_x11_gl_context_init (GdkX11GLContext *self)
 {
   self->do_frame_sync = TRUE;
 }
+#endif
 
 gboolean
 gdk_x11_screen_init_gl (GdkScreen *screen)
 {
+	return FALSE;
+
+#if 0
   GdkDisplay *display = gdk_screen_get_display (screen);
   GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
   Display *dpy;
@@ -916,8 +926,10 @@ gdk_x11_screen_init_gl (GdkScreen *screen)
                      display_x11->has_glx_sync_control ? "yes" : "no"));
 
   return TRUE;
+#endif
 }
 
+#if 0
 #define MAX_GLX_ATTRS   30
 
 static gboolean
@@ -1007,6 +1019,7 @@ out:
 
   return retval;
 }
+#endif
 
 struct glvisualinfo {
   int supports_gl;
@@ -1041,6 +1054,7 @@ visual_is_rgba (const GdkVisual *visual)
     visual->blue_mask  == 0x0000ff;
 }
 
+#if 0
 /* This picks a compatible (as in has the same X visual details) visual
    that has "better" characteristics on the GL side */
 static GdkVisual *
@@ -1179,10 +1193,12 @@ save_cached_gl_visuals (GdkDisplay *display, int system, int rgba)
                    (unsigned char *)visualdata, 2);
   gdk_x11_display_error_trap_pop_ignored (display);
 }
+#endif
 
 void
 _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen)
 {
+#if 0
   GdkX11Screen *x11_screen;
   GdkDisplay *display;
   GdkX11Display *display_x11;
@@ -1259,6 +1275,7 @@ _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen)
   save_cached_gl_visuals (display,
                           gdk_x11_visual_get_xvisual (x11_screen->system_visual)->visualid,
                           x11_screen->rgba_visual ? gdk_x11_visual_get_xvisual (x11_screen->rgba_visual)->visualid : 0);
+#endif
 }
 
 GdkGLContext *
@@ -1267,6 +1284,8 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
                                   GdkGLContext *share,
                                   GError      **error)
 {
+	return NULL;
+#if 0
   GdkDisplay *display;
   GdkX11GLContext *context;
   GdkVisual *visual;
@@ -1296,12 +1315,15 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
   context->is_attached = attached;
 
   return GDK_GL_CONTEXT (context);
+#endif
 }
 
 gboolean
 gdk_x11_display_make_gl_context_current (GdkDisplay   *display,
                                          GdkGLContext *context)
 {
+	return FALSE;
+#if 0
   GdkX11GLContext *context_x11;
   Display *dpy = gdk_x11_display_get_xdisplay (display);
   GdkWindow *window;
@@ -1357,6 +1379,7 @@ gdk_x11_display_make_gl_context_current (GdkDisplay   *display,
     }
 
   return TRUE;
+#endif
 }
 
 /**
@@ -1381,13 +1404,14 @@ gdk_x11_display_get_glx_version (GdkDisplay *display,
   if (!GDK_IS_X11_DISPLAY (display))
     return FALSE;
 
-  if (!gdk_x11_screen_init_gl (gdk_display_get_default_screen (display)))
+  //if (!gdk_x11_screen_init_gl (gdk_display_get_default_screen (display)))
     return FALSE;
-
+#if 0
   if (major != NULL)
     *major = GDK_X11_DISPLAY (display)->glx_version / 10;
   if (minor != NULL)
     *minor = GDK_X11_DISPLAY (display)->glx_version % 10;
 
   return TRUE;
+#endif
 }
diff --git a/gdk/x11/gdkglcontext-x11.h b/gdk/x11/gdkglcontext-x11.h
index 44cb0d5..753b265 100644
--- a/gdk/x11/gdkglcontext-x11.h
+++ b/gdk/x11/gdkglcontext-x11.h
@@ -1,7 +1,7 @@
 /* GDK - The GIMP Drawing Kit
  *
  * gdkglcontext-x11.h: Private X11 specific OpenGL wrappers
- * 
+ *
  * Copyright © 2014  Emmanuele Bassi
  *
  * This library is free software; you can redistribute it and/or
@@ -24,8 +24,8 @@
 #include <X11/X.h>
 #include <X11/Xlib.h>
 
-#include <epoxy/gl.h>
-#include <epoxy/glx.h>
+//#include <epoxy/gl.h>
+//#include <epoxy/glx.h>
 
 #include "gdkglcontextprivate.h"
 #include "gdkdisplayprivate.h"
@@ -40,9 +40,9 @@ struct _GdkX11GLContext
 {
   GdkGLContext parent_instance;
 
-  GLXContext glx_context;
+  /*GLXContext glx_context;
   GLXFBConfig glx_config;
-  GLXDrawable drawable;
+  GLXDrawable drawable;*/
 
   guint is_attached : 1;
   guint is_direct : 1;
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 48237d1..79d786e 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -31,6 +31,7 @@
 #include "gtkadjustment.h"
 #include "gtkbox.h"
 
+#undef GDK_WINDOWING_X11
 #ifdef GDK_WINDOWING_X11
 #include "x11/gdkx.h"
 #include <epoxy/glx.h>
-- 
2.30.2


From f324f93a943cf45ed842f6821bdb87e5f8288b9b Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:49:39 -0500
Subject: Build without ATK-bridge.


diff --git a/configure b/configure
index 887d6d5..c1f9910 100755
--- a/configure
+++ b/configure
@@ -27043,8 +27043,8 @@ fi
 ########################################
 
 if test x$enable_x11_backend = xyes; then
-   ATK_PACKAGES="atk atk-bridge-2.0"
-else
+#   ATK_PACKAGES="atk atk-bridge-2.0"
+#else
    ATK_PACKAGES="atk"
 fi
 
diff --git a/gtk/a11y/gtkaccessibility.c b/gtk/a11y/gtkaccessibility.c
index 7f0e520..78b979b 100644
--- a/gtk/a11y/gtkaccessibility.c
+++ b/gtk/a11y/gtkaccessibility.c
@@ -38,7 +38,8 @@
 #include <gtk/gtkaccessible.h>
 
 #ifdef GDK_WINDOWING_X11
-#include <atk-bridge.h>
+#undef GDK_WINDOWING_X11
+//#include <atk-bridge.h>
 #endif
 
 static gboolean gail_focus_watcher      (GSignalInvocationHint *ihint,
-- 
2.30.2


From d4c5484f070af803592211f6cca9b014350d317f Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:50:15 -0500
Subject: Disable another XI2 usage.


diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 7e08f47..2ce9544 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -3083,8 +3083,7 @@ gdk_x11_display_get_default_seat (GdkDisplay *display)
     }
 
   gdk_x11_display_error_trap_push (display);
-  result = XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display),
-                               None, &device_id);
+  result = BadImplementation;//XIGetClientPointer (GDK_DISPLAY_XDISPLAY (display), None, &device_id);
   gdk_x11_display_error_trap_pop_ignored (display);
 
   for (l = seats; l; l = l->next)
-- 
2.30.2


From 6234d5fecc236fc22e797225b5a7d917ce8863e8 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:51:09 -0500
Subject: Rework keyboard handling code to be more compatible with Xlibe.


diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c
index 350a79b..9953e3d 100644
--- a/gdk/x11/gdkdevicemanager-core-x11.c
+++ b/gdk/x11/gdkdevicemanager-core-x11.c
@@ -151,7 +151,7 @@ translate_key_event (GdkDisplay              *display,
                      XEvent                  *xevent)
 {
   GdkKeymap *keymap = gdk_keymap_get_for_display (display);
-  GdkModifierType consumed, state;
+  GdkModifierType consumed = 0, state = 0;
 
   event->key.type = xevent->xany.type == KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE;
   event->key.time = xevent->xkey.time;
@@ -164,20 +164,40 @@ translate_key_event (GdkDisplay              *display,
 
   event->key.keyval = GDK_KEY_VoidSymbol;
 
+#if 0
   gdk_keymap_translate_keyboard_state (keymap,
                                        event->key.hardware_keycode,
                                        event->key.state,
                                        event->key.group,
                                        &event->key.keyval,
                                        NULL, NULL, &consumed);
+#endif
 
   state = event->key.state & ~consumed;
   _gdk_x11_keymap_add_virt_mods (keymap, &state);
   event->key.state |= state;
 
+#ifndef __HAIKU__
   event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
 
   _gdk_x11_event_translate_keyboard_string (&event->key);
+#else
+  // KeyEvents contain hidden data with a full UTF-8 string representing
+  // the key event on Haiku (and maybe elsewhere.) We have to use XLookupString
+  // instead of the GDK keymap processing functions in order to utilize it.
+  KeySym keysym;
+  char buffer[8] = {};
+  event->key.string = NULL;
+  XLookupString(&xevent->xkey, buffer, sizeof(buffer), &keysym, NULL);
+  event->key.keyval = keysym;
+  event->key.length = strlen(buffer);
+  if (event->key.length) {
+    event->key.string = g_strdup(buffer);
+    keysym = gdk_unicode_to_keyval(g_utf8_get_char(buffer));
+    if (event->key.keyval == NoSymbol || keysym < 0x01000000)
+    	event->key.keyval = keysym;
+  }
+#endif
 
 #ifdef G_ENABLE_DEBUG
   if (GDK_DEBUG_CHECK (EVENTS))
@@ -689,7 +709,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
                                                xevent->xfocus.mode);
       return_val = FALSE;
       break;
-                                              
+
     default:
         return_val = FALSE;
     }
diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c
index 577e4a1..8fc265d 100644
--- a/gdk/x11/gdkkeys-x11.c
+++ b/gdk/x11/gdkkeys-x11.c
@@ -183,6 +183,10 @@ update_modmap (Display      *display,
   for (i = 0; i < 8; i++)
     keymap_x11->modmap[i] = 1 << i;
 
+#ifdef __HAIKU__
+	return;
+#endif
+
   for (i = 0; i < XkbNumVirtualMods; i++)
     {
       for (j = 0; vmods[j].atom; j++)
@@ -584,7 +588,7 @@ update_direction (GdkX11Keymap *keymap_x11,
 
   had_direction = keymap_x11->have_direction;
   old_direction = keymap_x11->current_direction;
-
+#ifndef __HAIKU__
   group_atom = xkb->names->groups[group];
 
   /* a group change? */
@@ -594,7 +598,7 @@ update_direction (GdkX11Keymap *keymap_x11,
       keymap_x11->current_group_atom = group_atom;
       keymap_x11->have_direction = TRUE;
     }
-
+#endif
   return !had_direction || old_direction != keymap_x11->current_direction;
 }
 
@@ -795,11 +799,24 @@ gdk_x11_keymap_get_entries_for_keyval (GdkKeymap     *keymap,
 
   retval = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
 
+#ifdef __HAIKU__
+  if (1) {
+  	Display* xdisplay = GDK_X11_DISPLAY(GDK_KEYMAP (keymap_x11)->display)->xdisplay;
+    KeyCode code = XKeysymToKeycode(xdisplay, keyval);
+    if (code) {
+      GdkKeymapKey key;
+      key.keycode = code;
+      key.group = 0;
+      key.level = 0;
+      g_array_append_val (retval, key);
+    }
+  } else
+#endif
+
 #ifdef HAVE_XKB
   if (KEYMAP_USE_XKB (keymap))
     {
       /* See sec 15.3.4 in XKB docs */
-
       XkbDescRec *xkb = get_xkb (keymap_x11);
       gint keycode;
 
@@ -940,6 +957,23 @@ gdk_x11_keymap_get_entries_for_keycode (GdkKeymap     *keymap,
   else
     keyval_array = NULL;
 
+#ifdef __HAIKU__
+  if (1) {
+  	Display* xdisplay = GDK_X11_DISPLAY(GDK_KEYMAP (keymap_x11)->display)->xdisplay;
+    KeySym keysym = XKeycodeToKeysym(xdisplay, hardware_keycode, 0);
+    if (keysym != NoSymbol) {
+       GdkKeymapKey key;
+       key.keycode = hardware_keycode;
+       key.group = 0;
+       key.level = 0;
+       if (key_array)
+          g_array_append_val (key_array, key);
+       if (keyval_array)
+          g_array_append_val (keyval_array, keysym);
+    }
+  } else
+#endif
+
 #ifdef HAVE_XKB
   if (KEYMAP_USE_XKB (keymap))
     {
@@ -1318,6 +1352,7 @@ gdk_x11_keymap_translate_keyboard_state (GdkKeymap       *keymap,
       state &= ~(1 << 13 | 1 << 14);
       state |= group << 13;
 
+#ifndef __HAIKU__
       MyEnhancedXkbTranslateKeyCode (xkb,
                                      hardware_keycode,
                                      state,
@@ -1325,6 +1360,17 @@ gdk_x11_keymap_translate_keyboard_state (GdkKeymap       *keymap,
                                      &tmp_keyval,
                                      effective_group,
                                      level);
+#else
+      XkbTranslateKeyCode (xkb,
+                           hardware_keycode,
+                           state,
+                           &tmp_modifiers,
+                           &tmp_keyval);
+      if (effective_group)
+        *effective_group = 0;
+      if (level)
+        *level = 0;
+#endif
 
       if (state & ~tmp_modifiers & LockMask)
         tmp_keyval = gdk_keyval_to_upper (tmp_keyval);
-- 
2.30.2


From 4a80c50a8cb38aba5b792a1a7254bac894531459 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 18:52:45 -0500
Subject: Atoms are pointer-width not integer-width.

Important for Xlibe.

diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index 7a8046e..4a4712d 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -57,9 +57,9 @@ insert_atom_pair (GdkDisplay *display,
   
   g_hash_table_insert (display_x11->atom_from_virtual, 
 		       GDK_ATOM_TO_POINTER (virtual_atom), 
-		       GUINT_TO_POINTER (xatom));
+		       (gpointer) (xatom));
   g_hash_table_insert (display_x11->atom_to_virtual,
-		       GUINT_TO_POINTER (xatom), 
+		       (gpointer) (xatom),
 		       GDK_ATOM_TO_POINTER (virtual_atom));
 }
 
@@ -73,7 +73,7 @@ lookup_cached_xatom (GdkDisplay *display,
     return ATOM_TO_INDEX (atom);
   
   if (display_x11->atom_from_virtual)
-    return GPOINTER_TO_UINT (g_hash_table_lookup (display_x11->atom_from_virtual,
+    return (Atom) (g_hash_table_lookup (display_x11->atom_from_virtual,
 						  GDK_ATOM_TO_POINTER (atom)));
 
   return None;
-- 
2.30.2


From dd8a375af5ea8de028db75ecfcec81c6a087f095 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 20:01:57 -0500
Subject: Pretend for one test we are not using X11.


diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
index 24540e3..5fd75b5 100644
--- a/testsuite/gtk/objects-finalize.c
+++ b/testsuite/gtk/objects-finalize.c
@@ -19,6 +19,7 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#undef GDK_WINDOWING_X11
 #ifdef GDK_WINDOWING_X11
 # include <gdk/gdkx.h>
 #endif
-- 
2.30.2


From aa7ef4d72741aa6aa0f1df84b9e34176d7fe67a0 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 18 Jan 2022 20:20:22 -0500
Subject: HACK: gtkiconhelper: Do not crash when failing to find the fallback
 icon.

Somehow, resources appear to be somewhat broken, and the icon is
not actually included. This deserves investigation.

diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index f6e3e29..83a9c87 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -491,8 +491,8 @@ ensure_surface_for_gicon (GtkIconHelper    *self,
                                               &error);
       /* We include this image as resource, so we always have it available or
        * the icontheme code is broken */
-      g_assert_no_error (error);
-      g_assert (destination);
+      //g_assert_no_error (error);
+      //g_assert (destination);
       symbolic = FALSE;
     }
 
-- 
2.30.2


From 49df1cb0482d9e2ced5abb08b81957b17d59af94 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 26 Jan 2022 22:58:51 +1000
Subject: Use haiku icon theme by default


diff --git a/gtk/gtksettingsprivate.h b/gtk/gtksettingsprivate.h
index 47f75a6..3dbf348 100644
--- a/gtk/gtksettingsprivate.h
+++ b/gtk/gtksettingsprivate.h
@@ -24,7 +24,7 @@
 G_BEGIN_DECLS
 
 #define DEFAULT_THEME_NAME      "Adwaita"
-#define DEFAULT_ICON_THEME      "Adwaita"
+#define DEFAULT_ICON_THEME      "haiku"
 
 void                _gtk_settings_set_property_value_from_rc (GtkSettings            *settings,
                                                               const gchar            *name,
-- 
2.30.2

