/* gcc -o pager pager.c -lX11 -lXmu -ldockapp */
-#if 0
-#include <X11/extensions/Xrender.h>
-#endif
#include <X11/Xatom.h>
#include <dockapp.h>
+#include <string.h>
#define DOCKAPP_SIZE 56
#define SPEED 100
static Window drag_window;
static int drag_x, drag_y;
static int drag_button;
-static int dockapp_x, dockapp_y, dockapp_width, dockapp_height;
-static unsigned int dockapp_border, dockapp_depth;
+static int dockapp_x, dockapp_y;
+static unsigned int dockapp_width, dockapp_height, dockapp_border, dockapp_depth;
static double scale;
static int desktop_geometry_supported;
int error_handler(Display *display, XErrorEvent *event) {
char buffer[512];
- int length;
switch (event->error_code) {
case BadWindow:
if (! clients[i]->window) continue;
if (! clicked(&clients[i]->rect, x, y)) continue;
- if (button == 4) {
- client_message(client_state_atom, clients[i]->window, 0, above_state, 0, 0, 0);
- client_message(client_state_atom, clients[i]->window, 1, below_state, 0, 0, 0);
- }
- else if (button == 5) {
- client_message(client_state_atom, clients[i]->window, 0, below_state, 0, 0, 0);
- client_message(client_state_atom, clients[i]->window, 1, above_state, 0, 0, 0);
- }
- else {
- drag_window = clients[i]->window;
- drag_button = button;
- drag_x = x - clients[i]->rect.x;
- drag_y = y - clients[i]->rect.y;
- }
+ drag_window = (Window) clients[i]->window;
+ drag_button = button;
+ drag_x = x - clients[i]->rect.x;
+ drag_y = y - clients[i]->rect.y;
break;
}
destroy_clients(&clients, num_clients);
if (button == drag_button) drag_window = 0;
}
-void move(int x, int y) {
- long dest_x, dest_y;
-
- if (! drag_window) return;
- if (x < 0 || y < 0) return;
- if (x >= dockapp_width || y >= dockapp_height) return;
-
- dest_x = (long) ((double) (x - drag_x) * scale);
- dest_y = (long) ((double) (y - drag_y) * scale);
-
- if (moveresize_supported) {
- client_message(moveresize_window_atom, drag_window, StaticGravity | (3 << 8) | (FromTool << 12), drag_x, drag_y, 0, 0);
- }
- else {
- XMoveWindow(DADisplay, drag_window, dest_x, dest_y);
- }
-
- page();
-}
-
void page() {
- Window child, active_window;
- XWindowAttributes attr;
+ Window active_window;
Pixmap pixmap;
- DARect rect;
- long i, j;
+ long i;
unsigned long num_clients;
- long client_desktop, active_desktop;
- int active;
+ unsigned long active_desktop;
GC gc;
client_t **clients;
/* Draw small windows. */
if (clients[i]->rect.width < 2 || clients[i]->rect.height < 2) gc = window_border1GC;
- else if (clients[i]->window == active_window) gc = active_windowGC;
+ else if ((long) clients[i]->window == active_window) gc = active_windowGC;
else gc = inactive_windowGC;
XFillRectangle(DADisplay, pixmap, gc, clients[i]->rect.x, clients[i]->rect.y, clients[i]->rect.width, clients[i]->rect.height);
if (clients[i]->rect.width < 2 || clients[i]->rect.height < 2) continue;
- /* Thumbnail. */
-#if 0
- XRenderPictureAttributes pa;
- Pixmap client_pixmap = XCreatePixmap(DADisplay, wins[i], width, height, DefaultDepth(DADisplay, DefaultScreen(DADisplay)));
- //XCopyArea(DADisplay, wins[i], client_pixmap, DefaultGC(DADisplay, DefaultScreen(DADisplay)), 0, 0, width, height, 0, 0);
- Picture client_picture = XRenderCreatePicture(DADisplay, client_pixmap, XRenderFindVisualFormat(DADisplay, attr.visual), CPSubwindowMode, &pa);
-
- XTransform xform = {{
- { XDoubleToFixed(1.0), 0, 0 },
- { 0, XDoubleToFixed(1.0), 0 },
- { 0, 0, XDoubleToFixed(scale) },
- }};
-
- XRenderSetPictureFilter(DADisplay, client_picture, FilterBilinear, 0, 0);
- XRenderSetPictureTransform(DADisplay, client_picture, &xform);
- XRenderComposite(DADisplay, PictOpSrc, client_picture, None, picture, 0, 0, 0, 0, rect.x, rect.y, rect.width, rect.height);
- XFreePixmap(DADisplay, client_pixmap);
- XSync(DADisplay, False);
-#endif
-
XDrawLine(DADisplay, pixmap, window_border1GC, clients[i]->rect.x, clients[i]->rect.y, clients[i]->rect.x, clients[i]->rect.y + clients[i]->rect.height - 2);
XDrawLine(DADisplay, pixmap, window_border1GC, clients[i]->rect.x + 1, clients[i]->rect.y, clients[i]->rect.x + clients[i]->rect.width - 1, clients[i]->rect.y);
XDrawLine(DADisplay, pixmap, window_border2GC, clients[i]->rect.x, clients[i]->rect.y + clients[i]->rect.height - 1, clients[i]->rect.x + clients[i]->rect.width - 1, clients[i]->rect.y + clients[i]->rect.height - 1);
XFreePixmap(DADisplay, pixmap);
}
+void move(int x, int y) {
+ long dest_x, dest_y;
+
+ if (! drag_window) return;
+ if (x < 0 || y < 0) return;
+ if (x >= dockapp_width || y >= dockapp_height) return;
+
+ dest_x = (long) ((double) (x - drag_x) * scale);
+ dest_y = (long) ((double) (y - drag_y) * scale);
+
+ if (moveresize_supported) {
+ client_message(moveresize_window_atom, drag_window, StaticGravity | (3 << 8) | (FromTool << 12), drag_x, drag_y, 0, 0);
+ }
+ else {
+ XMoveWindow(DADisplay, drag_window, dest_x, dest_y);
+ }
+
+ page();
+}
+
int main(int argc, char **argv) {
Display *display;
unsigned int root_width, root_height;
dockapp_width = (double) DOCKAPP_SIZE / aspect;
}
- DAParseArguments(argc, argv, &options, 1, "BLURB", "BLORB");
+ DAParseArguments(argc, argv, &options, 1, "OPTIONS", "pager");
DAOpenDisplay(0, argc, argv);
DACreateIcon("pager", dockapp_width, dockapp_height, argc, argv);
desktop = get_atom_long(current_desktop_atom, XA_CARDINAL, DefaultRootWindow(DADisplay));
}
else if (desktop-- > num_desktops) {
- fprintf(stderr, "There are only %d desktops!\n", num_desktops);
+ fprintf(stderr, "There are only %ld desktops!\n", num_desktops);
exit(111);
}
setup_GCs();
DAShow();
DAEventLoop();
+
+ exit(0);
}