3600 - Operating Systems Semester Project
Phase 1



On Friday of week-4,
we made some updates to our 3600/4/xwin89.c program.

This program creates a child window with a quick and dirty hack,
by calling the main function. It's temporary, but it works for now.

Please make these required updates...

1. The code in your check_keys function. ===================================== The switch statement should look like this... switch (key) { case XK_c: //declare cpid somewhere above of the switch. cpid = fork(); if (cpid == 0) { main(1, myargv, myenvp); exit(0); } break; case XK_Escape: return 1; }
2. In the main function. ===================== You may show a Usage statement if no timer argument is entered, but do not end the program. The timer argument is optional. The program should still run, but with a timer value of 0.
3. Child window starts up with a different background color. ========================================================= Press 'C' to create a child window. When the child window appears, it will have a background color that is different than the parent window. Draw text on the child window such as: "Child window" Notes: The parent window must retain its original color. Your program is not required to handle multiple child windows. How does each window know if it's the parent or child? ------------------------------------------------------ 1. Declare a global variable named child. 2. Initialize child to 0. 3. After the fork, just before the child process calls main, set child to 1. 4. child in the parent process is 0 child in the child process is 1 5. Test the child variable throughout the program to know if you are the parent or child window.
4. Child window prints letter 'c' to the console. ============================================== When the mouse moves inside your child window, print a 'c' character to the Linux console. Do not print a newline character when printing the 'c' character. Do not print spaces between the 'c' characters. When the mouse moves, an event is detected in the main() loop. Try to display one 'c' character for each 10 or 20 mouse events. As you move the mouse a lot, a few 'c' characters will be displayed. Important: The parent's mouse movement will still show 'm' characters.
5. Copy your program. ================== When you have finished the steps above, copy your 3600/4/xwin89.c program to 3600/4/phase1.c This will signify that your instructor can collect and score your work. Notice how the text is very readable on the window. Insert this code into your render function to set a font. XSetFont(g.dpy, g.gc, XLoadFont(g.dpy, "9x15bold")); Insert this function into your phase1.c program, then you can easily select various fonts for your text. //======================================================================== void x11_setFont(unsigned int idx) { char *fonts[] = { "fixed","5x8","6x9","6x10","6x12","6x13","6x13bold", "7x13","7x13bold","7x14","8x13","8x13bold","8x16","9x15","9x15bold", "10x20","12x24" }; Font f = XLoadFont(g.dpy, fonts[idx]); XSetFont(g.dpy, g.gc, f); } //======================================================================== Setting the 9x15 bold font would be a call to: x11_setFont(14); Note: The fonts shown above are standard X11 fonts available. These are not TrueType or scalable fonts. Make your window text readable by using nice colors and font sizes. Please no black text on dark blue background.