+++ /dev/null
-<oaf_info>
- <oaf_server iid="OAFIID:Accessibility_Util_Magnifier:proto0.1"
- type="exe" location="magnifier -vz 2">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:Accessibility/Magnifier:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" value="Magnifier"/>
- <oaf_attribute name="description" type="string" value="Simple Screen Magnification Service"/>
- </oaf_server>
-</oaf_info>
+++ /dev/null
-NULL =
-
-idldir = $(datadir)
-
-idl_DATA = idl/Magnifier.idl
-
-dist_SUBDIRS = idl
-
-lib_LTLIBRARIES = libat-util.la
-
-bin_PROGRAMS = magnifier
-
-noinst_PROGRAMS = mag_control
-
-libat_util_la_SOURCES = \
- mag_client.c \
- mag_client.h \
- Magnifier-common.c \
- Magnifier-stubs.c
-
-libat_util_la_DEPENDENCIES = \
- Magnifier.h
-
-magnifier_SOURCES = magnifier.c \
- mag_image.c \
- mag_image.h \
- magnifier.h \
- Magnifier.h \
- Magnifier-skels.c \
- Magnifier-common.c
-
-mag_control_SOURCES = mag_control.c \
- mag_client.h \
- Magnifier-common.c \
- Magnifier-stubs.c
-
-INCLUDES = \
- $(UTILS_CFLAGS) \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_srcdir)/util/idl
-
-CFLAGS += $(UTILS_CFLAGS)
-
-IDL_OUT = Magnifier.h Magnifier-skels.c Magnifier-stubs.c Magnifier-common.c
-
-IDL = $(top_srcdir)/util/$(idl_DATA)
-
-BUILT_SOURCES = $(IDL_OUT)
-CLEANFILES+=$(IDL_OUT)
-
-mag_client.c mag_client.h mag_control.c magnifier.h : Magnifier.h
-
-IDLFLAGS = -I$(BONOBO_ACTIVATION_IDL_DIR) \
- -I$(LIBBONOBO_IDL_DIR) \
- -I$(top_srcdir)/util/idl
-
-orbittypelibdir = $(libdir)/orbit
-
-LDADD = $(UTILS_LIBS) $(X_LIBS)
-
-serverinfodir = $(libdir)/bonobo/servers
-serverinfo_DATA = Accessibility_Util.server
-
-@INTLTOOL_SERVER_RULE@
-
-EXTRA_DIST = Accessibility_Util.server.in $(serverinfo_DATA) $(idl_DATA)
-
-$(IDL_OUT) : $(IDL) $(ORBIT_IDL)
- $(ORBIT_IDL) $(IDLFLAGS) $(IDL)
-
-DONT_DIST_SOURCE = $(IDL_OUT)
-
-dist-hook:
- for file in $(DONT_DIST_SOURCE) ; do \
- rm -f $(distdir)/$$file ; \
- done
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _ACCESSIBILITY_MAGNIFIER_IDL
-#define _ACCESSIBILITY_MAGNIFIER_IDL
-
-#include <Bonobo.idl>
-
-module Accessibility {
-
- interface Magnifier : Bonobo::Unknown {
-
- /**
- * void setMagFactor: sets the current x and y magnification ratio.
- * @zoom_region: the index of the affected zoom region.
- * @magX: the magnification factor in the x direction for the specified region.
- * @magY: the magnification factor in the x direction for the specified region.
- **/
- oneway void setMagFactor (in short zoom_region, in float magX, in float magY);
-
- /**
- * #attribute SourceDisplay: a @string containing the X display name
- * containing the region to be magnified.
- **/
- attribute string SourceDisplay;
-
- /**
- * #attribute TargetDisplay: a @string containing the X display name
- * where the magnifier pixels are to be displayed.
- **/
- attribute string TargetDisplay;
-
- /**
- * oneway void setROI:
- * Sets the region of interest for the magnifier.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the ROI bounding box
- * @x2: the maximum X coordinate of the ROI bounding box
- * @y1: the minimum Y coordinate of the ROI bounding box
- * @y2: the maximum Y coordinate of the ROI bounding box
- **/
- oneway void setROI (in short zoom_region,
- in long x1, in long y1, in long x2, in long y2);
-
- /**
- * oneway void setROI:
- * Sets the region of interest for the zoom region.
- * If the zoom region was previously 'unmanaged', this associates
- * it with the ROI.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the ROI bounding box
- * @x2: the maximum X coordinate of the ROI bounding box
- * @y1: the minimum Y coordinate of the ROI bounding box
- * @y2: the maximum Y coordinate of the ROI bounding box
- **/
- oneway void markDirty (in short zoom_region,
- in long x1, in long y1, in long x2, in long y2);
-
- /**
- * oneway void markUnmanaged:
- * Mark a zoom region as 'unmanaged', meaning that it should not
- * attempt to get pixels from the source display but will have its
- * pixels drawn by a client.
- * @zoom_region: the index of the affected zoom region.
- **/
- oneway void markUnmanaged (in short zoom_region);
-
- /**
- * short createZoomRegion:
- * Creates a new zoom region for the magnifier.
- * The new region is initially unmanaged'.
- * @zx: the scale factor in the x direction for the new zoom region
- * @zy: the scale factor in the y direction for the new zoom region
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
- **/
- short createZoomRegion (in float zx, in float zy,
- in long x1, in long y1,
- in long x2, in long y2);
-
- /**
- * boolean getZoomRegionParams:
- * Queries a specific zoom region for its parameters.
- * returns: FALSE if the specified zoom region does not exist.
- * @zoom_region: the index specifying which zoom region to query.
- * @zx: the scale factor in the x direction for the new zoom region
- * @zy: the scale factor in the y direction for the new zoom region
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
- **/
- boolean getZoomRegionParams (in short zoom_region,
- out float zx, out float zy,
- out long x1, out long y1,
- out long x2, out long y2);
-
- /**
- * void resizeZoomRegion:
- * Resizes the specified zoom region on the target display.
- * @zoom_region: the index of the affected zoom region.
- * @x1: the minimum X coordinate of the zoomed area bounding box
- * @x2: the maximum X coordinate of the zoomed area bounding box
- * @y1: the minimum Y coordinate of the zoomed area bounding box
- * @y2: the maximum Y coordinate of the zoomed area bounding box
- **/
- oneway void resizeZoomRegion (in short zoom_region,
- in long x1, in long y1,
- in long x2, in long y2);
-
- /**
- * void destroyZoomRegion:
- * Remove the specified zoom region from the magnifier.
- **/
- oneway void destroyZoomRegion (in short zoom_region);
-
- /**
- * void clearAllZoomRegions:
- * Clears and destroys all currently defined zoom regions.
- **/
- void clearAllZoomRegions ();
-
- /**
- * void exit:
- * Unmap the current magnifier from the display.
- **/
- void exit ();
-
- };
-};
-
-#endif
-
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#include <stdlib.h>
-#include <libbonobo.h>
-#include "Magnifier.h"
-#include "mag_client.h"
-
-static CORBA_Environment ev;
-
-Accessibility_Magnifier
-get_magnifier()
-{
- static Accessibility_Magnifier magnifier = NULL;
- static gboolean is_error = FALSE;
- CORBA_Object oclient;
- char *obj_id;
-
- if (!magnifier && !is_error)
- {
- CORBA_exception_init (&ev);
- obj_id = "OAFIID:Accessibility_Util_Magnifier:proto0.1";
-
- oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- fprintf (stderr,
- ("Activation error: during magnifier activation: %s\n"),
- CORBA_exception_id(&ev));
- CORBA_exception_free(&ev);
- is_error = TRUE;
- }
-
- if (CORBA_Object_is_nil (oclient, &ev))
- {
- g_error ("Could not locate magnifier");
- is_error = TRUE;
- }
-
- magnifier = (Accessibility_Magnifier) oclient;
-
- }
-
- return magnifier;
-}
-
-void
-magnifier_set_roi(int zoom_region, int x, int y, int w, int h)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_setROI (magnifier,
- (const CORBA_short) zoom_region,
- (const CORBA_long) x,
- (const CORBA_long) y,
- (const CORBA_long) x+w,
- (const CORBA_long) y+h,
- &ev);
-}
-
-void
-magnifier_set_magnification (int zoom_region, float mag_factor_x, float mag_factor_y)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_setMagFactor (magnifier,
- (const CORBA_short) zoom_region,
- ((CORBA_float) mag_factor_x),
- ((CORBA_float) mag_factor_y),
- &ev);
-}
-
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef MAG_CLIENT_H_
-#define MAG_CLIENT_H_
-
-#include "util/Magnifier.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-Accessibility_Magnifier get_magnifier (void);
-void magnifier_set_roi (int zoom_region, int x1, int y1, int x2, int y2);
-void magnifier_set_magnification (int zoom_region, float mag_factor_x, float mag_factor_y);
-void magnifier_resize_region (int zoom_region, int x1, int y1, int x2, int y2);
-int magnifier_create_region (float zx, float zy, int x1, int y1, int x2, int y2);
-void magnifier_clear_all_regions (void);
-void magnifier_exit (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* MAG_CLIENT_H_ */
-
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <libbonobo.h>
-#include "Magnifier.h"
-#include "mag_client.h"
-
-static CORBA_Environment ev;
-
-int main(int argc, char ** argv){
-
- if (!bonobo_init (&argc, argv))
- {
- g_error ("Could not initialize Bonobo");
- }
-
- CORBA_exception_init (&ev);
-
- if(argc == 1){
- get_magnifier ();
- }
-
- else
- {
- switch (*argv[1])
- {
- case 'z':
- printf ("setting mag factor to %f\n", (float) atof (argv[1]+1));
- magnifier_set_magnification (0, (float) atof (argv[1]+1),
- (float) atof (argv[1]+1));
- break;
- case 's':
- printf ("resizing region 0 to 100x100 at (600, 0)\n");
- magnifier_resize_region (0, 600, 0, 700, 100);
- break;
- case 'd':
- printf ("destroying/clearing all regions.\n");
- magnifier_clear_all_regions ();
- break;
- case 'q':
- printf ("exiting magnifier.\n");
- magnifier_exit ();
- break;
- case 'c':
- printf ("creating 3x region at 100,100; 300x200\n");
- magnifier_create_region (3.0, 3.0, 100, 100, 400, 300);
- }
- }
- return 0;
-}
-
-Accessibility_Magnifier
-get_magnifier()
-{
- static Accessibility_Magnifier magnifier = NULL;
- static gboolean is_error = FALSE;
- CORBA_Object oclient;
- char *obj_id;
-
- if (!magnifier && !is_error)
- {
- CORBA_exception_init (&ev);
- obj_id = "OAFIID:Accessibility_Util_Magnifier:proto0.1";
-
- oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- fprintf (stderr,
- ("Activation error: during magnifier activation: %s\n"),
- CORBA_exception_id(&ev));
- CORBA_exception_free(&ev);
- is_error = TRUE;
- }
-
- if (CORBA_Object_is_nil (oclient, &ev))
- {
- g_error ("Could not locate magnifier");
- is_error = TRUE;
- }
-
- magnifier = (Accessibility_Magnifier) oclient;
-
- /* bonobo_activate (); ? */
- }
-
- return magnifier;
-}
-
-void
-magnifier_set_roi(int zoom_region, int x, int y, int w, int h)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_setROI (magnifier,
- (const CORBA_short) zoom_region,
- (const CORBA_long) x,
- (const CORBA_long) y,
- (const CORBA_long) x+w,
- (const CORBA_long) y+h,
- &ev);
-}
-
-void
-magnifier_resize_region (int zoom_region, int x1, int y1, int x2, int y2)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_resizeZoomRegion (magnifier,
- (const CORBA_short) zoom_region,
- (const CORBA_long) x1,
- (const CORBA_long) y1,
- (const CORBA_long) x2,
- (const CORBA_long) y2,
- &ev);
-}
-
-void
-magnifier_clear_all_regions ()
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_clearAllZoomRegions (magnifier,
- &ev);
-}
-
-int
-magnifier_create_region (float zx, float zy, int x1, int y1, int x2, int y2)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
- int retval = -1;
-
- if (magnifier)
- retval = Accessibility_Magnifier_createZoomRegion (magnifier,
- (const CORBA_float) zx,
- (const CORBA_float) zy,
- (const CORBA_long) x1,
- (const CORBA_long) y1,
- (const CORBA_long) x2,
- (const CORBA_long) y2,
- &ev);
- return retval;
-}
-
-void
-magnifier_set_magnification (int zoom_region, float mag_factor_x, float mag_factor_y)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
-
- if (magnifier)
- Accessibility_Magnifier_setMagFactor (magnifier,
- (const CORBA_short) zoom_region,
- (const CORBA_float) mag_factor_x,
- (const CORBA_float) mag_factor_y,
- &ev);
-}
-
-void
-magnifier_exit (void)
-{
- Accessibility_Magnifier magnifier = get_magnifier();
- if (magnifier)
- Accessibility_Magnifier_exit (magnifier, &ev);
-}
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "mag_image.h"
-
-
-static int get_num(char* msg);
-static void get_coord(char* msg,point *p);
-static void get_rect(char* msg, point *p1, point *p2);
-static void compute_center_coord(point p1, point p2, point *center);
-static xlib_colormap * xlib_get_colormap (Colormap id, Visual *visual, MagnifierData *data);
-static guint32 mask_table[] = {
- 0x00000000, 0x00000001, 0x00000003, 0x00000007,
- 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
- 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
- 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
- 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
- 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
- 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
- 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
- 0xffffffff
-};
-
-void parse_message(char *msg, MagnifierData *data){
-
- int type;
- point roi_pos, roi_size;
- point mag_pos, mag_size;
-
- printf("%s\n",msg);
- if(msg[0] != '~'){
- fprintf(stderr,"corrupted message, discarding\n");
- return;
- }
- type = atoi((char*)&msg[1]);
- switch (type){
- case FACTOR :
- old_factor_x = data->factor_x;
- data->factor_x = get_num(msg);
- old_factor_y = data->factor_y;
- data->factor_y = get_num(msg);
- printf("FACTOR = %d\n",data->factor_x);
- break;
- case CONTRAST :
- data->contrast = get_num(msg);
- printf("CONTRAST = %d\n",data->contrast);
- break;
- case FOLLOW_MOUSE :
- data->follow_mouse = get_num(msg);
- printf("FOLLOW_MOUSE = %d\n",data->follow_mouse);
- break;
- case COLOR_INVERTED :
- data->color_inverted = get_num(msg);
- printf("COLOR_INVERTED = %d\n",data->color_inverted);
- break;
- case GOTO :
- get_coord(msg, &data->center);
- printf("GOTO = (%d,%d)\n", data->center.x, data->center.y);
- break;
- case SET_ROI:
- get_rect (msg, &roi_pos, &roi_size);
- printf("ROI = (%d,%d; %d,%d)\n", roi_pos.x, roi_pos.y, roi_size.x, roi_size.y);
- compute_center_coord (roi_pos, roi_size, &data->center);
- break;
- case SET_EXTENTS:
- get_rect (msg, &mag_pos, &mag_size);
- printf("EXTENTS = (%d,%d; %d,%d)\n", mag_pos.x, mag_pos.y, mag_size.x, mag_size.y);
- data->mag_width = mag_size.x;
- data->mag_height = mag_size.y;
- gdk_window_move_resize (data->output_window->window, mag_pos.x,
- mag_pos.y,
- data->mag_width, data->mag_height);
- break;
- case STOP :
- printf("STOP\n");
- gtk_main_quit();
- break;
- default:
- break;
- }
-}
-
-
-static int get_num(char* msg){
- int type,num;
- sscanf(msg,"~%d:%d:",&type,&num);
- return num;
-}
-
-static void get_coord(char* msg,point *p){
- int type;
- sscanf(msg,"~%d:%d,%d:",&type,&p->x,&p->y);
-}
-
-static void get_rect(char* msg, point *p1, point *p2){
- int type;
- sscanf(msg,"~%d:%d,%d;%d,%d:",&type, &p1->x, &p1->y, &p2->x, &p2->y);
-}
-
-static void compute_center_coord (point pos, point size, point *center) {
- center->x = pos.x + (size.x/2);
- center->y = pos.y + (size.y/2);
-}
-
-int display_image(gpointer data)
-{
- MagnifierData *mag_data = (MagnifierData *)data;
- update_image(mag_data);
- gdk_pixbuf_scale(image,
- scaled_image,
- 0,
- 0,
- DisplayWidth (mag_data->target_display,screen_num),
- DisplayHeight(mag_data->target_display,screen_num),
- 0,
- 0,
- mag_data->factor_x,
- mag_data->factor_y,
- GDK_INTERP_NEAREST);
-
- gdk_pixbuf_render_to_drawable (scaled_image,
- drawing_area->window,
- drawing_area->style->fg_gc[GTK_STATE_NORMAL],
- 0,0,0,0,DisplayWidth (mag_data->target_display,screen_num),
- DisplayHeight(mag_data->target_display,screen_num),
- GDK_RGB_DITHER_NORMAL,0,0);
-
- gdk_window_raise (drawing_area->window);
- return TRUE;
-}
-
-void update_image(MagnifierData *mag_data)
-{
- int x, y, total_width, total_height;
-
- if(mag_data->follow_mouse){
- Window root_return, child_return;
- int win_x_return,win_y_return;
- unsigned int mask_return;
- XQueryPointer(mag_data->source_display,spi_image_root_window,
- &root_return,&child_return,
- &mag_data->center.x,&mag_data->center.y,
- &win_x_return,&win_y_return,&mask_return);
- }
-
- total_width = DisplayWidth (mag_data->source_display,screen_num);
- total_height = DisplayHeight(mag_data->source_display,screen_num);
-
- x = mag_data->center.x - mag_data->mag_width/mag_data->factor_x/2;
- y = mag_data->center.y - mag_data->mag_height/mag_data->factor_y/2;
-
- if(mag_data->center.x < mag_data->mag_width/mag_data->factor_x/2)
- x = 0;
- if(mag_data->center.x > (total_width - mag_data->mag_width/mag_data->factor_x/2))
- x = total_width - mag_data->mag_width/mag_data->factor_x;
- if(mag_data->center.y < mag_data->mag_height/mag_data->factor_y/2)
- y = 0;
- if(mag_data->center.y > (total_height - mag_data->mag_height/mag_data->factor_y/2))
- y = total_height - mag_data->mag_height/mag_data->factor_y;
- if(x < 0)
- x = 0;
- if(y < 0)
- y = 0;
-/*
- printf("p = (%d,%d), x,y = (%d,%d), h,w = (%d,%d), ht,wt = (%d,%d)\n",
- mag_data->center.x,
- mag_data->center.y,
- x,y,
- mag_data->mag_height,mag_data->mag_width,
- total_height,
- total_width);
-*/
- if(mag_data->factor_x != old_factor_x || mag_data->factor_y != old_factor_y){
- g_object_unref((GObject *)image);
- image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
- DisplayWidth (mag_data->target_display,screen_num)/mag_data->factor_x,
- DisplayHeight(mag_data->target_display,screen_num)/mag_data->factor_y);
- /* yes, use target display above, since the size of the area grabbed depends on the target */
- old_factor_x = mag_data->factor_x;
- old_factor_y = mag_data->factor_y;
- }
- get_root_image(spi_image_root_window,
- image,
- x,
- y,
- mag_data);
-}
-void expose_event(GtkWidget * w, GdkEventExpose *event, gpointer data){
-
-}
-
-
-
-
-/* SpiImage grabbing and convertion routines from gdk-pixbuf-xlib */
-/*
- convert 1 bits-pixel data
- no alpha
-*/
-static void
-rgb1 (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
- guint8 *s;
- register guint8 data;
- guint8 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- /* convert upto 8 pixels/time */
- /* its probably not worth trying to make this run very fast, who uses
- 1 bit displays anymore? */
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
-
- for (xx = 0; xx < width; xx ++) {
- data = srow[xx >> 3] >> (7 - (xx & 7)) & 1;
- *o++ = colormap->colors[data].red;
- *o++ = colormap->colors[data].green;
- *o++ = colormap->colors[data].blue;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 1 bits/pixel data
- with alpha
-*/
-static void
-rgb1a (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
- guint8 *s;
- register guint8 data;
- guint8 *o;
- guint8 *srow = image->data, *orow = pixels;
- guint32 remap[2];
-
- /* convert upto 8 pixels/time */
- /* its probably not worth trying to make this run very fast, who uses
- 1 bit displays anymore? */
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (xx = 0; xx < 2; xx++) {
-#ifdef LITTLE
- remap[xx] = 0xff000000
- | colormap->colors[xx].blue << 16
- | colormap->colors[xx].green << 8
- | colormap->colors[xx].red;
-#else
- remap[xx] = 0xff
- | colormap->colors[xx].red << 24
- | colormap->colors[xx].green << 16
- | colormap->colors[xx].blue << 8;
-#endif
- }
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
-
- for (xx = 0; xx < width; xx ++) {
- data = srow[xx >> 3] >> (7 - (xx & 7)) & 1;
- *o++ = remap[data];
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 8 bits/pixel data
- no alpha
-*/
-static void
-rgb8 (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
- guint32 mask;
- register guint32 data;
- guint8 *srow = image->data, *orow = pixels;
- register guint8 *s;
- register guint8 *o;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- mask = mask_table[image->depth];
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
- for (xx = 0; xx < width; xx++) {
- data = *s++ & mask;
- *o++ = colormap->colors[data].red;
- *o++ = colormap->colors[data].green;
- *o++ = colormap->colors[data].blue;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 8 bits/pixel data
- with alpha
-*/
-static void
-rgb8a (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
- guint32 mask;
- register guint32 data;
- guint32 remap[256];
- register guint8 *s; /* read 2 pixels at once */
- register guint32 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- mask = mask_table[image->depth];
-
- for (xx = 0; xx < colormap->size; xx++) {
-#ifdef LITTLE
- remap[xx] = 0xff000000
- | colormap->colors[xx].blue << 16
- | colormap->colors[xx].green << 8
- | colormap->colors[xx].red;
-#else
- remap[xx] = 0xff
- | colormap->colors[xx].red << 24
- | colormap->colors[xx].green << 16
- | colormap->colors[xx].blue << 8;
-#endif
- }
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = (guint32 *) orow;
- for (xx = 0; xx < width; xx ++) {
- data = *s++ & mask;
- *o++ = remap[data];
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 16 bits/pixel data
- no alpha
- data in lsb format
-*/
-static void
-rgb565lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint32 *s; /* read 2 pixels at once */
-#else
- register guint8 *s; /* read 2 pixels at once */
-#endif
- register guint16 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint32 *) srow;
-#else
- s = srow;
-#endif
- o = (guint16 *) orow;
- for (xx = 1; xx < width; xx += 2) {
- register guint32 data;
-#ifdef LITTLE
- data = *s++;
- *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
- | (data & 0x7e0) << 5 | (data & 0x600) >> 1;
- *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
- | (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21;
- *o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25
- | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
- /* swap endianness first */
- data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
- s += 4;
- *o++ = (data & 0xf800) | (data & 0xe000) >> 5
- | (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
- *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
- | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
- *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
- | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
- }
- /* check for last remaining pixel */
- if (width & 1) {
- register guint16 data;
-#ifdef LITTLE
- data = *((short *) s);
-#else
- data = *((short *) s);
- data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#endif
- ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7);
- ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3);
- ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7);
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 16 bits/pixel data
- no alpha
- data in msb format
-*/
-static void
-rgb565msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint8 *s; /* need to swap data order */
-#else
- register guint32 *s; /* read 2 pixels at once */
-#endif
- register guint16 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = srow;
-#else
- s = (guint32 *) srow;
-#endif
- o = (guint16 *) orow;
- for (xx = 1; xx < width; xx += 2) {
- register guint32 data;
-#ifdef LITTLE
- /* swap endianness first */
- data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
- s += 4;
- *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
- | (data & 0x7e0) << 5 | (data & 0x600) >> 1;
- *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
- | (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21;
- *o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25
- | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
- data = *s++;
- *o++ = (data & 0xf800) | (data & 0xe000) >> 5
- | (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
- *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
- | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
- *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
- | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
- }
- /* check for last remaining pixel */
- if (width & 1) {
- register guint16 data;
-#ifdef LITTLE
- data = *((short *) s);
- data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#else
- data = *((short *) s);
-#endif
- ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7);
- ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3);
- ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7);
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 16 bits/pixel data
- with alpha
- data in lsb format
-*/
-static void
-rgb565alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint16 *s; /* read 1 pixels at once */
-#else
- register guint8 *s;
-#endif
- register guint32 *o;
-
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint16 *) srow;
-#else
- s = (guint8 *) srow;
-#endif
- o = (guint32 *) orow;
- for (xx = 0; xx < width; xx ++) {
- register guint32 data;
- /* rrrrrggg gggbbbbb -> rrrrrRRR ggggggGG bbbbbBBB aaaaaaaa */
- /* little endian: aaaaaaaa bbbbbBBB ggggggGG rrrrrRRR */
-#ifdef LITTLE
- data = *s++;
- *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
- | (data & 0x7e0) << 5 | (data & 0x600) >> 1
- | (data & 0x1f) << 19 | (data & 0x1c) << 14
- | 0xff000000;
-#else
- /* swap endianness first */
- data = s[0] | s[1] << 8;
- s += 2;
- *o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11
- | (data & 0x7e0) << 13 | (data & 0x600) << 7
- | (data & 0x1f) << 11 | (data & 0x1c) << 6
- | 0xff;
-#endif
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 16 bits/pixel data
- with alpha
- data in msb format
-*/
-static void
-rgb565amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint8 *s;
-#else
- register guint16 *s; /* read 1 pixels at once */
-#endif
- register guint32 *o;
-
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = (guint32 *) orow;
- for (xx = 0; xx < width; xx ++) {
- register guint32 data;
- /* rrrrrggg gggbbbbb -> rrrrrRRR gggggg00 bbbbbBBB aaaaaaaa */
- /* little endian: aaaaaaaa bbbbbBBB gggggg00 rrrrrRRR */
-#ifdef LITTLE
- /* swap endianness first */
- data = s[0] | s[1] << 8;
- s += 2;
- *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
- | (data & 0x7e0) << 5 | (data & 0x600) >> 1
- | (data & 0x1f) << 19 | (data & 0x1c) << 14
- | 0xff000000;
-#else
- data = *s++;
- *o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11
- | (data & 0x7e0) << 13 | (data & 0x600) << 7
- | (data & 0x1f) << 11 | (data & 0x1c) << 6
- | 0xff;
-#endif
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 15 bits/pixel data
- no alpha
- data in lsb format
-*/
-static void
-rgb555lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint32 *s; /* read 2 pixels at once */
-#else
- register guint8 *s; /* read 2 pixels at once */
-#endif
- register guint16 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint32 *) srow;
-#else
- s = srow;
-#endif
- o = (guint16 *) orow;
- for (xx = 1; xx < width; xx += 2) {
- register guint32 data;
-#ifdef LITTLE
- data = *s++;
- *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
- | (data & 0x3e0) << 6 | (data & 0x380) << 1;
- *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
- | (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20;
- *o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23
- | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
- /* swap endianness first */
- data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
- s += 4;
- *o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4
- | (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
- *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
- | (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28;
- *o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15
- | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
- }
- /* check for last remaining pixel */
- if (width & 1) {
- register guint16 data;
-#ifdef LITTLE
- data = *((short *) s);
-#else
- data = *((short *) s);
- data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#endif
- ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12;
- ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
- ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 15 bits/pixel data
- no alpha
- data in msb format
-*/
-static void
-rgb555msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint8 *s; /* read 2 pixels at once */
-#else
- register guint32 *s; /* read 2 pixels at once */
-#endif
- register guint16 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = (guint16 *) orow;
- for (xx = 1; xx < width; xx += 2) {
- register guint32 data;
-#ifdef LITTLE
- /* swap endianness first */
- data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
- s += 4;
- *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
- | (data & 0x3e0) << 6 | (data & 0x380) << 1;
- *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
- | (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20;
- *o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23
- | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
- data = *s++;
- *o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4
- | (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
- *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
- | (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28;
- *o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15
- | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
- }
- /* check for last remaining pixel */
- if (width & 1) {
- register guint16 data;
-#ifdef LITTLE
- data = *((short *) s);
- data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#else
- data = *((short *) s);
-#endif
- ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12;
- ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
- ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 15 bits/pixel data
- with alpha
- data in lsb format
-*/
-static void
-rgb555alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint16 *s; /* read 1 pixels at once */
-#else
- register guint8 *s;
-#endif
- register guint32 *o;
-
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint16 *) srow;
-#else
- s = srow;
-#endif
- o = (guint32 *) orow;
- for (xx = 0; xx < width; xx++) {
- register guint32 data;
- /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */
- /* little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */
-#ifdef LITTLE
- data = *s++;
- *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
- | (data & 0x3e0) << 6 | (data & 0x380) << 1
- | (data & 0x1f) << 19 | (data & 0x1c) << 14
- | 0xff000000;
-#else
- /* swap endianness first */
- data = s[0] | s[1] << 8;
- s += 2;
- *o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12
- | (data & 0x3e0) << 14 | (data & 0x380) << 9
- | (data & 0x1f) << 11 | (data & 0x1c) << 6
- | 0xff;
-#endif
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-/*
- convert 15 bits/pixel data
- with alpha
- data in msb format
-*/
-static void
-rgb555amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
-#ifdef LITTLE
- register guint16 *s; /* read 1 pixels at once */
-#else
- register guint8 *s;
-#endif
- register guint32 *o;
-
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint16 *) srow;
-#else
- s = srow;
-#endif
- o = (guint32 *) orow;
- for (xx = 0; xx < width; xx++) {
- register guint32 data;
- /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */
- /* little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */
-#ifdef LITTLE
- /* swap endianness first */
- data = s[0] | s[1] << 8;
- s += 2;
- *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
- | (data & 0x3e0) << 6 | (data & 0x380) << 1
- | (data & 0x1f) << 19 | (data & 0x1c) << 14
- | 0xff000000;
-#else
- data = *s++;
- *o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12
- | (data & 0x3e0) << 14 | (data & 0x380) << 9
- | (data & 0x1f) << 11 | (data & 0x1c) << 6
- | 0xff;
-#endif
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-
-static void
-rgb888alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
- guint8 *s; /* for byte order swapping */
- guint8 *o;
- guint8 *srow = image->data, *orow = pixels;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- /* lsb data */
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
- for (xx = 0; xx < width; xx++) {
- *o++ = s[2];
- *o++ = s[1];
- *o++ = s[0];
- *o++ = 0xff;
- s += 4;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-static void
-rgb888lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
- guint8 *srow = image->data, *orow = pixels;
- guint8 *o, *s;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
- for (xx = 0; xx < width; xx++) {
- *o++ = s[2];
- *o++ = s[1];
- *o++ = s[0];
- s += 4;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-static void
-rgb888amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
- guint8 *srow = image->data, *orow = pixels;
-#ifdef LITTLE
- guint32 *o;
- guint32 *s;
-#else
- guint8 *s; /* for byte order swapping */
- guint8 *o;
-#endif
-
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- /* msb data */
- for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
- s = (guint32 *) srow;
- o = (guint32 *) orow;
-#else
- s = srow;
- o = orow;
-#endif
- for (xx = 0; xx < width; xx++) {
-#ifdef LITTLE
- *o++ = s[1];
- *o++ = s[2];
- *o++ = s[3];
- *o++ = 0xff;
- s += 4;
-#else
- *o++ = (*s << 8) | 0xff; /* untested */
- s++;
-#endif
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-static void
-rgb888msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
- int xx, yy;
- int width, height;
- int bpl;
-
- guint8 *srow = image->data, *orow = pixels;
- guint8 *s;
- guint8 *o;
-
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
- for (xx = 0; xx < width; xx++) {
- *o++ = s[1];
- *o++ = s[2];
- *o++ = s[3];
- s += 4;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-static void
-visual_decompose_mask (gulong mask,
- gint *shift,
- gint *prec)
-{
- *shift = 0;
- *prec = 0;
-
- while (!(mask & 0x1)) {
- (*shift)++;
- mask >>= 1;
- }
-
- while (mask & 0x1) {
- (*prec)++;
- mask >>= 1;
- }
-}
-
-
-/*
- This should work correctly with any display/any endianness, but will probably
- run quite slow
-*/
-static void
-convert_real_slow (XImage *image, guchar *pixels, int rowstride, xlib_colormap *cmap, int alpha)
-{
- int xx, yy;
- int width, height;
- int bpl;
- guint8 *srow = image->data, *orow = pixels;
- guint8 *s;
- guint8 *o;
- guint32 pixel;
- Visual *v;
- guint8 component;
- int i;
- int red_shift, red_prec, green_shift, green_prec, blue_shift, blue_prec;
-
- width = image->width;
- height = image->height;
- bpl = image->bytes_per_line;
- v = cmap->visual;
-
- visual_decompose_mask (v->red_mask, &red_shift, &red_prec);
- visual_decompose_mask (v->green_mask, &green_shift, &green_prec);
- visual_decompose_mask (v->blue_mask, &blue_shift, &blue_prec);
-
- for (yy = 0; yy < height; yy++) {
- s = srow;
- o = orow;
- for (xx = 0; xx < width; xx++) {
- pixel = XGetPixel (image, xx, yy);
- switch (v->class) {
- /* I assume this is right for static & greyscale's too? */
- case StaticGray:
- case GrayScale:
- case StaticColor:
- case PseudoColor:
- *o++ = cmap->colors[pixel].red;
- *o++ = cmap->colors[pixel].green;
- *o++ = cmap->colors[pixel].blue;
- break;
- case TrueColor:
- /* This is odd because it must sometimes shift left (otherwise
- I'd just shift >> (*_shift - 8 + *_prec + <0-7>). This logic
- should work for all bit sizes/shifts/etc. */
- component = 0;
- for (i = 24; i < 32; i += red_prec)
- component |= ((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> i;
- *o++ = component;
- component = 0;
- for (i = 24; i < 32; i += green_prec)
- component |= ((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> i;
- *o++ = component;
- component = 0;
- for (i = 24; i < 32; i += blue_prec)
- component |= ((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> i;
- *o++ = component;
- break;
- case DirectColor:
- *o++ = cmap->colors[((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> 24].red;
- *o++ = cmap->colors[((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> 24].green;
- *o++ = cmap->colors[((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> 24].blue;
- break;
- }
- if (alpha)
- *o++ = 0xff;
- }
- srow += bpl;
- orow += rowstride;
- }
-}
-
-static xlib_colormap *
-xlib_get_colormap (Colormap id, Visual *visual, MagnifierData *mag_data)
-{
- int i;
- xlib_colormap *xc = g_new (xlib_colormap, 1);
-
- xc->size = visual->map_entries;
- xc->colors = g_new (XColor, xc->size);
- xc->visual = visual;
- xc->colormap = id;
-
- for (i = 0; i < xc->size; i++) {
- xc->colors[i].pixel = i;
- xc->colors[i].flags = DoRed | DoGreen | DoBlue;
- }
-
- XQueryColors (mag_data->source_display, xc->colormap, xc->colors, xc->size);
-
- return xc;
-}
-
-typedef void (* cfunc) (XImage *image, guchar *pixels, int rowstride, xlib_colormap *cmap);
-static cfunc convert_map[] = {
- rgb1,rgb1,rgb1a,rgb1a,
- rgb8,rgb8,rgb8a,rgb8a,
- rgb555lsb,rgb555msb,rgb555alsb,rgb555amsb,
- rgb565lsb,rgb565msb,rgb565alsb,rgb565amsb,
- rgb888lsb,rgb888msb,rgb888alsb,rgb888amsb
-};
-
-static void
-rgbconvert (XImage *image, guchar *pixels, int rowstride, int alpha, xlib_colormap *cmap,
- MagnifierData *mag_data)
-{
- int index = (image->byte_order == MSBFirst) | (alpha != 0) << 1;
- int bank=5; /* default fallback converter */
- Visual *v = cmap->visual;
- if (mag_data->fast_rgb_convert)
- {
- switch (v->class) {
- /* I assume this is right for static & greyscale's too? */
- case StaticGray:
- case GrayScale:
- case StaticColor:
- case PseudoColor:
- switch (image->bits_per_pixel) {
- case 1:
- bank = 0;
- break;
- case 8:
- bank = 1;
- break;
- }
- break;
- case TrueColor:
- switch (image->depth) {
- case 15:
- if (v->red_mask == 0x7c00 && v->green_mask == 0x3e0 && v->blue_mask == 0x1f
- && image->bits_per_pixel == 16)
- bank = 2;
- break;
- case 16:
- if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f
- && image->bits_per_pixel == 16)
- bank = 3;
- break;
- case 24:
- case 32:
- if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff
- && image->bits_per_pixel == 32)
- bank = 4;
- break;
- }
- break;
- case DirectColor:
- /* always use the slow version */
- break;
- }
- }
-
- if (bank==5) {
- convert_real_slow(image, pixels, rowstride, cmap, alpha);
- } else {
- index |= bank << 2;
- (* convert_map[index]) (image, pixels, rowstride, cmap);
- }
-}
-
-void get_root_image(Window src, GdkPixbuf *dest, int src_x, int src_y, MagnifierData *mag_data) {
- XImage *image;
- int width = mag_data->mag_width/mag_data->factor_x;
- int height = mag_data->mag_height/mag_data->factor_y;
-
- /* Get SpiImage in ZPixmap format (packed bits). */
- image = XGetImage (mag_data->source_display, src, src_x, src_y,
- width, height, AllPlanes, ZPixmap);
- g_assert(image != NULL);
-
- if(x_cmap == NULL){
- XWindowAttributes wa;
- XGetWindowAttributes (mag_data->source_display, src, &wa);
- x_cmap = xlib_get_colormap (wa.colormap, wa.visual, mag_data);
- }
- /* we offset into the image data based on the position we are retrieving from */
- rgbconvert (image, gdk_pixbuf_get_pixels(dest),
- gdk_pixbuf_get_rowstride(dest),
- gdk_pixbuf_get_has_alpha(dest),
- x_cmap,
- mag_data);
-
- /* would like to use GDK routine, but since we don't have multi-head
- yet, we have to use X */
-
- XDestroyImage (image);
-}
-
-
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __MAGNIFIER_SPI_IMAGE_H__
-#define __MAGNIFIER_SPI_IMAGE_H__
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <errno.h>
-#include <unistd.h>
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <X11/Xlib.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
-#include <gdk/gdkx.h>
-
-typedef struct _point {
- int x;
- int y;
-} point;
-
-typedef struct xlib_colormap_struct xlib_colormap;
-
-struct xlib_colormap_struct {
- int size;
- XColor *colors;
- Visual *visual;
- Colormap colormap;
-};
-
-typedef struct {
- GdkRectangle extents;
- GdkRectangle roi;
- float zoom_x;
- float zoom_y;
- int contrast;
- gboolean is_managed;
- gboolean is_dirty;
-} ZoomRegionData;
-
-point center_position;
-point curpos; /* Position of the magnified cursor */
-GdkPixbuf* image;
-GdkPixbuf* scaled_image;
-Window spi_image_root_window;
-int screen_num;
-int old_factor_x;
-int old_factor_y;
-xlib_colormap * x_cmap;
-
-typedef struct _MagnifierData {
- int mag_width;
- int mag_height;
- int mag_x;
- int mag_y;
- int factor_x;
- int factor_y;
- point center;
- int follow_mouse;
- int color_inverted;
- int fast_rgb_convert;
- int contrast;
- GtkWidget *output_window;
- void *source_display;
- void *target_display;
- GList *zoom_regions;
-} MagnifierData;
-
-#define FACTOR 1
-#define CONTRAST 2
-#define FOLLOW_MOUSE 3
-#define COLOR_INVERTED 4
-#define GOTO 5
-#define STOP 6
-#define SET_ROI 7
-#define SET_EXTENTS 8
-
-struct sockaddr_un mag_server;
-struct sockaddr_un client_sockaddr;
-int size_client;
-int desc;
-GtkWidget *drawing_area;
-
-void parse_message(char *msg, MagnifierData *data);
-void update_image(MagnifierData *data);
-void expose_event(GtkWidget * w, GdkEventExpose *event, gpointer data);
-void get_root_image(Window src,GdkPixbuf *dest,int src_x, int src_y, MagnifierData *data);
-int display_image(gpointer data);
-
-#endif
-
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <popt.h>
-#include <gdk/gdkwindow.h>
-#include <libbonobo.h>
-#include "magnifier.h"
-#include "mag_image.h"
-
-#define ENV_STRING_MAX_SIZE 128
-
-/*
- * Our parent GObject type
- */
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-
-struct sockaddr_un mag_server = { AF_UNIX , "/tmp/magnifier_socket" };
-
-typedef struct {
- gchar *target_display;
- gchar *source_display;
- int vertical_split;
- int horizontal_split;
- int dual_head;
- int fullscreen;
- int mouse_follow;
- int invert_image;
- float zoom_factor;
- int min_refresh_time;
- int no_bonobo;
- int fast_cmap_convert;
- int no_initial_region;
-} MagnifierOptions;
-
-static MagnifierOptions global_options = { ":0.0",
- ":0.0",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 2.0,
- 200,
- 0,
- 0,
- 0
- };
-
-struct poptOption magnifier_options [] = {
- {"target_display", 't', POPT_ARG_STRING, &global_options.target_display, 't', "specify display on which to show magnified view", NULL},
- {"source_display", 's', POPT_ARG_STRING, &global_options.source_display, 's', "specify display to magnify", NULL},
- {"vertical", 'v', POPT_ARG_NONE, &global_options.vertical_split, 'v', "split screen vertically (if target display = source display)", NULL},
- {"horizontal", 'h', POPT_ARG_NONE, &global_options.horizontal_split, 'h', "split screen horizontally (if target display = source display)", NULL},
- {"dual-head", 'd', POPT_ARG_NONE, &global_options.dual_head, 'd', "dual-head display mode (maps magnifier to second display)", NULL},
- {"mouse follow", 'm', POPT_ARG_NONE, &global_options.mouse_follow, 'm', "track mouse movements", NULL},
- {"refresh time", 'r', POPT_ARG_NONE, &global_options.min_refresh_time, 'r', "minimum refresh time for mouse follow and idle, in ms", NULL},
- {"zoom (scale) factor", 'z', POPT_ARG_FLOAT, &global_options.zoom_factor, 'z', "zoom (scale) factor used to magnify source display", NULL},
-/* {"invert image", 'i', POPT_ARG_NONE, &global_options.invert_image, 'i', "invert the image colormap", NULL}, */
- {"fast-colormap-conversion", 'c', POPT_ARG_NONE, &global_options.fast_cmap_convert, 'c', "use faster colormap conversion algorithm (fails for 6 bit color)", NULL},
- {"no-bonobo", '\0', POPT_ARG_NONE, &global_options.no_bonobo, '\0', "don't use bonobo for controls, use sockets", NULL},
- {"no-initial-region", '\0', POPT_ARG_NONE, &global_options.no_initial_region, '\0', "don't create an initial zoom region", NULL},
- {NULL, 0, 0, NULL, 0, 0}
-};
-
-#define MSG_LEN 80
-
-static GtkWidget *window; /* TODO: clean up, with accessor func? */
-
-static void
-magnifier_realize (GtkWidget *widget)
-{
- XWMHints wm_hints;
- Atom wm_window_protocols[2];
- static gboolean initialized = FALSE;
-
- if (!initialized)
- {
- wm_window_protocols[0] = gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW");
- wm_window_protocols[1] = gdk_x11_get_xatom_by_name ("_NET_WM_PING");
- }
-
- wm_hints.flags = InputHint;
- wm_hints.input = False;
-
- XSetWMHints (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XWINDOW (widget->window), &wm_hints);
-
- XSetWMProtocols (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XWINDOW (widget->window), wm_window_protocols, 2);
-}
-
-static void
-magnifier_exit()
-{
- gtk_exit(0);
-}
-
-static gboolean get_commands(GIOChannel* client,
- GIOCondition condition,
- gpointer data){
- char msg[MSG_LEN];
- int desc_client = 0;
-
- memset(msg,0,MSG_LEN);
-
- if((desc_client = accept(desc,(struct sockaddr*)&client_sockaddr,&size_client)) == -1){
- perror("Could connect to client");exit(1);
- }
-
- read(desc_client,msg,sizeof(msg));
- parse_message(msg, data);
- return TRUE;
-
-}
-
-static void
-magnifier_pack_regions (Magnifier *magnifier)
-{
- /*
- * this call prevents resizing, which is a bother, but required to
- * work around dtwm incompatibilities. Perhaps a better workaround will
- * be found, or we can make this a runtime option.
- */
- gtk_widget_set_size_request (magnifier->mag_data->output_window,
- magnifier->mag_data->mag_width,
- magnifier->mag_data->mag_height);
-
- gdk_window_move(magnifier->mag_data->output_window->window,
- magnifier->mag_data->mag_x,
- magnifier->mag_data->mag_y);
-
-}
-
-int main (int argc, char** argv){
- GIOChannel *mag_channel;
- char *dpyname;
- char env_string[ENV_STRING_MAX_SIZE];
-
- /* TODO: finish replacing socket connection IPC with bonobo service. */
- Magnifier *magnifier;
- char * obj_id;
- GdkGeometry geometry;
-
- x_cmap = NULL;
-
- size_client = sizeof(client_sockaddr);
-
- image = NULL;
-
- if (!bonobo_init (&argc, argv))
- {
- g_error ("Could not initialize Bonobo");
- }
-
- magnifier = magnifier_new (argc, argv);
-
- magnifier->mag_data->follow_mouse =
- global_options.mouse_follow;
- magnifier->mag_data->color_inverted =
- global_options.invert_image;
- if (!global_options.no_initial_region)
- {
- magnifier->mag_data->zoom_regions =
- g_list_prepend (magnifier->mag_data->zoom_regions,
- g_new0 (ZoomRegionData, 1));
- magnifier->mag_data->factor_x = (int) global_options.zoom_factor;
- magnifier->mag_data->factor_y = (int) global_options.zoom_factor;
- }
- else {
- g_print ("starting magnifier with no initial zoom region\n");
- magnifier->mag_data->mag_width = 0;
- magnifier->mag_data->mag_height = 0;
- }
- /* TODO: enable fractional magnifications option? */
- if (global_options.target_display) {
- g_snprintf (env_string, (size_t) (ENV_STRING_MAX_SIZE-1), "DISPLAY=%s", global_options.target_display);
- putenv (env_string);
- }
- gtk_init (&argc, &argv);
-
- window = g_object_connect (gtk_widget_new (gtk_window_get_type (),
- "user_data", NULL,
- "can_focus", FALSE,
- "type", GTK_WINDOW_TOPLEVEL,
- "title", "magnifier",
- "allow_grow", FALSE,
- "allow_shrink", FALSE,
- "border_width", 10,
- NULL),
- "signal::realize", magnifier_realize, NULL,
- "signal::destroy", magnifier_exit, NULL,
- NULL);
-
- drawing_area = gtk_drawing_area_new();
- gtk_container_add (GTK_CONTAINER (window),drawing_area);
- gtk_widget_add_events(GTK_WIDGET(drawing_area),GDK_BUTTON_PRESS_MASK);
- gtk_signal_connect (GTK_OBJECT (drawing_area),"expose_event",
- GTK_SIGNAL_FUNC(expose_event),NULL);
-
- /* Init socket */
- if (global_options.no_bonobo) {
- if((desc = socket(AF_UNIX,SOCK_STREAM,0)) == -1){
- perror("Socket");exit(1);
- }
- unlink("/tmp/magnifier_socket");
-
- if(bind(desc,(struct sockaddr*)&mag_server,sizeof(mag_server)) == -1){
- perror("Bind");exit(1);
- }
-
- if(listen(desc,100) == -1){
- perror("Listen");exit(1);
- }
- mag_channel = g_io_channel_unix_new(desc);
- g_io_add_watch(mag_channel,
- G_IO_IN | G_IO_ERR,
- get_commands,
- magnifier->mag_data);
-
- }
-
- /* init image information */
- if (!global_options.source_display) global_options.source_display = gdk_get_display();
- dpyname = global_options.source_display + (strlen(global_options.source_display) - 1);
- screen_num = atoi(dpyname);
- if (!global_options.target_display) {
- if((screen_num == 0) && global_options.dual_head)
- screen_num++;
- else if (global_options.dual_head)
- screen_num--;
- global_options.target_display =
- (char *) malloc (strlen (global_options.source_display));
- strncpy (global_options.target_display,
- global_options.source_display,
- strlen(global_options.source_display)-2);
- global_options.target_display[strlen(global_options.source_display)-2] = 0;
- sprintf(global_options.target_display, "%s.%d",
- global_options.target_display, screen_num);
- }
-
- printf("displays: source=%s; target=%s\n",
- global_options.source_display,
- global_options.target_display);
-
- magnifier->mag_data->source_display = XOpenDisplay (global_options.source_display);
- magnifier->mag_data->target_display = GDK_DISPLAY();
-
- spi_image_root_window = RootWindow(magnifier->mag_data->source_display, screen_num);
- gdk_pixbuf_xlib_init (magnifier->mag_data->source_display, screen_num);
- image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
- DisplayWidth (magnifier->mag_data->source_display,screen_num)/2,
- DisplayHeight(magnifier->mag_data->source_display,screen_num)/2);
- scaled_image = gdk_pixbuf_new (GDK_COLORSPACE_RGB,FALSE, 8,
- DisplayWidth (magnifier->mag_data->target_display,screen_num),
- DisplayHeight(magnifier->mag_data->target_display,screen_num));
- if (global_options.vertical_split)
- {
- magnifier->mag_data->mag_width =
- DisplayWidth (magnifier->mag_data->target_display,screen_num)/2;
- magnifier->mag_data->mag_height =
- DisplayHeight (magnifier->mag_data->target_display, screen_num);
- }
- else if (global_options.horizontal_split)
- {
- magnifier->mag_data->mag_width =
- DisplayWidth (magnifier->mag_data->target_display, screen_num);
- magnifier->mag_data->mag_height =
- DisplayHeight (magnifier->mag_data->target_display,screen_num)/2;
- }
- else if (global_options.fullscreen)
- {
- magnifier->mag_data->mag_width =
- DisplayWidth (magnifier->mag_data->target_display, screen_num);
- magnifier->mag_data->mag_height =
- DisplayHeight (magnifier->mag_data->target_display,screen_num);
- }
- magnifier->mag_data->mag_x =
- DisplayWidth (magnifier->mag_data->target_display, screen_num)
- - magnifier->mag_data->mag_width;
- magnifier->mag_data->mag_y =
- DisplayHeight (magnifier->mag_data->target_display, screen_num)
- - magnifier->mag_data->mag_height;
-
- magnifier->mag_data->output_window = window;
- gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
- gtk_widget_show_all (window);
-
- magnifier_pack_regions (magnifier);
-
- /* if (global_options.fullscreen) */
- gdk_window_stick (window->window);
- gdk_window_set_functions(window->window, 0);
- gdk_window_raise(window->window);
-
- gtk_timeout_add(global_options.min_refresh_time, display_image, magnifier->mag_data);
-
- obj_id = "OAFIID:Accessibility_Util_Magnifier:proto0.1";
-
- if (! global_options.no_bonobo)
- {
- int ret = bonobo_activation_active_server_register (
- obj_id, BONOBO_OBJREF (magnifier));
-
- if (ret == Bonobo_ACTIVATION_REG_SUCCESS)
- {
- bonobo_main ();
- }
- }
- else
- {
- gtk_main ();
- }
-
- unlink("magnifier_socket");
- return 0;
-}
-
-static void
-impl_magnifier_fullscreen (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->mag_width = DisplayWidth (magnifier->mag_data->target_display, screen_num);
- magnifier->mag_data->mag_height = DisplayHeight (magnifier->mag_data->target_display, screen_num);
-}
-
-static void
-impl_magnifier_set_extents (PortableServer_Servant servant,
- CORBA_long x1,
- CORBA_long y1,
- CORBA_long x2,
- CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->mag_width = x2 - x1;
- magnifier->mag_data->mag_height = y2 - y1;
- gdk_window_move(window->window, x1, y1);
-}
-
-static void
-impl_magnifier_set_follow_mouse (PortableServer_Servant servant,
- const CORBA_boolean follow_mouse,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->follow_mouse = (int) follow_mouse;
-}
-
-static void
-impl_magnifier_set_contrast (PortableServer_Servant servant,
- const CORBA_short contrast,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->contrast = (int) contrast;
-}
-
-static void
-impl_magnifier_set_source_display (PortableServer_Servant servant,
- const CORBA_char *display,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->source_display =
- XOpenDisplay (global_options.source_display);
-}
-
-static void
-impl_magnifier_set_target_display (PortableServer_Servant servant,
- const CORBA_char *display,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->target_display = GDK_DISPLAY();
-}
-
-static void
-impl_magnifier_goto (PortableServer_Servant servant,
- const CORBA_long x,
- const CORBA_long y,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->center.x = (int) x;
- magnifier->mag_data->center.y = (int) y;
-}
-
-static void
-impl_magnifier_set_roi (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- magnifier->mag_data->center.x = (int) ((x1 + x2)/2);
- magnifier->mag_data->center.y = (int) ((y1 + y2)/2);
-}
-
-static void
-impl_magnifier_set_mag_factor (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_float mag_factor_x,
- const CORBA_float mag_factor_y,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == (CORBA_short) 0) /* TODO: fix for multi-zoom-regions */
- {
- magnifier->mag_data->factor_x = (float) mag_factor_x;
- magnifier->mag_data->factor_y = (float) mag_factor_y;
- }
-}
-
-static void
-impl_magnifier_mark_dirty (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- /* TODO: implement */
-}
-
-static void
-impl_magnifier_mark_unmanaged (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- /* TODO: implement */
-}
-
-static CORBA_short
-impl_magnifier_create_zoom_region (PortableServer_Servant servant,
- const CORBA_float zx,
- const CORBA_float zy,
- const CORBA_long x1,
- const CORBA_long y1,
- const CORBA_long x2,
- const CORBA_long y2,
- CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (magnifier->mag_data->zoom_regions == NULL)
- {
- magnifier->mag_data->zoom_regions =
- g_list_prepend (magnifier->mag_data->zoom_regions,
- g_new0 (ZoomRegionData, 1));
- magnifier->mag_data->factor_x = (int) zx;
- magnifier->mag_data->factor_y = (int) zy;
- magnifier->mag_data->mag_x = x1;
- magnifier->mag_data->mag_y = y1;
- magnifier->mag_data->mag_width = (x2 - x1);
- magnifier->mag_data->mag_height = (y2 - y1);
- magnifier_pack_regions (magnifier);
- return 0;
- }
- else
- {
- return -1;
- }
-}
-
-static CORBA_boolean
-impl_magnifier_get_zoom_region_params (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_float * zx,
- CORBA_float * zy, CORBA_long * x1,
- CORBA_long * y1, CORBA_long * x2,
- CORBA_long * y2,
- CORBA_Environment * ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == (CORBA_short) 0)
- {
- *zx = magnifier->mag_data->factor_x;
- *zy = magnifier->mag_data->factor_y;
- *x1 = 0;
- *y1 = 0;
- *x2 = *x1 + magnifier->mag_data->mag_width;
- *y2 = *y1 + magnifier->mag_data->mag_height;
- return CORBA_TRUE;
- }
- else return CORBA_FALSE;
-}
-
-static void
-impl_magnifier_resize_zoom_region (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- const CORBA_long x1, const CORBA_long y1,
- const CORBA_long x2, const CORBA_long y2,
- CORBA_Environment * ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == 0)
- {
- magnifier->mag_data->mag_x = x1;
- magnifier->mag_data->mag_y = y1;
- magnifier->mag_data->mag_width = (x2 - x1);
- magnifier->mag_data->mag_height = (y2 - y1);
- magnifier_pack_regions (magnifier);
- }
-}
-
-static void
-impl_magnifier_destroy_zoom_region (PortableServer_Servant servant,
- const CORBA_short zoom_region,
- CORBA_Environment * ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (zoom_region == 0)
- {
- g_list_free (magnifier->mag_data->zoom_regions);
- }
-}
-
-static void
-impl_magnifier_clear_all_zoom_regions (PortableServer_Servant servant,
- CORBA_Environment * ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- g_list_free (magnifier->mag_data->zoom_regions);
- magnifier->mag_data->zoom_regions = NULL;
-}
-
-static void
-impl_magnifier_exit (PortableServer_Servant servant, CORBA_Environment *ev)
-{
- Magnifier *magnifier = MAGNIFIER (bonobo_object_from_servant (servant));
- if (magnifier->mag_data->zoom_regions)
- g_list_free (magnifier->mag_data->zoom_regions);
- g_free (magnifier->mag_data);
- magnifier_exit();
-}
-
-static void
-magnifier_class_init (MagnifierClass *klass)
-{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Magnifier__epv *epv = &klass->epv;
-/*
- object_class->finalize = magnifier_finalize;
-*/
- epv->_set_SourceDisplay = impl_magnifier_set_source_display;
- epv->_set_TargetDisplay = impl_magnifier_set_target_display;
- epv->setROI = impl_magnifier_set_roi;
- epv->setMagFactor = impl_magnifier_set_mag_factor;
- epv->markDirty = impl_magnifier_mark_dirty;
- epv->markUnmanaged = impl_magnifier_mark_unmanaged;
- epv->createZoomRegion = impl_magnifier_create_zoom_region;
- epv->getZoomRegionParams = impl_magnifier_get_zoom_region_params;
- epv->resizeZoomRegion = impl_magnifier_resize_zoom_region;
- epv->destroyZoomRegion = impl_magnifier_destroy_zoom_region;
- epv->clearAllZoomRegions = impl_magnifier_clear_all_zoom_regions;
- epv->exit = impl_magnifier_exit;
-}
-
-static void
-magnifier_init (Magnifier *magnifier)
-{
- magnifier->mag_data = (MagnifierData *) g_new0 (MagnifierData, 1);
- magnifier->mag_data->factor_x = 2;
- magnifier->mag_data->factor_y = 2;
- magnifier->mag_data->contrast = 0;
- magnifier->mag_data->color_inverted = FALSE;
- magnifier->mag_data->fast_rgb_convert = FALSE;
- magnifier->mag_data->center.x = 0;
- magnifier->mag_data->center.y = 0;
- magnifier->mag_data->zoom_regions = NULL;
-}
-
-GType
-magnifier_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (MagnifierClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) magnifier_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Magnifier),
- 0, /* n preallocs */
- (GInstanceInitFunc) magnifier_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_Accessibility_Magnifier__init,
- NULL,
- G_STRUCT_OFFSET (MagnifierClass, epv),
- &tinfo,
- "Magnifier");
- }
-
- return type;
-}
-
-Magnifier *
-magnifier_new (int argc, char **argv)
-{
- poptContext ctx;
- Magnifier *magnifier =
- MAGNIFIER (g_object_new (magnifier_get_type(), NULL));
- ctx = poptGetContext ("magnifier",
- argc,
- (const char **)argv,
- magnifier_options,
- 0);
-
- while (poptGetNextOpt (ctx) >= 0)
- /**/;
-
- return magnifier;
-}
+++ /dev/null
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef MAGNIFIER_H_
-#define MAGNIFIER_H_
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <bonobo/bonobo-object.h>
-#include "Magnifier.h"
-#include "mag_image.h" /* TODO: remove this include */
-
-#define MAGNIFIER_TYPE (magnifier_get_type ())
-#define MAGNIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAGNIFIER_TYPE, Magnifier))
-#define MAGNIFIER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MAGNIFIER_TYPE, MagnifierClass))
-#define IS_MAGNIFIER(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), MAGNIFIER_TYPE))
-#define IS_MAGNIFIER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MAGNIFIER_TYPE))
-
-typedef struct {
- BonoboObject parent;
- MagnifierData *mag_data;
-} Magnifier;
-
-typedef struct {
- BonoboObjectClass parent_class;
- POA_Accessibility_Magnifier__epv epv;
-} MagnifierClass;
-
-GType magnifier_get_type (void);
-Magnifier *magnifier_new (int argc, char **argv);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* MAGNIFIER_H_ */