Adding st embedder patch

This commit is contained in:
bakkeby 2020-01-07 08:05:00 +01:00
parent e76c4c0637
commit 352170eec8
7 changed files with 116 additions and 1 deletions

50
patch/st_embedder_x.c Normal file
View file

@ -0,0 +1,50 @@
static Window embed;
void
createnotify(XEvent *e)
{
XWindowChanges wc;
if (embed || e->xcreatewindow.override_redirect)
return;
embed = e->xcreatewindow.window;
XReparentWindow(xw.dpy, embed, xw.win, 0, 0);
XSelectInput(xw.dpy, embed, PropertyChangeMask | StructureNotifyMask | EnterWindowMask);
XMapWindow(xw.dpy, embed);
sendxembed(XEMBED_EMBEDDED_NOTIFY, 0, xw.win, 0);
wc.width = win.w;
wc.height = win.h;
XConfigureWindow(xw.dpy, embed, CWWidth | CWHeight, &wc);
XSetInputFocus(xw.dpy, embed, RevertToParent, CurrentTime);
}
void
destroynotify(XEvent *e)
{
visibility(e);
if (embed == e->xdestroywindow.window) {
focus(e);
}
}
void
sendxembed(long msg, long detail, long d1, long d2)
{
XEvent e = { 0 };
e.xclient.window = embed;
e.xclient.type = ClientMessage;
e.xclient.message_type = xw.xembed;
e.xclient.format = 32;
e.xclient.data.l[0] = CurrentTime;
e.xclient.data.l[1] = msg;
e.xclient.data.l[2] = detail;
e.xclient.data.l[3] = d1;
e.xclient.data.l[4] = d2;
XSendEvent(xw.dpy, embed, False, NoEventMask, &e);
}

7
patch/st_embedder_x.h Normal file
View file

@ -0,0 +1,7 @@
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
#define XEMBED_FOCUS_CURRENT 0
static void createnotify(XEvent *e);
static void destroynotify(XEvent *e);
static void sendxembed(long msg, long detail, long d1, long d2);

View file

@ -17,6 +17,9 @@
#if RIGHTCLICKTOPLUMB_PATCH
#include "rightclicktoplumb_x.c"
#endif
#if ST_EMBEDDER_PATCH
#include "st_embedder_x.c"
#endif
#if VISUALBELL_2_PATCH || VISUALBELL_3_PATCH
#include "visualbell.c"
#endif

View file

@ -14,6 +14,9 @@
#if RIGHTCLICKTOPLUMB_PATCH
#include "rightclicktoplumb_x.h"
#endif
#if ST_EMBEDDER_PATCH
#include "st_embedder_x.h"
#endif
#if VISUALBELL_2_PATCH || VISUALBELL_3_PATCH
#include "visualbell.h"
#endif