Beispiel #1
0
static void rfb_exittask(RFBDISPLAY *mod)
{
	TAPTR TExecBase = TGetExecBase(mod);
	struct TNode *imsg, *node, *next;

	/* free pooled input messages: */
	while ((imsg = TRemHead(&mod->rfb_IMsgPool)))
		TFree(imsg);

	/* close all fonts */
	node = mod->rfb_FontManager.openfonts.tlh_Head;
	for (; (next = node->tln_Succ); node = next)
		rfb_hostclosefont(mod, (TAPTR) node);

	if (mod->rfb_BufferOwner)
		TFree(mod->rfb_BufPtr);
	
	TDestroy(mod->rfb_RndIMsgPort);
	TFree(mod->rfb_RndRequest);
	TCloseModule(mod->rfb_RndDevice);
	TDestroy((struct THandle *) mod->rfb_RndRPort);
	TDestroy((struct THandle *) mod->rfb_InstanceLock);
	
	if (mod->rfb_DirtyRegion)
		region_destroy(&mod->rfb_RectPool, mod->rfb_DirtyRegion);
	
	region_destroypool(&mod->rfb_RectPool);
}
Beispiel #2
0
LOCAL void
dfb_closevisual(DFBDISPLAY *mod, struct TVRequest *req)
{
	struct DFBPen *pen;
	TAPTR exec = TGetExecBase(mod);
	DFBWINDOW *v = req->tvr_Op.CloseWindow.Window;
	if (v == TNULL) return;

	TDBPRINTF(TDB_INFO,("Visual close\n"));

	TRemove(&v->node);

	if (mod->dfb_Focused == (TAPTR) v)
	{
		/* pass focus on to the next window */
		DFBWINDOW *vt = (DFBWINDOW *)TFIRSTNODE(&mod->dfb_vlist);
		if (vt) genimsg(mod, TNULL, vt, TITYPE_FOCUS);
		mod->dfb_Focused = (TAPTR) vt;
	}

	if (mod->dfb_Active == (TAPTR) v)
		mod->dfb_Active = TNULL;

	while ((pen = (struct DFBPen *) TRemHead(&v->penlist)))
	{
		/* free pens */
		TRemove(&pen->node);
		TExecFree(mod->dfb_ExecBase, pen);
	}

	v->winsurface->Release(v->winsurface);
	v->window->Release(v->window);
	mod->dfb_fm.defref--;
	TExecFree(exec, v);
}
Beispiel #3
0
LOCAL TBOOL
fb_getimsg(WINDISPLAY *mod, WINWINDOW *win, TIMSG **msgptr, TUINT type)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	TIMSG *msg;
	TBOOL res = TFALSE;

	TLock(mod->fbd_Lock);
	msg = (TIMSG *) TRemHead(&mod->fbd_IMsgPool);
	if (msg == TNULL)
		msg = TAllocMsg0(sizeof(TIMSG));
	if (msg)
	{
		msg->timsg_Instance = win;
		msg->timsg_UserData = win->fbv_UserData;
		msg->timsg_Type = type;
		msg->timsg_Qualifier = win->fbv_KeyQual;
		msg->timsg_MouseX = win->fbv_MouseX;
		msg->timsg_MouseY = win->fbv_MouseY;
		TGetSystemTime(&msg->timsg_TimeStamp);
		*msgptr = msg;
		res = TTRUE;
	}
	else
		*msgptr = TNULL;
	TUnlock(mod->fbd_Lock);
	return res;
}
Beispiel #4
0
static void
fb_closeall(WINDISPLAY *mod, WINWINDOW *win, TBOOL unref_font)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	struct FBPen *pen;

	if (win->fbv_HDC)
		ReleaseDC(win->fbv_HWnd, win->fbv_HDC);

	if (mod->fbd_WindowFocussedApp == win->fbv_HWnd)
		mod->fbd_WindowFocussedApp = NULL;
	if (mod->fbd_WindowUnderCursor == win->fbv_HWnd)
		mod->fbd_WindowUnderCursor = NULL;
	if (mod->fbd_WindowActivePopup == win->fbv_HWnd)
		mod->fbd_WindowActivePopup = NULL;

	if (win->fbv_HWnd)
		DestroyWindow(win->fbv_HWnd);

	while ((pen = (struct FBPen *) TRemHead(&win->penlist)))
		TFree(pen);

	if (unref_font)
		mod->fbd_FontManager.defref--;
	if (win->fbv_InputMask & TITYPE_INTERVAL)
		--mod->fbd_NumInterval;

	TFree(win);
}
Beispiel #5
0
LOCAL TBOOL rfb_getimsg(RFBDISPLAY *mod, RFBWINDOW *v, TIMSG **msgptr, 
	TUINT type)
{
	TAPTR TExecBase = TGetExecBase(mod);
	TIMSG *msg;
	
	TLock(mod->rfb_InstanceLock);
	msg = (TIMSG *) TRemHead(&mod->rfb_IMsgPool);
	TUnlock(mod->rfb_InstanceLock);
	if (msg == TNULL)
		msg = TAllocMsg(sizeof(TIMSG));
	*msgptr = msg;
	if (msg)
	{
		memset(msg, 0, sizeof(TIMSG));
		msg->timsg_Instance = v;
		msg->timsg_UserData = v->userdata;
		msg->timsg_Type = type;
		msg->timsg_Qualifier = mod->rfb_KeyQual;
		msg->timsg_MouseX = mod->rfb_MouseX;
		msg->timsg_MouseY = mod->rfb_MouseY;
		TGetSystemTime(&msg->timsg_TimeStamp);
		return TTRUE;
	}
	return TFALSE;
}
Beispiel #6
0
static void rfb_exittask(struct rfb_Display *mod)
{
	TAPTR TExecBase = TGetExecBase(mod);
	struct TNode *imsg, *node, *next;

#if defined(ENABLE_LINUXFB)
	rfb_linux_exit(mod);
#endif

	TFree(mod->rfb_PtrBackBuffer.data);
	if (mod->rfb_Flags & RFBFL_PTR_ALLOCATED)
		TFree(mod->rfb_PtrImage.tpb_Data);

	/* free pooled input messages: */
	while ((imsg = TRemHead(&mod->rfb_IMsgPool)))
		TFree(imsg);

	/* close all fonts */
	node = mod->rfb_FontManager.openfonts.tlh_Head.tln_Succ;
	for (; (next = node->tln_Succ); node = next)
		rfb_hostclosefont(mod, (TAPTR) node);

	if (mod->rfb_Flags & RFBFL_BUFFER_OWNER)
		TFree(mod->rfb_PixBuf.tpb_Data);

	TDestroy(mod->rfb_RndIMsgPort);
	TFree(mod->rfb_RndRequest);
	TCloseModule(mod->rfb_RndDevice);
	TDestroy((struct THandle *) mod->rfb_RndRPort);
	TDestroy((struct THandle *) mod->rfb_InstanceLock);

	region_free(&mod->rfb_RectPool, &mod->rfb_DirtyRegion);

	region_destroypool(&mod->rfb_RectPool);
}
Beispiel #7
0
static TBOOL x11_getimsg(struct X11Display *mod, struct X11Window *v,
	TIMSG ** msgptr, TUINT type)
{
	TAPTR TExecBase = TGetExecBase(mod);
	TIMSG *msg = (TIMSG *) TRemHead(&mod->x11_imsgpool);

	if (msg == TNULL)
		msg = TAllocMsg0(sizeof(TIMSG));
	if (msg)
	{
		msg->timsg_Instance = v;
		msg->timsg_UserData = v->userdata;
		msg->timsg_Type = type;
		msg->timsg_Qualifier = mod->x11_KeyQual;
		msg->timsg_ScreenMouseX = mod->x11_ScreenMouseX;
		msg->timsg_ScreenMouseY = mod->x11_ScreenMouseY;
		msg->timsg_MouseX = v->mousex;
		msg->timsg_MouseY = v->mousey;
		TGetSystemTime(&msg->timsg_TimeStamp);
		*msgptr = msg;
		return TTRUE;
	}
	*msgptr = TNULL;
	return TFALSE;
}
Beispiel #8
0
static void
fb_exitinstance(WINDISPLAY *mod)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	struct TNode *imsg, *node, *next;

	/* free pooled input messages: */
	while ((imsg = TRemHead(&mod->fbd_IMsgPool)))
		TFree(imsg);

	/* free queued input messages in all open visuals: */
	node = mod->fbd_VisualList.tlh_Head;
	for (; (next = node->tln_Succ); node = next)
	{
		WINWINDOW *v = (WINWINDOW *) node;

		/* unset active font in all open visuals */
		v->fbv_CurrentFont = TNULL;

		while ((imsg = TRemHead(&v->fbv_IMsgQueue)))
			TFree(imsg);
	}

	/* force closing of default font */
	mod->fbd_FontManager.defref = 0;

	/* close all fonts */
	node = mod->fbd_FontManager.openfonts.tlh_Head;
	for (; (next = node->tln_Succ); node = next)
		fb_hostclosefont(mod, (TAPTR) node);

	if (mod->fbd_DeviceHWnd)
		DestroyWindow(mod->fbd_DeviceHWnd);

	if (mod->fbd_ClassAtom)
		UnregisterClass(FB_DISPLAY_CLASSNAME, mod->fbd_HInst);

	if (mod->fbd_ClassAtomPopup)
		UnregisterClass(FB_DISPLAY_CLASSNAME_POPUP, mod->fbd_HInst);
}
Beispiel #9
0
static void
vis_modclose(struct TVisualBase *inst)
{
	struct TVisualBase *mod =
		(struct TVisualBase *) inst->vis_Module.tmd_ModSuper;
	struct TExecBase *TExecBase = TGetExecBase(mod);
	if (inst != mod)
	{
		struct TNode *node;
		TAPTR imsg;

		if (inst->vis_Flags & TVISFL_IMSGPORT_OWNER)
		{
			TINT n = 0;
			while ((imsg = TGetMsg(inst->vis_IMsgPort)))
			{
				TAckMsg(imsg);
				n++;
			}
			if (n > 0)
				TDBPRINTF(TDB_WARN,("freed &d pending input message\n", n));
		}

		while ((node = TRemHead(&inst->vis_ReqPool)))
			TFree(node);

		while ((node = TRemHead(&inst->vis_WaitList)))
		{
			TWaitIO((struct TIORequest *) node);
			TFree(node);
		}

		vis_destroyports(inst);
		TFreeInstance(&inst->vis_Module);
	}
	TLock(mod->vis_Lock);
	if (--mod->vis_RefCount == 0)
		vis_exit(mod);
	TUnlock(mod->vis_Lock);
}
Beispiel #10
0
LOCAL void fb_sendimessages(WINDISPLAY *mod, TBOOL do_interval)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	struct TNode *next, *node = mod->fbd_VisualList.tlh_Head;
	for (; (next = node->tln_Succ); node = next)
	{
		WINWINDOW *v = (WINWINDOW *) node;
		TIMSG *imsg;

		if (do_interval && (v->fbv_InputMask & TITYPE_INTERVAL) &&
			fb_getimsg(mod, v, &imsg, TITYPE_INTERVAL))
			TPutMsg(v->fbv_IMsgPort, TNULL, imsg);

		while ((imsg = (TIMSG *) TRemHead(&v->fbv_IMsgQueue)))
			TPutMsg(v->fbv_IMsgPort, TNULL, imsg);
	}
}
Beispiel #11
0
LOCAL void x11_sendimessages(struct X11Display *mod)
{
	TAPTR TExecBase = TGetExecBase(mod);
	struct TNode *next, *node = mod->x11_vlist.tlh_Head.tln_Succ;

	for (; (next = node->tln_Succ); node = next)
	{
		struct X11Window *v = (struct X11Window *) node;
		TIMSG *imsg;

		while ((imsg = (TIMSG *) TRemHead(&v->imsgqueue)))
		{
			/* only certain input message types are sent two-way */
			struct TMsgPort *rport = imsg->timsg_Type == TITYPE_REQSELECTION ?
				mod->x11_IReplyPort : TNULL;
			TPutMsg(v->imsgport, rport, imsg);
		}
	}
}
Beispiel #12
0
static void
fb_closeall(WINDISPLAY *mod, WINWINDOW *win, TBOOL unref_font)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	struct FBPen *pen;

	if (win->fbv_HDC)
		ReleaseDC(win->fbv_HWnd, win->fbv_HDC);

	if (win->fbv_HWnd)
		DestroyWindow(win->fbv_HWnd);

	while ((pen = (struct FBPen *) TRemHead(&win->penlist)))
		TFree(pen);

	if (unref_font)
	{
		TLock(mod->fbd_Lock);
		mod->fbd_FontManager.defref--;
		TUnlock(mod->fbd_Lock);
	}

	TFree(win);
}
Beispiel #13
0
LOCAL TBOOL fbp_copyarea_int(struct rfb_Display *mod, struct rfb_Window *v,
	TINT dx, TINT dy, TINT *dr)
{
	struct RectPool *pool = &mod->rfb_RectPool;

	struct Region R;

	if (!rfb_getlayermask(mod, &R, dr, v, 0, 0))
		return TFALSE;

	if (R.rg_Rects.rl_NumNodes == 0)
	{
		region_free(pool, &R);
		return TFALSE;
	}

	TINT yinc = dy < 0 ? -1 : 1;
	TINT y, i, h;

	TINT dy0 = dr[1];
	TINT dy1 = dr[3];

	h = dy1 - dy0 + 1;
	if (yinc > 0)
	{
		TINT t = dy0;

		dy0 = dy1;
		dy1 = t;
	}

	TINT bpp = TVPIXFMT_BYTES_PER_PIXEL(v->rfbw_PixBuf.tpb_Format);

	if (R.rg_Rects.rl_NumNodes == 1)
	{
		/* optimization for a single rectangle */

		struct RectNode *rn =
			(struct RectNode *) TFIRSTNODE(&R.rg_Rects.rl_List);
		TINT x0 = rn->rn_Rect[0];
		TINT y0 = rn->rn_Rect[1];
		TINT x1 = rn->rn_Rect[2];
		TINT y1 = rn->rn_Rect[3];

		h = y1 - y0 + 1;
		dy0 = y0;
		dy1 = y1;
		if (yinc > 0)
		{
			TINT t = dy0;

			dy0 = dy1;
			dy1 = t;
		}

#if defined(ENABLE_VNCSERVER)
		if (mod->rfb_VNCTask && !(v->rfbw_Flags & RFBWFL_BACKBUFFER))
			rfb_vnc_copyrect(mod, v, dx, dy, x0, y0, x1, y1, yinc);
		else
#endif
		{
			/* update own buffer */
			for (i = 0, y = dy0; i < h; ++i, y -= yinc)
				CopyLineOver(v, x0 - dx, y - dy, x0, y, (x1 - x0 + 1) * bpp);
		}

		/* update sub device */
		TINT d[4];

		d[0] = rn->rn_Rect[0];
		d[1] = rn->rn_Rect[1];
		d[2] = rn->rn_Rect[2];
		d[3] = rn->rn_Rect[3];
		if (v->rfbw_Flags & RFBWFL_BACKBUFFER)
			rfb_markdirty(mod, v, d);
		else
			rfb_copyrect_sub(mod, d, dx, dy);
	}
	else
	{
		struct TNode *n;
		struct TList r, t;

		TInitList(&r);
		TInitList(&t);

		while ((n = TRemHead(&R.rg_Rects.rl_List)))
			TAddTail(&r, n);

		for (i = 0, y = dy0; i < h; ++i, y -= yinc)
		{
			struct TNode *rnext, *rnode = r.tlh_Head.tln_Succ;

			for (; (rnext = rnode->tln_Succ); rnode = rnext)
			{
				struct RectNode *rn = (struct RectNode *) rnode;

				if (y >= rn->rn_Rect[1] && y <= rn->rn_Rect[3])
				{
					struct TNode *prednode = TNULL;
					struct TNode *tnext, *tnode = t.tlh_Head.tln_Succ;

					for (; (tnext = tnode->tln_Succ); tnode = tnext)
					{
						struct RectNode *tn = (struct RectNode *) tnode;

						if (rn->rn_Rect[2] < tn->rn_Rect[0])
							break;
						prednode = tnode;
					}
					TRemove(rnode);
					TInsert(&t, rnode, prednode);	/* insert after prednode */
				}
			}

			while (!TISLISTEMPTY(&t))
			{
				TINT x0, x1;

				if (dx < 0)
				{
					struct RectNode *E = (struct RectNode *) TRemHead(&t);

					x0 = E->rn_Rect[0];
					x1 = E->rn_Rect[2];
					TAddTail(&r, &E->rn_Node);
					while (!TISLISTEMPTY(&t))
					{
						struct RectNode *N =
							(struct RectNode *) TFIRSTNODE(&t);
						if (N->rn_Rect[0] == x1 + 1)
						{
							x1 = N->rn_Rect[2];
							TAddTail(&r, TRemHead(&t));
							continue;
						}
						break;
					}
				}
				else
				{
					struct RectNode *E = (struct RectNode *) TRemTail(&t);

					x0 = E->rn_Rect[0];
					x1 = E->rn_Rect[2];
					TAddTail(&r, &E->rn_Node);
					while (!TISLISTEMPTY(&t))
					{
						struct RectNode *N = (struct RectNode *) TLASTNODE(&t);

						if (N->rn_Rect[2] == x0 - 1)
						{
							x0 = N->rn_Rect[0];
							TAddTail(&r, TRemTail(&t));
							continue;
						}
						break;
					}
				}
				CopyLineOver(v, x0 - dx, y - dy, x0, y, (x1 - x0 + 1) * bpp);
			}
		}

		while ((n = TRemHead(&r)))
		{
			struct RectNode *rn = (struct RectNode *) n;

			/* this would be incorrect, unfortunately: */
			/* rfb_copyrect_sub(mod, rn->rn_Rect, dx, dy); */
			rfb_markdirty(mod, v, rn->rn_Rect);
			TAddTail(&R.rg_Rects.rl_List, n);
		}
	}

	region_free(pool, &R);

	return TTRUE;	/* do expose */
}