2000-12-08 12:38:48 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser 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.
|
|
|
|
*/
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2000-12-06 17:27:52 +00:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkinternals.h>
|
|
|
|
#include "gdkprivate-fb.h"
|
2002-09-10 15:19:13 +00:00
|
|
|
#include "gdkinputprivate.h"
|
2000-12-06 17:27:52 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2001-06-25 23:01:36 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
typedef struct _GdkFBMouse GdkFBMouse;
|
|
|
|
typedef struct _GdkFBMouseDevice GdkFBMouseDevice;
|
|
|
|
|
|
|
|
struct _GdkFBMouse {
|
|
|
|
gint fd; /* Set by open */
|
2003-09-16 17:59:20 +00:00
|
|
|
gchar *file;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
void
|
2000-12-08 12:38:48 +00:00
|
|
|
gdk_fb_mouse_get_info (gint *x,
|
|
|
|
gint *y,
|
|
|
|
GdkModifierType *mask)
|
2000-12-06 17:27:52 +00:00
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
*x = gdk_fb_mouse->x;
|
|
|
|
if (y)
|
|
|
|
*y = gdk_fb_mouse->y;
|
|
|
|
if (mask)
|
|
|
|
*mask =
|
|
|
|
(gdk_fb_mouse->button_pressed[0]?GDK_BUTTON1_MASK:0) |
|
|
|
|
(gdk_fb_mouse->button_pressed[1]?GDK_BUTTON2_MASK:0) |
|
|
|
|
(gdk_fb_mouse->button_pressed[2]?GDK_BUTTON3_MASK:0) |
|
2000-12-08 12:38:48 +00:00
|
|
|
gdk_fb_keyboard_modifiers ();
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_mouse_movement(GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
GdkWindow *mousewin;
|
|
|
|
GdkEvent *event;
|
|
|
|
gint x, y;
|
2001-01-17 15:52:22 +00:00
|
|
|
GdkWindow *old_win, *win, *event_win, *cursor_win;
|
2000-12-06 17:27:52 +00:00
|
|
|
guint state;
|
|
|
|
GdkDrawableFBData *mousewin_private;
|
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
old_win = gdk_window_at_pointer (NULL, NULL);
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
if (_gdk_fb_pointer_grab_confine)
|
|
|
|
mousewin = _gdk_fb_pointer_grab_confine;
|
|
|
|
else
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
mousewin = _gdk_parent_root;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
mousewin_private = GDK_DRAWABLE_IMPL_FBDATA (mousewin);
|
|
|
|
|
|
|
|
if (mouse->x < mousewin_private->llim_x)
|
|
|
|
mouse->x = mousewin_private->llim_x;
|
|
|
|
else if (mouse->x > mousewin_private->lim_x - 1)
|
|
|
|
mouse->x = mousewin_private->lim_x - 1;
|
|
|
|
|
|
|
|
if (mouse->y < mousewin_private->llim_y)
|
|
|
|
mouse->y = mousewin_private->llim_y;
|
|
|
|
else if (mouse->y > mousewin_private->lim_y - 1)
|
|
|
|
mouse->y = mousewin_private->lim_y - 1;
|
|
|
|
|
|
|
|
win = gdk_window_at_pointer (NULL, NULL);
|
2001-01-17 15:52:22 +00:00
|
|
|
|
|
|
|
cursor_win = win;
|
|
|
|
if (_gdk_fb_pointer_grab_window)
|
|
|
|
{
|
|
|
|
GdkWindow *w;
|
|
|
|
|
|
|
|
cursor_win = _gdk_fb_pointer_grab_window;
|
|
|
|
w = win;
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
while (w != _gdk_parent_root)
|
2001-01-17 15:52:22 +00:00
|
|
|
{
|
|
|
|
if (w == _gdk_fb_pointer_grab_window)
|
|
|
|
{
|
|
|
|
cursor_win = win;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
w = gdk_window_get_parent (w);
|
|
|
|
}
|
|
|
|
}
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
gdk_fb_cursor_move (mouse->x, mouse->y, cursor_win);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
event_win = gdk_fb_pointer_event_window (win, GDK_MOTION_NOTIFY);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
if (event_win && (win == old_win))
|
2000-12-06 17:27:52 +00:00
|
|
|
{
|
2001-01-17 15:52:22 +00:00
|
|
|
/* Only send motion events in the same window */
|
|
|
|
gdk_window_get_origin (event_win, &x, &y);
|
|
|
|
x = mouse->x - x;
|
|
|
|
y = mouse->y - y;
|
|
|
|
|
|
|
|
state = (mouse->button_pressed[0]?GDK_BUTTON1_MASK:0) |
|
|
|
|
(mouse->button_pressed[1]?GDK_BUTTON2_MASK:0) |
|
|
|
|
(mouse->button_pressed[2]?GDK_BUTTON3_MASK:0) |
|
|
|
|
gdk_fb_keyboard_modifiers ();
|
|
|
|
|
|
|
|
event = gdk_event_make (event_win, GDK_MOTION_NOTIFY, TRUE);
|
2000-12-06 17:27:52 +00:00
|
|
|
event->motion.x = x;
|
|
|
|
event->motion.y = y;
|
|
|
|
event->motion.state = state;
|
|
|
|
event->motion.is_hint = FALSE;
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
event->motion.device = _gdk_core_pointer;
|
2000-12-06 17:27:52 +00:00
|
|
|
event->motion.x_root = mouse->x;
|
|
|
|
event->motion.y_root = mouse->y;
|
|
|
|
}
|
2001-01-17 15:52:22 +00:00
|
|
|
|
|
|
|
gdk_fb_window_send_crossing_events (NULL, win, GDK_CROSSING_NORMAL);
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_button_event (GdkFBMouse *mouse,
|
|
|
|
guint button,
|
|
|
|
gboolean press_event)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
gint x, y, i;
|
2001-01-17 15:52:22 +00:00
|
|
|
GdkWindow *mouse_win;
|
|
|
|
GdkWindow *event_win;
|
2000-12-06 17:27:52 +00:00
|
|
|
int nbuttons;
|
|
|
|
|
2001-01-17 15:52:22 +00:00
|
|
|
|
|
|
|
mouse_win = gdk_window_at_pointer(NULL, NULL);
|
|
|
|
event_win = gdk_fb_pointer_event_window (mouse_win,
|
|
|
|
press_event ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
|
|
|
|
|
|
|
|
if (event_win)
|
2000-12-06 17:27:52 +00:00
|
|
|
{
|
2001-01-17 15:52:22 +00:00
|
|
|
event = gdk_event_make (event_win, press_event ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE, FALSE);
|
|
|
|
|
|
|
|
gdk_window_get_origin (event_win, &x, &y);
|
2000-12-06 17:27:52 +00:00
|
|
|
x = mouse->x - x;
|
|
|
|
y = mouse->y - y;
|
|
|
|
|
|
|
|
event->button.x = x;
|
|
|
|
event->button.y = y;
|
|
|
|
event->button.button = button;
|
|
|
|
event->button.state = (mouse->button_pressed[0]?GDK_BUTTON1_MASK:0) |
|
|
|
|
(mouse->button_pressed[1] ? GDK_BUTTON2_MASK : 0) |
|
|
|
|
(mouse->button_pressed[2] ? GDK_BUTTON3_MASK : 0) |
|
|
|
|
(1 << (button + 8)) /* badhack */ |
|
2000-12-08 12:38:48 +00:00
|
|
|
gdk_fb_keyboard_modifiers ();
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
event->button.device = _gdk_core_pointer;
|
2000-12-06 17:27:52 +00:00
|
|
|
event->button.x_root = mouse->x;
|
|
|
|
event->button.y_root = mouse->y;
|
|
|
|
|
2002-09-10 15:19:13 +00:00
|
|
|
_gdk_event_queue_append (gdk_display_get_default (), event);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
/* For double-clicks */
|
|
|
|
if (press_event)
|
2002-09-10 15:19:13 +00:00
|
|
|
_gdk_event_button_generate (gdk_display_get_default (), event);
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nbuttons = 0;
|
|
|
|
for (i=0;i<3;i++)
|
|
|
|
if (mouse->button_pressed[i])
|
|
|
|
nbuttons++;
|
|
|
|
|
|
|
|
/* Handle implicit button grabs: */
|
|
|
|
if (press_event && nbuttons == 1)
|
|
|
|
{
|
2001-01-17 15:52:22 +00:00
|
|
|
gdk_fb_pointer_grab (mouse_win, FALSE,
|
|
|
|
gdk_window_get_events (mouse_win),
|
2000-12-06 17:27:52 +00:00
|
|
|
NULL, NULL,
|
|
|
|
GDK_CURRENT_TIME, TRUE);
|
|
|
|
mouse->click_grab = TRUE;
|
|
|
|
}
|
|
|
|
else if (!press_event && nbuttons == 0 && mouse->click_grab)
|
|
|
|
{
|
|
|
|
gdk_fb_pointer_ungrab (GDK_CURRENT_TIME, TRUE);
|
|
|
|
mouse->click_grab = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-25 12:58:36 +00:00
|
|
|
static void
|
|
|
|
handle_mouse_scroll (GdkFBMouse *mouse,
|
|
|
|
gboolean up)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
gint x, y;
|
|
|
|
GdkWindow *mouse_win;
|
|
|
|
|
|
|
|
mouse_win = gdk_window_at_pointer(NULL, NULL);
|
|
|
|
|
|
|
|
event = gdk_event_make (mouse_win, GDK_SCROLL, FALSE);
|
|
|
|
|
|
|
|
gdk_window_get_origin (mouse_win, &x, &y);
|
|
|
|
x = mouse->x - x;
|
|
|
|
y = mouse->y - y;
|
|
|
|
|
|
|
|
event->button.window = mouse_win;
|
|
|
|
event->scroll.direction = up ? GDK_SCROLL_UP : GDK_SCROLL_DOWN;
|
|
|
|
event->scroll.window = mouse_win;
|
|
|
|
event->scroll.time = GDK_CURRENT_TIME;
|
|
|
|
event->scroll.x = x;
|
|
|
|
event->scroll.y = y;
|
|
|
|
event->scroll.x_root = mouse->x;
|
|
|
|
event->scroll.y_root = mouse->y;
|
|
|
|
event->scroll.state = gdk_fb_keyboard_modifiers ();
|
|
|
|
event->scroll.device = _gdk_core_pointer;
|
|
|
|
|
|
|
|
_gdk_event_queue_append (gdk_display_get_default (), event);
|
|
|
|
}
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
/******************************************************
|
|
|
|
************ Device specific mouse code **************
|
|
|
|
******************************************************/
|
|
|
|
|
2000-12-09 11:10:41 +00:00
|
|
|
/* proto is used to detect the start of the packet:
|
|
|
|
* (buf[0]&proto[0]) == proto[1]
|
|
|
|
* indicates start of packet.
|
|
|
|
*/
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
struct _GdkFBMouseDevice {
|
2003-09-16 17:59:20 +00:00
|
|
|
gchar *name;
|
|
|
|
gchar *file;
|
2000-12-06 17:27:52 +00:00
|
|
|
gint packet_size;
|
|
|
|
gboolean (*open)(GdkFBMouse *mouse);
|
|
|
|
void (*close)(GdkFBMouse *mouse);
|
|
|
|
gboolean (*parse_packet)(GdkFBMouse *mouse, gboolean *got_motion);
|
2000-12-09 11:10:41 +00:00
|
|
|
guchar proto[2];
|
2000-12-06 17:27:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean handle_mouse_io (GIOChannel *gioc,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data);
|
|
|
|
static gboolean gdk_fb_mouse_ps2_open (GdkFBMouse *mouse);
|
2002-09-25 12:58:36 +00:00
|
|
|
static gboolean gdk_fb_mouse_imps2_open (GdkFBMouse *mouse);
|
2000-12-06 17:27:52 +00:00
|
|
|
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",
|
2003-09-16 17:59:20 +00:00
|
|
|
"/dev/psaux",
|
2000-12-06 17:27:52 +00:00
|
|
|
3,
|
|
|
|
gdk_fb_mouse_ps2_open,
|
|
|
|
gdk_fb_mouse_ps2_close,
|
2000-12-09 11:10:41 +00:00
|
|
|
gdk_fb_mouse_ps2_packet,
|
|
|
|
{ 0xc0, 0x00 }
|
2000-12-06 17:27:52 +00:00
|
|
|
},
|
2000-12-13 10:03:16 +00:00
|
|
|
{ "imps2",
|
2003-09-16 17:59:20 +00:00
|
|
|
"/dev/psaux",
|
2000-12-13 10:03:16 +00:00
|
|
|
4,
|
2002-09-25 12:58:36 +00:00
|
|
|
gdk_fb_mouse_imps2_open,
|
2000-12-13 10:03:16 +00:00
|
|
|
gdk_fb_mouse_ps2_close,
|
|
|
|
gdk_fb_mouse_ps2_packet,
|
|
|
|
{ 0xc0, 0x00 }
|
|
|
|
},
|
2000-12-06 17:27:52 +00:00
|
|
|
{ "ms",
|
2003-09-16 17:59:20 +00:00
|
|
|
"/dev/mouse",
|
2000-12-06 17:27:52 +00:00
|
|
|
3,
|
|
|
|
gdk_fb_mouse_ms_open,
|
|
|
|
gdk_fb_mouse_ms_close,
|
2000-12-09 11:10:41 +00:00
|
|
|
gdk_fb_mouse_ms_packet,
|
|
|
|
{ 0x40, 0x40 }
|
2000-12-06 17:27:52 +00:00
|
|
|
},
|
|
|
|
{ "fidmour",
|
2003-09-16 17:59:20 +00:00
|
|
|
"/dev/fidmour",
|
2000-12-06 17:27:52 +00:00
|
|
|
5,
|
|
|
|
gdk_fb_mouse_fidmour_open,
|
|
|
|
gdk_fb_mouse_fidmour_close,
|
2000-12-09 11:10:41 +00:00
|
|
|
gdk_fb_mouse_fidmour_packet,
|
|
|
|
{ 0x00, 0x00 } /* don't know what packet start looks like */
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
gboolean
|
2001-06-25 23:01:36 +00:00
|
|
|
gdk_fb_mouse_init (gboolean open_dev)
|
2000-12-06 17:27:52 +00:00
|
|
|
{
|
2003-09-16 17:59:20 +00:00
|
|
|
gchar *mouse_type, *mouse_file;
|
|
|
|
gint i;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2001-06-25 23:01:36 +00:00
|
|
|
gdk_fb_mouse = g_new0 (GdkFBMouse, 1);
|
|
|
|
gdk_fb_mouse->fd = -1;
|
|
|
|
|
2000-12-08 12:38:48 +00:00
|
|
|
mouse_type = getenv ("GDK_MOUSE_TYPE");
|
2000-12-06 17:27:52 +00:00
|
|
|
if (!mouse_type)
|
|
|
|
mouse_type = "ps2";
|
2001-06-25 23:01:36 +00:00
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
for (i=0;i<G_N_ELEMENTS(mouse_devs);i++)
|
|
|
|
{
|
2002-09-27 21:36:11 +00:00
|
|
|
if (g_ascii_strcasecmp(mouse_type, mouse_devs[i].name)==0)
|
2000-12-06 17:27:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == G_N_ELEMENTS(mouse_devs))
|
|
|
|
{
|
2000-12-08 12:38:48 +00:00
|
|
|
g_warning ("No mouse driver of type %s found", mouse_type);
|
2000-12-06 17:27:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-06-25 23:01:36 +00:00
|
|
|
gdk_fb_mouse->dev = &mouse_devs[i];
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2003-09-16 17:59:20 +00:00
|
|
|
mouse_file = getenv ("GDK_MOUSE_FILE");
|
|
|
|
if (!mouse_file)
|
|
|
|
mouse_file = gdk_fb_mouse->dev->file;
|
|
|
|
gdk_fb_mouse->file = mouse_file;
|
|
|
|
|
2001-06-25 23:01:36 +00:00
|
|
|
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;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
2001-06-25 23:01:36 +00:00
|
|
|
if (!device->open(gdk_fb_mouse))
|
2000-12-06 17:27:52 +00:00
|
|
|
{
|
2000-12-08 12:38:48 +00:00
|
|
|
g_warning ("Mouse driver open failed");
|
2000-12-06 17:27:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-06-25 23:01:36 +00:00
|
|
|
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);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_fb_mouse_close (void)
|
|
|
|
{
|
2001-06-25 23:01:36 +00:00
|
|
|
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;
|
|
|
|
}
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
handle_mouse_io (GIOChannel *gioc,
|
|
|
|
GIOCondition cond,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GdkFBMouse *mouse = (GdkFBMouse *)data;
|
|
|
|
GdkFBMouseDevice *dev = mouse->dev;
|
2000-12-09 11:10:41 +00:00
|
|
|
guchar *proto = dev->proto;
|
2000-12-06 17:27:52 +00:00
|
|
|
gboolean got_motion;
|
2000-12-09 11:10:41 +00:00
|
|
|
gint n, i;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
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;
|
2000-12-09 11:10:41 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-03-22 16:06:06 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_fb_mouse_ps2_open (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
gint fd;
|
|
|
|
guchar buf[7];
|
|
|
|
int i = 0;
|
|
|
|
|
2003-09-16 17:59:20 +00:00
|
|
|
fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);
|
2000-12-06 17:27:52 +00:00
|
|
|
if (fd < 0)
|
2003-09-16 17:59:20 +00:00
|
|
|
{
|
|
|
|
g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
/* 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;
|
2003-09-16 17:59:20 +00:00
|
|
|
|
2002-03-22 16:06:06 +00:00
|
|
|
if (!write_all (fd, buf, i))
|
|
|
|
{
|
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-09-25 12:58:36 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_fb_mouse_imps2_open (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
gint fd;
|
|
|
|
guchar buf[7];
|
|
|
|
int i = 0;
|
|
|
|
|
2003-09-16 17:59:20 +00:00
|
|
|
fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);
|
2002-09-25 12:58:36 +00:00
|
|
|
if (fd < 0)
|
2003-09-16 17:59:20 +00:00
|
|
|
{
|
|
|
|
g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-25 12:58:36 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
static void
|
|
|
|
gdk_fb_mouse_ps2_close (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
close (mouse->fd);
|
2001-06-25 23:01:36 +00:00
|
|
|
mouse->fd = -1;
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2002-09-25 12:58:36 +00:00
|
|
|
if (mouse->dev->packet_size == 4 && buf[3] != 0)
|
|
|
|
handle_mouse_scroll (mouse, buf[3] & 0x80);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2003-09-16 17:59:20 +00:00
|
|
|
fd = gdk_fb_mouse_dev_open (mouse->file, O_RDWR);
|
|
|
|
if (fd < 0)
|
2001-06-25 23:01:36 +00:00
|
|
|
{
|
2003-09-16 17:59:20 +00:00
|
|
|
g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));
|
2001-06-25 23:01:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-09-16 17:59:20 +00:00
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
while ((i = read (fd, buf, sizeof(buf))) > 0)
|
2003-09-16 17:59:20 +00:00
|
|
|
g_print ("Got %d bytes of junk from %s\n", mouse->file, i);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
tcgetattr (fd, &tty);
|
|
|
|
tty.c_iflag = IGNBRK | IGNPAR;
|
|
|
|
tty.c_cflag = CREAD|CLOCAL|HUPCL|CS7|B1200;
|
|
|
|
tty.c_oflag = 0;
|
|
|
|
tty.c_lflag = 0;
|
|
|
|
tty.c_line = 0;
|
|
|
|
tty.c_cc[VTIME] = 0;
|
|
|
|
tty.c_cc[VMIN] = 1;
|
|
|
|
tcsetattr (fd, TCSAFLUSH, &tty);
|
2002-03-22 16:06:06 +00:00
|
|
|
|
|
|
|
if (!write_all (fd, "*n", 2))
|
|
|
|
{
|
|
|
|
close (fd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
mouse->fd = fd;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_fb_mouse_ms_close (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
close (mouse->fd);
|
2001-06-25 23:01:36 +00:00
|
|
|
mouse->fd = -1;
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_fb_mouse_ms_packet (GdkFBMouse *mouse,
|
|
|
|
gboolean *got_motion)
|
|
|
|
{
|
|
|
|
int dx=0, dy=0;
|
|
|
|
gboolean new_button1, new_button2, new_button3;
|
|
|
|
guchar *buf;
|
2000-12-09 11:10:41 +00:00
|
|
|
static guchar prev = 0;
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
buf = mouse->mouse_packet;
|
|
|
|
|
2000-12-09 11:10:41 +00:00
|
|
|
/* handling of third button is adapted from gpm ms driver */
|
|
|
|
if (buf[0] == 0x40 && !(prev|buf[1]|buf[2]))
|
|
|
|
{
|
|
|
|
new_button1 = 0;
|
|
|
|
new_button2 = 1;
|
|
|
|
new_button3 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_button1 = (buf[0] & 0x20) && 1;
|
|
|
|
new_button2 = 0;
|
|
|
|
new_button3 = (buf[0] & 0x10) && 1;
|
|
|
|
}
|
|
|
|
prev = (new_button1 << 2) | (new_button2 << 1) | (new_button3 << 0);
|
2000-12-06 17:27:52 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
dx = (signed char)(((buf[0] & 0x03) << 6) | (buf[1] & 0x3F));
|
|
|
|
dy = (signed char)(((buf[0] & 0x0C) << 4) | (buf[2] & 0x3F));
|
|
|
|
|
|
|
|
mouse->x += dx;
|
|
|
|
mouse->y += dy;
|
|
|
|
|
|
|
|
if (dx || dy)
|
|
|
|
*got_motion = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_fb_mouse_fidmour_open (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
gint fd;
|
|
|
|
|
2003-09-16 17:59:20 +00:00
|
|
|
fd = gdk_fb_mouse_dev_open (mouse->file, O_RDONLY);
|
2000-12-06 17:27:52 +00:00
|
|
|
if (fd < 0)
|
2003-09-16 17:59:20 +00:00
|
|
|
{
|
|
|
|
g_print ("Error opening %s: %s\n", mouse->file, strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-12-06 17:27:52 +00:00
|
|
|
mouse->fd = fd;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_fb_mouse_fidmour_close (GdkFBMouse *mouse)
|
|
|
|
{
|
|
|
|
close (mouse->fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gdk_fb_mouse_fidmour_packet (GdkFBMouse *mouse,
|
|
|
|
gboolean *got_motion)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
gboolean btn_down = 0;
|
|
|
|
gdouble x = 0.0, y = 0.0;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
if (!(mouse->mouse_packet[0] & 0x80))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* We haven't received any of the packet yet but there is no header at the beginning */
|
|
|
|
for (i = 1; i < mouse->packet_nbytes; i++)
|
|
|
|
{
|
|
|
|
if (mouse->mouse_packet[i] & 0x80)
|
|
|
|
{
|
|
|
|
n = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mouse->packet_nbytes > 1 &&
|
|
|
|
((mouse->mouse_packet[0] & 0x90) == 0x90))
|
|
|
|
{
|
|
|
|
/* eat the 0x90 and following byte, no clue what it's for */
|
|
|
|
n = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (mouse->mouse_packet[0] & 0xF)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
btn_down = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 0:
|
|
|
|
btn_down = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = mouse->mouse_packet[1] + (mouse->mouse_packet[2] << 7);
|
|
|
|
if (x > 8192)
|
|
|
|
x -= 16384;
|
|
|
|
y = mouse->mouse_packet[3] + (mouse->mouse_packet[4] << 7);
|
|
|
|
if (y > 8192)
|
|
|
|
y -= 16384;
|
|
|
|
/* Now map touchscreen coords to screen coords */
|
Added ENABLE_SHADOW_FB
2001-01-11 Alexander Larsson <alexl@redhat.com>
* acconfig.h:
Added ENABLE_SHADOW_FB
* configure.in:
Added --disable-shadowfb
* gdk/linux-fb/gdkcursor-fb.c:
Update shadowfb when updating cursor
* gdk/linux-fb/gdkdrawable-fb2.c:
Added wrappers for shadowfb that calls the normal drawable
methods, but calls gdk_shadow_fb_update(bounding box) when
GdkWindows are drawed to.
Moved gdk_draw_glyphs implementation to _gdk_draw_glyphs
which also returns the bounding box.
* gdk/linux-fb/gdkfb.h:
Added GdkFBAngle type and gdk_fb_set_rotation declaration.
* gdk/linux-fb/gdkgeometry-fb.c:
Update shadowfb when scrolling window.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_angle.
* gdk/linux-fb/gdkkeyboard-fb.c:
Test code for screen rotation. Shift-F2 in the xlate driver
rotates the screen.
* gdk/linux-fb/gdkmain-fb.c:
Handle shadowfb. Add gdk_fb_set_rotation(). Remove CM and RP.
* gdk/linux-fb/gdkmouse-fb.c:
Use fb_width/height instead of modeinfo.xres/yres.
* gdk/linux-fb/gdkprivate-fb.h:
Added fb_men, fb_width, fb_height & fb_stride. When using
shadow fb these can differ from the framebuffer stuff.
Declarations for gdk_shadow_fb_update, gdk_shadow_fb_init,
gdk_shadow_fb_stop_updates, gdk_fb_recompute_all,
_gdk_fb_screen_angle. Removed CM, RP.
* gdk/linux-fb/gdkrender-fb.c:
Added code for shadowfb handling and screen rotation using
shadowfb.
* gdk/linux-fb/gdkwindow-fb.c:
Use fb_mem, fb_stride, fb_width, fb_height.
Added recompute_rowstride to reset the rowstride of all windows.
Added gdk_fb_recompute_all() which recomputes rootwindow size,
window abs positions and window rowstrides. Usefull when the
rotation has changed.
2001-01-11 16:39:21 +00:00
|
|
|
x *= ((double)gdk_display->fb_width)/4096.0;
|
|
|
|
y *= ((double)gdk_display->fb_height)/4096.0;
|
2000-12-06 17:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
memmove (mouse->mouse_packet, mouse->mouse_packet+n, mouse->packet_nbytes-n);
|
|
|
|
mouse->packet_nbytes -= n;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (btn_down != mouse->button_pressed[0])
|
|
|
|
{
|
|
|
|
if (*got_motion)
|
|
|
|
{
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse->button_pressed[0] = btn_down;
|
|
|
|
send_button_event (mouse, 1, btn_down);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fabs(x - mouse->x) >= 1.0 || fabs(x - mouse->y) >= 1.0)
|
|
|
|
{
|
|
|
|
*got_motion = TRUE;
|
|
|
|
mouse->x = x;
|
|
|
|
mouse->y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|