Пример #1
0
/*
 * Hide the window to make it and its children invisible on the screen.
 * This is a recursive routine which increments the unmapcount values for
 * this window and all of its children, and causes exposure events for
 * windows which are newly uncovered.
 */
void
MwHideWindow(HWND hwnd,BOOL bChangeFocus, BOOL bSendMsg)
{
	HWND	wp = hwnd;
	HWND	pwp;		/* parent window */
	HWND	sibwp;		/* sibling window */
	HWND	childwp;	/* child window */

	if (wp == rootwp)
		return;

	++mwpaintNC;		/* experimental NC paint handling*/

	/* send hide message if currently visible*/
	if(bSendMsg && wp->unmapcount == 0)
		SendMessage(wp, WM_SHOWWINDOW, FALSE, 0L);

	wp->unmapcount++;

	for (childwp = wp->children; childwp; childwp = childwp->siblings)
		MwHideWindow(childwp, bChangeFocus, bSendMsg);

	if (wp == mousewp) {
		MwCheckMouseWindow();
		MwCheckCursor();
	}

	if (bChangeFocus && wp == focuswp)
		SetFocus(rootwp->children? rootwp->children: rootwp);

	/*
	 * If the parent window is still unmapped, then we are all done.
	 */
	if (wp->parent->unmapcount)
		return;

	/*
	 * Clear the area in the parent for this window, causing an
	 * exposure event for it.
	 */
	pwp = wp->parent;
	MwClearWindow(pwp, wp->winrect.left - pwp->winrect.left,
		wp->winrect.top - pwp->winrect.top,
		wp->winrect.right - wp->winrect.left,
		wp->winrect.bottom - wp->winrect.top, TRUE);

	/*
	 * Finally clear and redraw all parts of our lower sibling
	 * windows that were covered by this window.
	 */
	sibwp = wp;
	while (sibwp->siblings) {
		sibwp = sibwp->siblings;
		MwExposeArea(sibwp, wp->winrect.left, wp->winrect.top,
			wp->winrect.right - wp->winrect.left,
			wp->winrect.bottom - wp->winrect.top);
	}
}
Пример #2
0
/*
 * Move the cursor to the specified absolute screen coordinates.
 * The coordinates are that of the defined hot spot of the cursor.
 * The cursor's appearance is changed to that defined for the window
 * in which the cursor is moved to.  In addition, the window the
 * cursor is in is recalculated.
 */
void MwMoveCursor(MWCOORD x, MWCOORD y)
{
	/*
	 * Move the cursor only if necessary, offsetting it to
	 * place the hot spot at the specified coordinates.
	 */
	if (x != cursorx || y != cursory) {
		if(curcursor)
			GdMoveCursor(x - curcursor->cursor.hotx,
				y - curcursor->cursor.hoty);
		cursorx = x;
		cursory = y;
	}

	/*
	 * Now check to see which window the mouse is in and whether or
	 * not the cursor shape should be changed.
	 */
	MwCheckMouseWindow();
	MwCheckCursor();
}
Пример #3
0
/*
 * Map the window to possibly make it and its children visible on the screen.
 * This is a recursive routine which decrements the unmapcount values for
 * this window and all of its children, and causes exposure events for
 * those windows which become visible.
 */
void
MwShowWindow(HWND hwnd, BOOL bSendMsg)
{
	HWND	wp = hwnd;

	if (wp == rootwp)
		return;

	++mwpaintNC;		/* experimental NC paint handling*/

	if (wp->unmapcount)
		wp->unmapcount--;

	if (wp->unmapcount == 0) {
		SendMessage(wp, WM_SHOWWINDOW, TRUE, 0L);
		MwCheckMouseWindow();
		MwCheckCursor();
	}

	/*
	 * If the window just became visible,
	 * then draw its border, clear it to the background color, and
	 * generate an exposure event.
	 */
	if (wp->unmapcount == 0) {
		/*MwDrawBorder(wp);*/
		MwClearWindow(wp, 0, 0, wp->winrect.right - wp->winrect.left,
			wp->winrect.bottom - wp->winrect.top, TRUE);
	}

	/*
	 * Do the same thing for the children.
	 */
	for (wp = wp->children; wp; wp = wp->siblings)
		MwShowWindow(wp, bSendMsg);
}
Пример #4
0
/*
 * Destroy the specified window, and all of its children.
 * This is a recursive routine.
 */
