CMPS-3600 - Spring 2025 - Semester Project

Phase-1 - Send signals to child window -------------------------------------- Start with a working version of your xwin-child.c program. working version is here: /home/fac/gordon/public_html/3600/xwin-child.c Contact the instructor. We wrote this program in class together. If you do not have a working version, let your instructor know. Copy the program to 3600/4/vrphase1.c Do this work in your 3600/4 folder. Functionality for phase-1 ------------------------- 1. Start your parent window. 2. In the parent, press 'C' key to create a child window. 3. In the parent, you will now see two options. A. change the color of the child window. B. terminate the child window. 4. The child window will use one or more signal handlers to receive signals from the parent. Here is an animation showing the functionality. You can do all the controls with the keyboard if you wish. Required for control and communication... 1. signal(2) 2. kill(2) 3. SIGUSR1 and SIGUSR2 signals Step-by-step functionality... 1. Start parent window. 2. Press C. 3. Parent window changes its text. 4. Parent calls fork(2) to start child window. 5. Child sets up a handler for SIGUSR1 and SIGUSR2. 6. Press A in parent. 7. Parent sends SIGUSR1 to child window. 8. Child changes its background color. 9. Press B in parent. 10. Parent sends SIGUSR2 to child window. 11. Child terminates itself. 12. Parent changes its text back to original text. 13. Press Esc to close the parent window. Notes: Do not go to the Internet or AI to find a solution to this. Start with your xwin-child.c program. If you did not follow along in class on this program, contact your instructor in order to get started. Always follow along when we write programs on the big-screen. Look back to your mysignal2.c program. You should use only signal(2), kill(2), with SIGUSR1 and SIGUSR2 signals. You may call render() from a signal handler after receiving a signal.
Code samples ------------ To draw some text on the screen ------------------------------- Define this function... void drawString(int left, int top, char *str) { XDrawString(g.dpy, g.win, g.gc, left, top, str, strlen(str)); } Call it like this... drawString(10, 20, "Parent window");
To use a bold font for easier reading ------------------------------------- Call this function at top of render(): XSetFont(g.dpy, g.gc, XLoadFont(g.dpy, "9x15bold")); Fonts to choose from: "fixed", "5x8", "6x9", "6x10", "6x12", "6x13", "6x13bold", "7x13", "7x13bold", "7x14", "8x13", "8x13bold", "8x16", "9x15", "9x15bold", "10x20", "12x24" Some are bigger, some are more bold. Easy reading.
To draw a rectangle outline --------------------------- draw a rectangle at x=40 y=60 width=40 height=30 XDrawRectangle(g.dpy, g.win, g.gc, 40, 60, 40, 30);