comparison src/balloon_help.c @ 157:6b37e6ddd302 r20-3b5

Import from CVS: tag r20-3b5
author cvs
date Mon, 13 Aug 2007 09:40:41 +0200
parents 43dd3413c7c7
children 15872534500d
comparison
equal deleted inserted replaced
156:60baf0b43294 157:6b37e6ddd302
28 * Written by Douglas Keller <dkeller@vnet.ibm.com> 28 * Written by Douglas Keller <dkeller@vnet.ibm.com>
29 * 29 *
30 * 30 *
31 */ 31 */
32 32
33 #include <config.h>
33 #include <string.h> 34 #include <string.h>
34 #include <stdio.h> 35 #include <stdio.h>
35 #include <stdlib.h> 36 #include <stdlib.h>
36 #include <assert.h> 37 #include <assert.h>
37 38
41 42
42 #include <X11/Intrinsic.h> 43 #include <X11/Intrinsic.h>
43 44
44 #include "balloon_help.h" 45 #include "balloon_help.h"
45 46
46 #include "config.h"
47 #ifndef WINDOWSNT 47 #ifndef WINDOWSNT
48 #define max(x,y) (x>y?x:y) 48 #define max(x,y) (x>y?x:y)
49 #endif 49 #endif
50 50
51 #undef bool 51 #undef bool
286 286
287 static int 287 static int
288 get_shape (int last_shape, int x, int y, int width, int height, 288 get_shape (int last_shape, int x, int y, int width, int height,
289 int screen_width, int screen_height) 289 int screen_width, int screen_height)
290 { 290 {
291 /* Can we use last_shape */ 291 /* Can we use last_shape? */
292 if (SHAPE_CONE_TOP_LEFT == last_shape) 292 if (((last_shape == SHAPE_CONE_TOP_LEFT) &&
293 { 293 (x + width < screen_width) && (y + height < screen_height)) ||
294 if ((x + width < screen_width) && (y + height < screen_height)) 294 ((last_shape == SHAPE_CONE_TOP_RIGHT) &&
295 { 295 (x - width > 0) && (y + height < screen_height)) ||
296 return last_shape; 296 ((last_shape == SHAPE_CONE_BOTTOM_LEFT) &&
297 } 297 (x + width < screen_width) && (y - height > 0)) ||
298 } 298 ((last_shape == SHAPE_CONE_BOTTOM_RIGHT) &&
299 else if (SHAPE_CONE_TOP_RIGHT == last_shape) 299 (x - width > 0) && (y - height > 0)))
300 { 300 return last_shape;
301 if ((x - width > 0) && (y + height < screen_height)) 301
302 { 302 /* Try to pick a shape that will not get changed,
303 return last_shape; 303 e.g. if top left quadrant, top_left */
304 } 304 return (x < screen_width / 2) ?
305 } 305 (y < screen_height / 2 ? SHAPE_CONE_TOP_LEFT: SHAPE_CONE_BOTTOM_LEFT) :
306 else if (SHAPE_CONE_BOTTOM_LEFT == last_shape) 306 (y < screen_height / 2 ? SHAPE_CONE_TOP_RIGHT: SHAPE_CONE_BOTTOM_RIGHT);
307 {
308 if ((x + width < screen_width) && (y - height > 0))
309 {
310 return last_shape;
311 }
312 }
313 else if (SHAPE_CONE_BOTTOM_RIGHT == last_shape)
314 {
315 if ((x - width > 0) && (y - height > 0))
316 {
317 return last_shape;
318 }
319 }
320
321 /* Try to pick a shape that will not get changed, ie if top left quadrant, top_left */
322 if (x < screen_width / 2)
323 {
324 if (y < screen_height / 2)
325 {
326 return SHAPE_CONE_TOP_LEFT;
327 }
328 else
329 {
330 return SHAPE_CONE_BOTTOM_LEFT;
331 }
332 }
333 else
334 {
335 if (y < screen_height / 2)
336 {
337 return SHAPE_CONE_TOP_RIGHT;
338 }
339 else
340 {
341 return SHAPE_CONE_BOTTOM_RIGHT;
342 }
343 }
344
345 /* ### if width or height is greater than 1/2 the width or height then we might
346 run off the screen */
347
348 abort ();
349
350 return 0;
351 } 307 }
352 308
353 static void 309 static void
354 make_mask (int shape, int x, int y, int width, int height) 310 make_mask (int shape, int x, int y, int width, int height)
355 { 311 {