void
MwDestroyWindow(HWND hwnd,BOOL bSendMsg)
{
	HWND	wp = hwnd;
	HWND	prevwp;
	PMWLIST	p;
	PMSG	pmsg;

	if (wp == rootwp || !IsWindow (hwnd))
		return;

	/*
	 * Unmap the window.
	 */
	if (wp->unmapcount == 0)
		MwHideWindow(wp, FALSE, FALSE);

	if(bSendMsg)
		SendMessage(hwnd, WM_DESTROY, 0, 0L);

	/*
	 * Remove from timers
	 */
	MwRemoveWndFromTimers(hwnd);

	/*
	 * Remove hotkeys
	 */
	MwRemoveWndFromHotkeys(hwnd);

	/*
	 * Disable all sendmessages to this window.
	 */
	wp->lpfnWndProc = NULL;

	/*
	 * Destroy all children, sending WM_DESTROY messages.
	 */
	while (wp->children)
		MwDestroyWindow(wp->children, bSendMsg);

	wp->pClass = NULL;

	/*
	 * Free any cursor associated with the window.
	 */
	if (wp->cursor->usecount-- == 1) {
		free(wp->cursor);
		wp->cursor = NULL;
	}

	/*
	 * Remove this window from the child list of its parent.
	 */
	prevwp = wp->parent->children;
	if (prevwp == wp)
		wp->parent->children = wp->siblings;
	else {
		while (prevwp && prevwp->siblings != wp)
			prevwp = prevwp->siblings;
		if (prevwp) prevwp->siblings = wp->siblings;
	}
	wp->siblings = NULL;

	/*
	 * Remove this window from the complete list of windows.
	 */
	prevwp = listwp;
	if (prevwp == wp)
		listwp = wp->next;
	else {
		while (prevwp->next && prevwp->next != wp)
			prevwp = prevwp->next;
		prevwp->next = wp->next;
	}
	wp->next = NULL;

	/*
	 * Forget various information related to this window.
	 * Then finally free the structure.
	 */

	/* Remove all messages from msg queue for this window*/
	for(p=mwMsgHead.head; p; ) {
		pmsg = GdItemAddr(p, MSG, link);
		if(pmsg->hwnd == wp) {
			p = p->next;
			GdListRemove(&mwMsgHead, &pmsg->link);
			GdItemFree(pmsg);
		} else
			p = p->next;
	}

	/*
	 * Remove all properties from this window.
	 */
	for(p=hwnd->props.head; p; ) {
		MWPROP  *pProp = GdItemAddr(p, MWPROP, link);
		p = p->next;
		GdListRemove (&hwnd->props, &pProp->link);
		GdItemFree (pProp);
	}

	/* FIXME: destroy hdc's relating to window?*/

	if (wp == capturewp) {
		capturewp = NULL;
		MwCheckMouseWindow();
	}

	if (wp == MwGetTopWindow(focuswp))
		SetFocus(rootwp->children? rootwp->children: rootwp);

	/* destroy private DC*/
	if(wp->owndc) {
		HDC hdc = wp->owndc;
		wp->owndc = NULL;	/* force destroy with ReleaseDC*/
		ReleaseDC(wp, hdc);
	}

	if (wp->szTitle) {
		free(wp->szTitle);
		wp->szTitle = NULL;
	}

#if UPDATEREGIONS
	if (wp->update) {
		GdDestroyRegion(wp->update);
		wp->update = NULL;
	}
#endif

	GdItemFree(wp);
}