-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement bring-to-front for Linux * Add musl-64 binary * Add glibc-64 binary * Add glibc-32 binary * Add musl-32 binary
- Loading branch information
1 parent
6374659
commit 283e1f1
Showing
8 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
all: clean build | ||
clean: | ||
rm "${DEST}/bring-to-front" || true | ||
build: | ||
mkdir "${DEST}" || true | ||
${CXX} bring-to-front.cpp -I/usr/include/X11 -L/usr/lib/X11 -lX11 -o "${DEST}/bring-to-front" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <cstdio> | ||
|
||
extern "C" { | ||
#include <X11/Xlib.h> | ||
#include <X11/Xutil.h> | ||
#include <X11/Xos.h> | ||
} | ||
|
||
int main (int argc, char** argv) { | ||
if (argc != 2) { | ||
printf("Incorrect arguments\n"); | ||
return 1; | ||
} | ||
|
||
unsigned long windowId = 0; | ||
|
||
sscanf(argv[1], "%lx", &windowId); | ||
|
||
Display* display = XOpenDisplay(NULL); | ||
|
||
if (display == NULL) { | ||
printf("Cannot open display\n"); | ||
return 1; | ||
} | ||
|
||
XWindowAttributes attr; | ||
|
||
Atom atom = XInternAtom (display, "_NET_ACTIVE_WINDOW", False);; | ||
XEvent xev; | ||
|
||
xev.xclient.type = ClientMessage; | ||
xev.xclient.serial = 0; | ||
xev.xclient.send_event = True; | ||
xev.xclient.display = display; | ||
xev.xclient.window = (Window) windowId; | ||
xev.xclient.message_type = atom; | ||
xev.xclient.format = 32; | ||
xev.xclient.data.l[0] = 2; | ||
xev.xclient.data.l[1] = 0; | ||
xev.xclient.data.l[2] = 0; | ||
xev.xclient.data.l[3] = 0; | ||
xev.xclient.data.l[4] = 0; | ||
|
||
XGetWindowAttributes(display, (Window) windowId, &attr); | ||
|
||
XSendEvent (display, | ||
attr.root, False, | ||
SubstructureRedirectMask | SubstructureNotifyMask, | ||
&xev); | ||
|
||
XSync(display, False); | ||
|
||
XRaiseWindow(display, (Window) windowId); | ||
XSync(display, False); | ||
|
||
XCloseDisplay(display); | ||
|
||
return 0; | ||
} |