📄 gtk+-2.4.14-xynth.diff
字号:
+ display->fb_width = display->modeinfo.xres;+ display->fb_height = display->modeinfo.yres;+ display->fb_stride = display->sinfo.line_length; #endif+ s_thread_create(&s_client_loop, window); - return display;+ display->xynth_root = window;+ + return display; } static void@@ -898,8 +169,6 @@ gdk_shadow_fb_init (); - gdk_fb_manager_connect (gdk_display);- if (!gdk_fb_keyboard_init (!gdk_display->manager_blocked)) { g_warning ("Failed to initialize keyboard");@@ -907,11 +176,10 @@ gdk_display = NULL; return; }- + if (!gdk_fb_mouse_init (!gdk_display->manager_blocked)) { g_warning ("Failed to initialize mouse");- gdk_fb_keyboard_close (); gdk_fb_display_destroy (gdk_display); gdk_display = NULL; return;@@ -1309,9 +577,6 @@ gdk_fb_mouse_close (); /*leak g_free (gdk_fb_mouse);*/ - gdk_fb_keyboard_close ();- /*leak g_free (gdk_fb_keyboard);*/- gdk_fb_display_destroy (gdk_display); gdk_display = NULL;diff -U 3 -H -d -r -N gtk+-2.4.14/gdk/linux-fb/gdkmouse-fb.c gtk+-2.4.14-xynth/gdk/linux-fb/gdkmouse-fb.c--- gtk+-2.4.14/gdk/linux-fb/gdkmouse-fb.c 2004-03-06 05:37:04.000000000 +0200+++ gtk+-2.4.14-xynth/gdk/linux-fb/gdkmouse-fb.c 2005-12-08 18:05:04.000000000 +0200@@ -16,6 +16,12 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */+ +/*+ * Gtk-Xynth port is based on linux-fb port+ * Xynth Team+ * http://www.xynth.org+ */ #include <config.h> #include <gdk/gdk.h>@@ -33,24 +39,11 @@ #include <errno.h> typedef struct _GdkFBMouse GdkFBMouse;-typedef struct _GdkFBMouseDevice GdkFBMouseDevice; struct _GdkFBMouse {- gint fd; /* Set by open */- gchar *file;-- /* These are written to by parse_packet */ gdouble x, y; gboolean button_pressed[3];-- guchar mouse_packet[5]; /* read by parse_packet */- gint packet_nbytes;- gboolean click_grab;- GIOChannel *io;- gint io_tag;-- GdkFBMouseDevice *dev; }; static GdkFBMouse *gdk_fb_mouse = NULL;@@ -244,621 +237,57 @@ _gdk_event_queue_append (gdk_display_get_default (), event); } -/******************************************************- ************ Device specific mouse code **************- ******************************************************/--/* proto is used to detect the start of the packet:- * (buf[0]&proto[0]) == proto[1]- * indicates start of packet.- */--struct _GdkFBMouseDevice {- gchar *name;- gchar *file;- gint packet_size;- gboolean (*open)(GdkFBMouse *mouse);- void (*close)(GdkFBMouse *mouse);- gboolean (*parse_packet)(GdkFBMouse *mouse, gboolean *got_motion);- guchar proto[2];-};--static gboolean handle_mouse_io (GIOChannel *gioc,- GIOCondition cond,- gpointer data);-static gboolean gdk_fb_mouse_ps2_open (GdkFBMouse *mouse);-static gboolean gdk_fb_mouse_imps2_open (GdkFBMouse *mouse);-static void gdk_fb_mouse_ps2_close (GdkFBMouse *mouse);-static gboolean gdk_fb_mouse_ps2_packet (GdkFBMouse *mouse,- gboolean *got_motion);-static gboolean gdk_fb_mouse_ms_open (GdkFBMouse *mouse);-static void gdk_fb_mouse_ms_close (GdkFBMouse *mouse);-static gboolean gdk_fb_mouse_ms_packet (GdkFBMouse *mouse,- gboolean *got_motion);-static gboolean gdk_fb_mouse_fidmour_open (GdkFBMouse *mouse);-static void gdk_fb_mouse_fidmour_close (GdkFBMouse *mouse);-static gboolean gdk_fb_mouse_fidmour_packet (GdkFBMouse *mouse,- gboolean *got_motion);--static GdkFBMouseDevice mouse_devs[] =-{- { "ps2",- "/dev/psaux",- 3,- gdk_fb_mouse_ps2_open,- gdk_fb_mouse_ps2_close,- gdk_fb_mouse_ps2_packet,- { 0xc0, 0x00 }- },- { "imps2",- "/dev/psaux",- 4,- gdk_fb_mouse_imps2_open,- gdk_fb_mouse_ps2_close,- gdk_fb_mouse_ps2_packet,- { 0xc0, 0x00 }- },- { "ms",- "/dev/mouse",- 3,- gdk_fb_mouse_ms_open,- gdk_fb_mouse_ms_close,- gdk_fb_mouse_ms_packet,- { 0x40, 0x40 }- },- { "fidmour",- "/dev/fidmour",- 5,- gdk_fb_mouse_fidmour_open,- gdk_fb_mouse_fidmour_close,- gdk_fb_mouse_fidmour_packet,- { 0x00, 0x00 } /* don't know what packet start looks like */- }-};--gboolean-gdk_fb_mouse_init (gboolean open_dev)-{- gchar *mouse_type, *mouse_file;- gint i;-- gdk_fb_mouse = g_new0 (GdkFBMouse, 1);- gdk_fb_mouse->fd = -1;-- mouse_type = getenv ("GDK_MOUSE_TYPE");- if (!mouse_type)- mouse_type = "ps2";- - for (i=0;i<G_N_ELEMENTS(mouse_devs);i++)- {- if (g_ascii_strcasecmp(mouse_type, mouse_devs[i].name)==0)- break;- }- - if (i == G_N_ELEMENTS(mouse_devs))- {- g_warning ("No mouse driver of type %s found", mouse_type);- return FALSE;- }-- gdk_fb_mouse->dev = &mouse_devs[i];-- mouse_file = getenv ("GDK_MOUSE_FILE");- if (!mouse_file)- mouse_file = gdk_fb_mouse->dev->file;- gdk_fb_mouse->file = mouse_file;-- gdk_fb_mouse->x = gdk_display->fb_width / 2;- gdk_fb_mouse->y = gdk_display->fb_height / 2;-- if (open_dev)- return gdk_fb_mouse_open ();- else- return TRUE;-}--gboolean-gdk_fb_mouse_open (void)-{- GdkFBMouseDevice *device;-- device = gdk_fb_mouse->dev;-- if (!device->open(gdk_fb_mouse))- {- g_warning ("Mouse driver open failed");- return FALSE;- }-- gdk_fb_mouse->io = - g_io_channel_unix_new (gdk_fb_mouse->fd);- gdk_fb_mouse->io_tag = - g_io_add_watch (gdk_fb_mouse->io,- G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, - handle_mouse_io, gdk_fb_mouse);-- return TRUE;-}--void -gdk_fb_mouse_close (void)-{- if (gdk_fb_mouse->io_tag)- {- g_source_remove (gdk_fb_mouse->io_tag);- gdk_fb_mouse->io_tag = 0;- }- - gdk_fb_mouse->dev->close(gdk_fb_mouse);-- if (gdk_fb_mouse->io)- {- g_io_channel_unref (gdk_fb_mouse->io);- gdk_fb_mouse->io = NULL;- }-}--static gboolean-handle_mouse_io (GIOChannel *gioc,- GIOCondition cond,- gpointer data)-{- GdkFBMouse *mouse = (GdkFBMouse *)data;- GdkFBMouseDevice *dev = mouse->dev;- guchar *proto = dev->proto;- gboolean got_motion;- gint n, i;-- got_motion = FALSE;- - while (1)- {- n = read (mouse->fd, mouse->mouse_packet + mouse->packet_nbytes, dev->packet_size - mouse->packet_nbytes);- if (n<=0) /* error or nothing to read */- break;-- /* we just read in what should be the first byte of a packet */- if (mouse->packet_nbytes == 0)- {- /* check to see if we have the first byte of a packet.- * if not, throw it away */- while ((mouse->mouse_packet[0] & proto[0]) != proto[1] && n > 0)- {- for (i = 1; i < n; i++)- mouse->mouse_packet[i-1] = mouse->mouse_packet[i];- n--;- }- /* if none of the bytes read were packet starts, break */- if (n <= 0)- break;- }- - mouse->packet_nbytes += n;- - if (mouse->packet_nbytes == dev->packet_size)- {- if (dev->parse_packet (mouse, &got_motion))- mouse->packet_nbytes = 0;- }- }- - if (got_motion)- handle_mouse_movement (mouse);- - return TRUE;-}--static gint-gdk_fb_mouse_dev_open (char *devname, gint mode)-{- gint fd;- - /* Use nonblocking mode to open, to not hang on device */- fd = open (devname, mode | O_NONBLOCK);- return fd;-}--static gboolean-write_all (gint fd,- gchar *buf,- gsize to_write)-{- while (to_write > 0)- {- gssize count = write (fd, buf, to_write);- if (count < 0)- {- if (errno != EINTR)- return FALSE;- }- else- {- to_write -= count;- buf += count;- }- }-- return TRUE;-}--static gboolean-gdk_fb_mouse_ps2_open (GdkFBMouse *mouse)-{- gint fd;- guchar buf[7];- int i = 0;-- fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);- if (fd < 0)- {- g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));- return FALSE;- }-- /* From xf86_Mouse.c */- buf[i++] = 230; /* 1:1 scaling */- buf[i++] = 244; /* enable mouse */- buf[i++] = 243; /* Sample rate */- buf[i++] = 200;- buf[i++] = 232; /* device resolution */- buf[i++] = 1;-- if (!write_all (fd, buf, i))- {- close (fd);- return FALSE;- }- - usleep (10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt- to get synchronized with the event stream */- - while ((i = read (fd, buf, sizeof(buf))) > 0)- g_print ("Got %d bytes of junk from psaux\n", i);- - mouse->fd = fd;- return TRUE;-}--static gboolean-gdk_fb_mouse_imps2_open (GdkFBMouse *mouse)-{- gint fd;- guchar buf[7];- int i = 0;-- fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);- if (fd < 0)- {- g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));- return FALSE;- }-- i = 0;- buf[i++] = 243; /* Sample rate */- buf[i++] = 200;- buf[i++] = 243; /* Sample rate */- buf[i++] = 100;- buf[i++] = 243; /* Sample rate */- buf[i++] = 80;- buf[i++] = 242;-- if (!write_all (fd, buf, i))- {- close (fd);- return FALSE;- }-- if (read (fd, buf, 1) != 1)- {- close (fd);- return FALSE;- }- - i = 0;- buf[i++] = 230; /* 1:1 scaling */- buf[i++] = 244; /* enable mouse */- buf[i++] = 243; /* Sample rate */- buf[i++] = 100;- buf[i++] = 232; /* device resolution */- buf[i++] = 3;-- if (!write_all (fd, buf, i))- {- close (fd);- return FALSE;- }- - mouse->fd = fd;- return TRUE;-}--static void-gdk_fb_mouse_ps2_close (GdkFBMouse *mouse)-{- close (mouse->fd);- mouse->fd = -1;-}--static gboolean-gdk_fb_mouse_ps2_packet (GdkFBMouse *mouse, gboolean *got_motion)-{- int dx=0, dy=0;- gboolean new_button1, new_button2, new_button3;- guchar *buf;-- buf = mouse->mouse_packet;- - new_button1 = (buf[0] & 1) && 1;- new_button3 = (buf[0] & 2) && 1;- new_button2 = (buf[0] & 4) && 1;- if (mouse->dev->packet_size == 4 && buf[3] != 0)- handle_mouse_scroll (mouse, buf[3] & 0x80);-- if (*got_motion &&- (new_button1 != mouse->button_pressed[0] ||- new_button2 != mouse->button_pressed[1] ||- new_button3 != mouse->button_pressed[2]))- {- /* If a mouse button state changes we need to get correct ordering with enter/leave events,- so push those out via handle_mouse_input */- *got_motion = FALSE;- handle_mouse_movement (mouse);- }-- if (new_button1 != mouse->button_pressed[0])- {- mouse->button_pressed[0] = new_button1; - send_button_event (mouse, 1, new_button1);- }- - if (new_button2 != mouse->button_pressed[1])- {- mouse->button_pressed[1] = new_button2;- send_button_event (mouse, 2, new_button2);- }- - if (new_button3 != mouse->button_pressed[2])- {- mouse->button_pressed[2] = new_button3; - send_button_event (mouse, 3, new_button3);- }- - if (buf[1] != 0)- dx = ((buf[0] & 0x10) ? ((gint)buf[1])-256 : buf[1]);- else- dx = 0;- if (buf[2] != 0)- dy = -((buf[0] & 0x20) ? ((gint)buf[2])-256 : buf[2]);- else- dy = 0;- - mouse->x += dx;- mouse->y += dy;- - if (dx || dy)- *got_motion = TRUE;-- return TRUE;-}---static gboolean-gdk_fb_mouse_ms_open (GdkFBMouse *mouse)-{- gint fd;- gint i;- guchar buf[7];- struct termios tty;-- fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);- if (fd < 0)- {- g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -