Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
openSUSE:Leap:15.1
xroach
xroach.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xroach.dif of Package xroach
--- Imakefile +++ Imakefile @@ -1,6 +1,6 @@ SYS_LIBRARIES = -lm LOCAL_LIBRARIES = $(XLIB) -SRCS = xroach.c -OBJS = xroach.o +SRCS = xroach.c toon_root.c +OBJS = xroach.o toon_root.o ComplexProgramTarget(xroach) --- xroach.c +++ xroach.c @@ -55,7 +55,7 @@ Display *display; int screen; -Window rootWin; +Window rootWin, clientparent; unsigned int display_width, display_height; int center_x, center_y; GC gc; @@ -82,10 +82,15 @@ int steps; } Roach; +int minx = 10000; +int miny = 10000; +int maxx = 0; +int maxy = 0; + Roach *roaches; int maxRoaches = 10; int curRoaches = 0; -float roachSpeed = 20.0; +float roachSpeed = 1.0; Region rootVisible = NULL; @@ -100,7 +105,7 @@ Pixel AllocNamedColor(); Window FindRootWindow(); -void +int main(ac, av) int ac; char *av[]; @@ -118,6 +123,8 @@ int needCalc; Window squishWin; XSetWindowAttributes xswa; + unsigned int toon_expose = 0; + unsigned int redrawIcons = 0; /* Process command line options. @@ -166,7 +173,7 @@ } screen = DefaultScreen(display); - rootWin = FindRootWindow(); + rootWin = ToonGetRootWindow(display, screen, &clientparent); black = BlackPixel(display, screen); white = WhitePixel(display, screen); @@ -213,7 +220,19 @@ while (curRoaches < maxRoaches) AddRoach(); - XSelectInput(display, rootWin, ExposureMask | SubstructureNotifyMask); + if (rootWin != RootWindow(display, screen)) { + if (rootWin == clientparent) { + XSelectInput(display, rootWin, ExposureMask | SubstructureNotifyMask + | StructureNotifyMask); + } + else { + XSelectInput(display, rootWin, ExposureMask | StructureNotifyMask); + XSelectInput(display, clientparent, ExposureMask | SubstructureNotifyMask); + } + } + else { + XSelectInput(display, clientparent, ExposureMask | SubstructureNotifyMask); + } if (squishRoach) { xswa.event_mask = ButtonPressMask; @@ -225,6 +244,16 @@ XLowerWindow(display, squishWin); } +/* Will we redraw icons? */ + + { + XWindowAttributes attributes; + + XGetWindowAttributes(display, rootWin, &attributes); + if (attributes.all_event_masks & ExposureMask) + toon_expose = 1; + } + needCalc = 1; while (!done) { if (XPending(display)) { @@ -244,6 +273,7 @@ XMapWindow(display, squishWin); squishWinUp = True; } + redrawIcons=1; } else { if (squishWinUp && squishRoach) { @@ -252,6 +282,26 @@ } if (needCalc == 0) DrawRoaches(); + if (toon_expose && redrawIcons + && maxx > minx && maxy > miny) { + XExposeEvent event; + + event.type = Expose; + event.send_event = True; + event.display = display; + event.window = rootWin; + event.x = minx; + event.y = miny; + event.width = maxx-minx + 1; + event.height = maxy-miny + 1; + XSendEvent(display, rootWin, True, Expose, + (XEvent *) &event); + minx = 10000; + maxx = 0; + miny = 10000; + maxy = 0; + redrawIcons = 0; + } eventBlock = 1; XNextEvent(display, &ev); eventBlock = 0; @@ -502,6 +552,14 @@ roach->x = newX; roach->y = newY; + if (newX < minx) + minx = newX; + if (newX+roach->rp->width > maxx) + maxx = newX+roach->rp->width; + if (newY < miny) + miny = newY; + if (newY+roach->rp->height > maxy) + maxy = newY+roach->rp->height; if (roach->steps-- <= 0) { TurnRoach(roach); @@ -608,10 +666,11 @@ XWindowAttributes wa; int wx; XRectangle rect; - int winX, winY; + int winX, winY, x, y, toon_display_width, toon_display_height, x_offset=0, y_offset=0; unsigned int winHeight, winWidth; unsigned int borderWidth; unsigned int depth; + unsigned int width, height; /* If we don't grab the server, the XGetWindowAttribute or XGetGeometry @@ -624,10 +683,19 @@ XSetErrorHandler(RoachErrors); #endif + /* Check to see if rootWin has moved with respect to clientparent */ + XGetWindowAttributes(display, rootWin, &wa); + toon_display_width = wa.width; + toon_display_height = wa.height; + if (rootWin != clientparent) { + x_offset = wa.x; + y_offset = wa.y; + } + /* Get children of root. */ - XQueryTree(display, rootWin, &dummy, &dummy, &children, &nChildren); + XQueryTree(display, clientparent, &dummy, &dummy, &children, &nChildren); /* For each mapped child, add the window rectangle to the covered @@ -643,6 +711,19 @@ XGetWindowAttributes(display, children[wx], &wa); if (errorVal) continue; if (wa.class == InputOutput && wa.map_state == IsViewable) { + + x = wa.x - x_offset; + y = wa.y - y_offset; + width = wa.width + 2*wa.border_width; + height = wa.height + 2*wa.border_width; + + /* Entirely offscreen? */ + if (x >= toon_display_width) continue; + if (y >= toon_display_height) continue; + if ((y + height) <= 0) continue; + if ((x + width) <= 0) continue; + if ((y <= 0) && ((y + height) >= toon_display_height) && (x <= 0) && ((x + width) >= toon_display_width)) continue; + XGetGeometry(display, children[wx], &dummy, &winX, &winY, &winWidth, &winHeight, &borderWidth, &depth); if (errorVal) continue; --- xroach.man +++ xroach.man @@ -20,8 +20,8 @@ Use the given string as the color for the bugs instead of the default "black". .TP 8 .B \-speed \fIroach_speed\fB -Use the given speed for the insects instead of the default 20.0. For example, -in winter the speed should be set to 5.0. In summer, 30.0 might be about +Use the given speed for the insects instead of the default 1.0. For example, +in winter the speed should be set to 0.1. In summer, 2.0 might be about right. .TP 8 .B \-roaches \fInum_roaches\fB --- xroach.c.orig 2005-04-07 18:48:09.000000000 +0200 +++ ./xroach.c 2005-04-07 18:49:04.887000769 +0200 @@ -104,6 +104,8 @@ int CalcRootVisible(); int MarkHiddenRoaches(); Pixel AllocNamedColor(); Window FindRootWindow(); +void checkSquish(XButtonEvent *buttonEvent); + int main(ac, av) @@ -121,7 +123,7 @@ char *av[]; char *gutsColor = NULL; int nVis; int needCalc; - Window squishWin; + Window squishWin = 0; XSetWindowAttributes xswa; unsigned int toon_expose = 0; unsigned int redrawIcons = 0; @@ -827,7 +829,7 @@ Pixel dfltPix; /* * squishCheck - Check to see if we have to squish any roaches. */ -checkSquish(buttonEvent) +void checkSquish(buttonEvent) XButtonEvent *buttonEvent; { int x, y;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor