view lcdemu/window.c @ 923:10b4bed10192

gsm-fw/L1: fix for the DSP patch corruption bug The L1 code we got from the LoCosto fw contains a feature for DSP CPU load measurement. This feature is a LoCosto-ism, i.e., not applicable to earlier DBB chips (Calypso) with their respective earlier DSP ROMs. Most of the code dealing with that feature is conditionalized as #if (DSP >= 38), but one spot was missed, and the MCU code was writing into an API word dealing with this feature. In TCS211 this DSP API word happens to be used by the DSP code patch, hence that write was corrupting the patched DSP code.
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 19 Oct 2015 17:13:56 +0000
parents e54abee27e8f
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);
}