|
| 1 | +// Script to expose a problem with Compositor on hosted. |
| 2 | +// If you open a screen which is smaller than the workbench you can |
| 3 | +// move the workbench screen above the limit of the X11 Window. |
| 4 | + |
| 5 | +#include <proto/exec.h> |
| 6 | +#include <proto/dos.h> |
| 7 | +#include <proto/intuition.h> |
| 8 | + |
| 9 | +#include <stdlib.h> |
| 10 | + |
| 11 | +static struct Window *window; |
| 12 | +static struct Screen *screen; |
| 13 | +static struct Screen *wbscreen; |
| 14 | + |
| 15 | +static void clean_exit(CONST_STRPTR s); |
| 16 | +static void draw_stuff(void); |
| 17 | +static void handle_events(void); |
| 18 | + |
| 19 | +int main(void) |
| 20 | +{ |
| 21 | + wbscreen = LockPubScreen(NULL); |
| 22 | + |
| 23 | + // open a small screen |
| 24 | + screen = OpenScreenTags(NULL, |
| 25 | + SA_Width, 320, |
| 26 | + SA_Height, 200, |
| 27 | + SA_Type, CUSTOMSCREEN, |
| 28 | + TAG_END); |
| 29 | + |
| 30 | + if (! screen) clean_exit("Can't open screen\n"); |
| 31 | + |
| 32 | + window = OpenWindowTags(NULL, |
| 33 | + WA_Width, 300, |
| 34 | + WA_Height, 200, |
| 35 | + WA_Activate, TRUE, |
| 36 | + WA_CloseGadget, TRUE, |
| 37 | + WA_DragBar, TRUE, |
| 38 | + WA_IDCMP, IDCMP_CLOSEWINDOW, |
| 39 | + WA_RMBTrap, TRUE, |
| 40 | + WA_CustomScreen, screen, // Link to screen |
| 41 | + TAG_END); |
| 42 | + |
| 43 | + if (! window) clean_exit("Can't open window\n"); |
| 44 | + |
| 45 | + // you can either move the screens with the mouse |
| 46 | + // or you can move them with the following lines. |
| 47 | +#if 0 |
| 48 | + MoveScreen(screen, 0, 100); |
| 49 | + MoveScreen(wbscreen, 0, -100); |
| 50 | +#endif |
| 51 | + |
| 52 | + handle_events(); |
| 53 | + |
| 54 | + clean_exit(NULL); |
| 55 | + |
| 56 | + return 0; |
| 57 | +} |
| 58 | + |
| 59 | +static void handle_events(void) |
| 60 | +{ |
| 61 | + struct MsgPort *port = window->UserPort; |
| 62 | + |
| 63 | + BOOL terminated = FALSE; |
| 64 | + |
| 65 | + while (! terminated) |
| 66 | + { |
| 67 | + struct IntuiMessage *imsg; |
| 68 | + Wait(1L << port->mp_SigBit); |
| 69 | + |
| 70 | + while ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL) |
| 71 | + { |
| 72 | + switch (imsg->Class) |
| 73 | + { |
| 74 | + case IDCMP_CLOSEWINDOW: |
| 75 | + terminated = TRUE; |
| 76 | + break; |
| 77 | + } |
| 78 | + ReplyMsg((struct Message *)imsg); |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | + |
| 84 | +static void clean_exit(CONST_STRPTR s) |
| 85 | +{ |
| 86 | + if (s) PutStr(s); |
| 87 | + |
| 88 | + // Give back allocated resourses |
| 89 | + if (window) CloseWindow(window); |
| 90 | + if (screen) CloseScreen(screen); |
| 91 | + if (wbscreen) UnlockPubScreen(NULL, wbscreen); |
| 92 | + |
| 93 | + exit(0); |
| 94 | +} |
0 commit comments