FreeCalypso > hg > freecalypso-tools
view lcdemu/window.c @ 266:f0662279848c
CHANGES: removal of ffstools/aud-fcdev3b is the first post-r7 change
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 20 Oct 2017 03:58:13 +0000 |
parents | e7502631a0f9 |
children |
line wrap: on
line source
/* * LCDemu based on HECterm by the same author * X11 window creation functions */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <X11/Xlib.h> #include <X11/Xresource.h> #include <X11/Xutil.h> #include "globals.h" extern char *xrm_lookup(); create_our_window() { XrmQuark instquarks[3], classquarks[3]; register char *cp; register int i, geomask; int pixwidth, pixheight, xpos, ypos; XSetWindowAttributes xswa; u_long xswamask; XColor bdcolor; XClassHint xclasshint; XWMHints wmhints; XSizeHints wm_normal_hints; /* Determine our geometry */ instquarks[0] = xrmquark_topinstance; classquarks[0] = xrmquark_topclass; classquarks[1] = instquarks[1] = XrmStringToQuark("geometry"); instquarks[2] = classquarks[2] = NULLQUARK; cp = xrm_lookup(instquarks, classquarks); if (cp) { geomask = XParseGeometry(cp, &xpos, &ypos, &pixwidth, &pixheight); free(cp); } else geomask = 0; if (!(geomask & WidthValue)) pixwidth = 176; if (!(geomask & HeightValue)) pixheight = 220; if (!(geomask & XValue)) xpos = 0; else if (geomask & XNegative) xpos += DisplayWidth(mydisplay, DefaultScreen(mydisplay)) - pixwidth; if (!(geomask & YValue)) ypos = 0; else if (geomask & YNegative) ypos += DisplayHeight(mydisplay, DefaultScreen(mydisplay)) - pixheight; /* fill out XSetWindowAttributes */ xswa.event_mask = 0; /* not interested in any events */ xswamask = CWEventMask; /* border color */ classquarks[1] = instquarks[1] = XrmStringToQuark("borderColor"); cp = xrm_lookup(instquarks, classquarks); if (cp) { i = XParseColor(mydisplay, DefaultColormap(mydisplay, DefaultScreen(mydisplay)), cp, &bdcolor); free(cp); if (i) { i = XAllocColor(mydisplay, DefaultColormap(mydisplay, DefaultScreen(mydisplay)), &bdcolor); if (i) { xswa.border_pixel = bdcolor.pixel; xswamask |= CWBorderPixel; } } } /* border width */ classquarks[1] = instquarks[1] = XrmStringToQuark("borderWidth"); cp = xrm_lookup(instquarks, classquarks); if (cp) { i = atoi(cp); free(cp); } else i = 2; /* go for it! */ mainwindow = XCreateWindow(mydisplay, DefaultRootWindow(mydisplay), xpos, ypos, pixwidth, pixheight, i, CopyFromParent, InputOutput, CopyFromParent, xswamask, &xswa); /* set window manager properties */ xclasshint.res_name = proginstancename; xclasshint.res_class = "LEDemu"; XSetClassHint(mydisplay, mainwindow, &xclasshint); wmhints.flags = InputHint | StateHint; wmhints.input = False; classquarks[1] = instquarks[1] = XrmStringToQuark("iconic"); cp = xrm_lookup(instquarks, classquarks); if (cp) { i = parse_boolean_resource(cp); free(cp); } else i = 0; wmhints.initial_state = i ? IconicState : NormalState; XSetWMHints(mydisplay, mainwindow, &wmhints); if (geomask & (WidthValue|HeightValue)) wm_normal_hints.flags = USSize; else wm_normal_hints.flags = PSize; if (geomask & (XValue|YValue)) wm_normal_hints.flags |= USPosition; XSetWMNormalHints(mydisplay, mainwindow, &wm_normal_hints); } set_initial_window_title() { XrmQuark instquarks[3], classquarks[3]; register char *cp; char buf[256]; instquarks[0] = xrmquark_topinstance; classquarks[0] = xrmquark_topclass; instquarks[1] = XrmStringToQuark("title"); classquarks[1] = XrmStringToQuark("Title"); instquarks[2] = classquarks[2] = NULLQUARK; cp = xrm_lookup(instquarks, classquarks); if (cp) { XStoreName(mydisplay, mainwindow, cp); free(cp); return; } XStoreName(mydisplay, mainwindow, "Emulated LCD"); } set_initial_icon_name() { XrmQuark instquarks[3], classquarks[3]; register char *cp; instquarks[0] = xrmquark_topinstance; classquarks[0] = xrmquark_topclass; instquarks[1] = XrmStringToQuark("iconName"); classquarks[1] = XrmStringToQuark("IconName"); instquarks[2] = classquarks[2] = NULLQUARK; cp = xrm_lookup(instquarks, classquarks); if (cp) { XSetIconName(mydisplay, mainwindow, cp); free(cp); return; } XSetIconName(mydisplay, mainwindow, proginstancename); } create_mainwin_gc() { XGCValues xgcval; xgcval.graphics_exposures = False; mainwingc = XCreateGC(mydisplay, mainwindow, GCGraphicsExposures, &xgcval); }