-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.c
41 lines (29 loc) · 865 Bytes
/
resize.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "resize.h"
int resize(int window_id,int x, int y, int width, int height) {
char command[256];
int ret;
// Prepare the command to run the script with the value
snprintf(command, sizeof(command), "./resize.sh %d", window_id);
// Execute the script
ret = system(command);
Display *display = XOpenDisplay(NULL);
if (display == NULL) {
printf("Unable to open X display\n");
return 1;
}
if (XMoveResizeWindow(display, window_id,x,y, width, height) == 0) {
printf("Failed to resize window\n");
XCloseDisplay(display);
return 1;
}
XRaiseWindow(display, window_id);
// Flush the X server
XFlush(display);
// Clean up
XCloseDisplay(display);
return 0;
}