⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmag-events.c

📁 在Linux下实现magnification功能
💻 C
📖 第 1 页 / 共 3 页
字号:
		pgmag_win = (GmagWinPtr) elem->data;		XFixesTranslateRegion (dpy_conn, region,				       pgmag_win->attr.x, pgmag_win->attr.y);		XFixesUnionRegion (dpy_conn,				   pgmag_win->damaged_region,				   pgmag_win->damaged_region, region);		pgmag_win->damaged = TRUE;	}}/* * Paint all the windows that have some damage. */static voidgmag_events_paint_damaged_windows (){	GList      *elem;	GmagWinPtr  pgmag_win;	elem = g_queue_peek_head_link (mag_windows_list);	while (elem) {		pgmag_win = (GmagWinPtr) elem->data;		if (pgmag_win->damaged) {			gmag_events_paint_window (pgmag_win,						  pgmag_win->damaged_region);			XFixesSetRegion (dpy_conn,					 pgmag_win->damaged_region, 0, 0);			pgmag_win->damaged = FALSE;		}		elem = g_list_next (elem);	}}static voidgmag_events_circulate_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received CirculateNotify event: 0x%x\n",		(guint) ev->xcirculate.window);#endif /* COMPOSITE_DEBUG */	if (ev->xcirculate.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xcirculate.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		g_queue_remove (mag_windows_list, pgmag_win);		if (ev->xcirculate.place == PlaceOnTop) {			g_queue_push_tail (mag_windows_list,					   pgmag_win);			if (pgmag_win->attr.map_state == IsViewable) {				XFixesSubtractRegion (					dpy_conn,					tmp_region, pgmag_win->win_region,					pgmag_win->clip);				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region, tmp_region);			}		} else {			g_queue_push_head (mag_windows_list,					   pgmag_win);			if (pgmag_win->attr.map_state == IsViewable)				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region,					pgmag_win->clip);		}	}}static voidgmag_events_configure_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;	#ifdef COMPOSITE_DEBUG	printf ("Received ConfigureNotify event: 0x%x\n",		(guint) ev->xconfigure.window);#endif /* COMPOSITE_DEBUG */	if (ev->xconfigure.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xconfigure.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		if ((pgmag_win->attr.x != ev->xconfigure.x) ||		    (pgmag_win->attr.y != ev->xconfigure.y) ||		    (pgmag_win->attr.width != ev->xconfigure.width) ||		    (pgmag_win->attr.height != ev->xconfigure.height) ||		    (pgmag_win->attr.border_width !=		     ev->xconfigure.border_width)) {			/* If an attribute of the window has changed we could			 * have an exposed area that is not reported due to the			 * overlay window. So we subtract the new region, from			 * the old one, and we have the value of the exposed			 * region that must be repainted.			 */			pgmag_win->attr.x = ev->xconfigure.x;			pgmag_win->attr.y = ev->xconfigure.y;			pgmag_win->attr.width = ev->xconfigure.width;			pgmag_win->attr.height = ev->xconfigure.height;			pgmag_win->attr.border_width =				ev->xconfigure.border_width;			      			if (pgmag_win->attr.map_state == IsViewable) {				XFixesCopyRegion (					dpy_conn,					old_region, pgmag_win->clip);				gmag_events_calculate_window_clip (pgmag_win);				XFixesCopyRegion (					dpy_conn,					new_region, pgmag_win->clip);				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region, old_region);				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region, new_region);			}		}		if (!ev->xconfigure.above) {			g_queue_remove (mag_windows_list, pgmag_win);			g_queue_push_head (mag_windows_list,					   pgmag_win);			if (pgmag_win->attr.map_state == IsViewable) {				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region,					pgmag_win->win_region);			}		} else {			elem = g_queue_find_custom (				mag_windows_list,				(gconstpointer) ev->xconfigure.above,				(GCompareFunc) gmag_events_g_compare_func);			if (elem) {				g_queue_remove (mag_windows_list,						pgmag_win);				g_queue_insert_after (mag_windows_list,						      elem, pgmag_win);				if (pgmag_win->attr.map_state == IsViewable) {					XFixesUnionRegion (						dpy_conn,						exp_region, exp_region,						pgmag_win->win_region);				}			}		}	}}static voidgmag_events_create_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received CreateNotify event: 0x%x\n",		(guint) ev->xcreatewindow.window);#endif /* COMPOSITE_DEBUG */	if (ev->xcreatewindow.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	gmag_events_add_window (ev->xcreatewindow.window);	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xcreatewindow.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		if (pgmag_win->attr.map_state == IsViewable) {			gmag_events_calculate_window_clip (pgmag_win);			XFixesUnionRegion (dpy_conn,					   exp_region, exp_region,					   pgmag_win->clip);		}	}}static voidgmag_events_destroy_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received DestroyNotify event: 0x%x\n",		(guint) ev->xdestroywindow.window);#endif /* COMPOSITE_DEBUG */	if (ev->xdestroywindow.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xdestroywindow.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		if (pgmag_win->attr.map_state == IsViewable)			XFixesUnionRegion (dpy_conn,					   exp_region, exp_region,					   pgmag_win->clip);		gmag_events_remove_window (ev->xdestroywindow.window);	}}static voidgmag_events_map_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received MapNotify event: 0x%x\n",		(guint) ev->xmap.window);#endif /* COMPOSITE_DEBUG */	if (ev->xmap.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xmap.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		pgmag_win->attr.map_state = IsViewable;		gmag_events_calculate_window_clip (pgmag_win);		XFixesUnionRegion (dpy_conn, exp_region,				   exp_region, pgmag_win->clip);	}}static voidgmag_events_unmap_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received UnmapNotify event: 0x%x\n",		(guint) ev->xunmap.window);#endif /* COMPOSITE_DEBUG */	if (ev->xunmap.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	elem = g_queue_find_custom (mag_windows_list,				    (gconstpointer) ev->xunmap.window,				    (GCompareFunc) gmag_events_g_compare_func);	if (elem) {		pgmag_win = (GmagWinPtr) elem->data;		pgmag_win->attr.map_state = IsUnmapped;		XFixesUnionRegion (dpy_conn, exp_region,				   exp_region, pgmag_win->clip);	}}static voidgmag_events_reparent_notify_handler (XEvent *ev){	GList      *elem;	GmagWinPtr  pgmag_win;#ifdef COMPOSITE_DEBUG	printf ("Received ReparentNotify event: 0x%x (Window), 0x%x (Parent)\n", (guint) ev->xreparent.window, (guint) ev->xreparent.parent);#endif /* COMPOSITE_DEBUG */	if  (ev->xreparent.window == mag_window) {#ifdef HAVE_OVERLAY#ifdef COMPOSITE_DEBUG		printf ("Overlay window = 0x%x\n",			(guint) gmag_events_overlay_window);#endif /* COMPOSITE_DEBUG */#endif /* HAVE_OVERLAY */		return;	}	if (ev->xreparent.parent != root_window) {		gmag_events_remove_window (ev->xreparent.window);	} else {		gmag_events_add_window (ev->xreparent.window);		elem = g_queue_find_custom (			mag_windows_list,			(gconstpointer) ev->xreparent.window,			(GCompareFunc) gmag_events_g_compare_func);		if (elem) {			pgmag_win = (GmagWinPtr) elem->data;			if (pgmag_win->attr.map_state == IsViewable) {			        gmag_events_calculate_window_clip (pgmag_win);				XFixesUnionRegion (					dpy_conn,					exp_region, exp_region,					pgmag_win->clip);			}		}	}}#endif /* HAVE_COMPOSITE */#ifdef HAVE_DAMAGEstatic voidgmag_events_damage_notify_handler (XEvent *ev){	XDamageNotifyEvent *dev = (XDamageNotifyEvent *) ev;#ifdef DAMAGE_DEBUG	g_message ("Damage area %3d, %3d x %3d, %3d",		   (int) dev->area.x, (int) dev->area.x + dev->area.width,		   (int) dev->area.y, (int) dev->area.y + dev->area.height);	g_message ("Damage geometry %3d, %3d x %3d, %3d",		   (int) dev->geometry.x,		   (int) dev->geometry.x + dev->geometry.width,		   (int) dev->geometry.y,		   (int) dev->geometry.y + dev->geometry.height);#endif /* DAMAGE_DEBUG */#ifdef HAVE_COMPOSITE	if (use_composite) {		if (dev->damage == off_screen_damage) {#ifdef DAMAGE_DEBUG			g_message ("off_screen_damage damaged");#endif /* DAMAGE_DEBUG */			XDamageSubtract (dpy_conn, dev->damage, None,					 gmag_events_tmp_region);			XFixesUnionRegion (dpy_conn,					   off_screen_region,					   off_screen_region,					   gmag_events_tmp_region);		} else {#ifdef DAMAGE_DEBUG			g_message ("Window with damage: 0x%x", dev->drawable);#endif /* DAMAGE_DEBUG */			XDamageSubtract (dpy_conn, dev->damage, None,					 gmag_events_tmp_region);			gmag_events_add_win_damaged_region (				dev->drawable, gmag_events_tmp_region);		}	}#endif /* HAVE_COMPOSITE */}#endif /* HAVE_DAMAGE */static voidgmag_events_cursor_convert_to_rgba (Magnifier *magnifier,				    XFixesCursorImage *cursor_image){	int i, count = cursor_image->width * cursor_image->height;	for (i = 0; i < count; ++i) {		guint32 pixval = GUINT_TO_LE (cursor_image->pixels[i]);		cursor_image->pixels[i] = pixval;	}}static voidgmag_events_free_cursor_pixels (guchar *pixels, gpointer data){    /* XFree (data); FIXME why doesn't this work properly? */}#endif /* HAVE_XFIXES */GdkPixbuf *gmag_events_get_source_pixbuf (Magnifier *magnifier)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -