diff options
author | Alexander Larsson <alla@lysator.liu.se> | 2000-11-20 10:12:40 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2000-11-20 10:12:40 +0000 |
commit | 2999f465b4db274a9d2301c7d3653d134bd79adb (patch) | |
tree | 50eefca3e476356c116ab34f2276bcee98703826 /gdk/linux-fb | |
parent | c9e39436b9cae1c03fb15242116798550a44b66e (diff) | |
download | gtk+-2999f465b4db274a9d2301c7d3653d134bd79adb.tar.gz |
Removed unused arguments from gdk_fb_drawable_get_pixel().
2000-11-20 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkdrawable-fb2.c:
Removed unused arguments from gdk_fb_drawable_get_pixel().
* gdk/linux-fb/gdkinput-ps2.c (handle_input_ps2):
Renamed fidur specific mouse packet data in MouseDevice to
generic. Used it in ps2 mouse handling code to avoid blocking
reads.
Diffstat (limited to 'gdk/linux-fb')
-rw-r--r-- | gdk/linux-fb/gdkdrawable-fb2.c | 40 | ||||
-rw-r--r-- | gdk/linux-fb/gdkinput-ps2.c | 60 |
2 files changed, 36 insertions, 64 deletions
diff --git a/gdk/linux-fb/gdkdrawable-fb2.c b/gdk/linux-fb/gdkdrawable-fb2.c index 4c7b6626ad..986274c2e8 100644 --- a/gdk/linux-fb/gdkdrawable-fb2.c +++ b/gdk/linux-fb/gdkdrawable-fb2.c @@ -14,10 +14,7 @@ static GetPixelRet gdk_fb_drawable_get_pixel (GdkDrawable *drawable, GdkGC *gc, int x, int y, - GdkColor *spot, - gboolean abs_coords, - GdkDrawable *bg_relto, - GdkDrawable *bgpm); + GdkColor *spot); void gdk_fb_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, gint filled, @@ -798,22 +795,13 @@ gdk_fb_drawable_get_pixel (GdkDrawable *drawable, GdkGC *gc, int x, int y, - GdkColor *spot, - gboolean abs_coords, - GdkDrawable *bg_relto, - GdkDrawable *bgpm) + GdkColor *spot) { GetPixelRet retval = GPR_NONE; GdkDrawableFBData *private = GDK_DRAWABLE_FBDATA (drawable); guchar *mem = private->mem; guint rowstride = private->rowstride; - if (!abs_coords) - { - x += private->abs_x; - y += private->abs_y; - } - switch (private->depth) { case 1: @@ -824,21 +812,7 @@ gdk_fb_drawable_get_pixel (GdkDrawable *drawable, else { retval = GPR_USED_BG; - - if (bgpm) - { - int bgx, bgy; - - bgx = (x - GDK_DRAWABLE_IMPL_FBDATA (bg_relto)->abs_x) % GDK_DRAWABLE_IMPL_FBDATA (bgpm)->width; - bgy = (y - GDK_DRAWABLE_IMPL_FBDATA (bg_relto)->abs_y) % GDK_DRAWABLE_IMPL_FBDATA (bgpm)->height; - - gdk_fb_drawable_get_pixel (bgpm, gc, bgx, bgy, spot, FALSE, NULL, NULL); - retval = GPR_USED_BG; - } - else - { - *spot = GDK_GC_FBDATA (gc)->values.background; - } + *spot = GDK_GC_FBDATA (gc)->values.background; } } break; @@ -1242,7 +1216,7 @@ gdk_fb_draw_drawable_generic (GdkDrawable *drawable, continue; } - switch (gdk_fb_drawable_get_pixel (src, gc, cur_x + src_x_off, cur_y + src_y_off, &spot, TRUE, NULL, NULL)) + switch (gdk_fb_drawable_get_pixel (src, gc, cur_x + src_x_off, cur_y + src_y_off, &spot)) { case GPR_AA_GRAYVAL: { @@ -1279,9 +1253,9 @@ gdk_fb_draw_drawable_generic (GdkDrawable *drawable, { int bgx, bgy; - bgx = (cur_x - GDK_DRAWABLE_IMPL_FBDATA (dc->bg_relto)->abs_x) % GDK_DRAWABLE_IMPL_FBDATA (dc->bgpm)->width; - bgy = (cur_y - GDK_DRAWABLE_IMPL_FBDATA (dc->bg_relto)->abs_y) % GDK_DRAWABLE_IMPL_FBDATA (dc->bgpm)->height; - gdk_fb_drawable_get_pixel (dc->bgpm, gc, bgx, bgy, &realspot, FALSE, NULL, NULL); + bgx = (cur_x - GDK_DRAWABLE_IMPL_FBDATA (dc->bg_relto)->abs_x) % GDK_DRAWABLE_IMPL_FBDATA (dc->bgpm)->width + private->abs_x; + bgy = (cur_y - GDK_DRAWABLE_IMPL_FBDATA (dc->bg_relto)->abs_y) % GDK_DRAWABLE_IMPL_FBDATA (dc->bgpm)->height + private->abs_y; + gdk_fb_drawable_get_pixel (dc->bgpm, gc, bgx, bgy, &realspot); } break; case GPR_NONE: diff --git a/gdk/linux-fb/gdkinput-ps2.c b/gdk/linux-fb/gdkinput-ps2.c index 8725320b14..bf1e030518 100644 --- a/gdk/linux-fb/gdkinput-ps2.c +++ b/gdk/linux-fb/gdkinput-ps2.c @@ -57,8 +57,8 @@ typedef struct { gboolean button1_pressed, button2_pressed, button3_pressed; gboolean click_grab; - guchar fidmour_bytes[5]; - int fidmour_nbytes; + guchar mouse_packet[5]; + int packet_nbytes; } MouseDevice; typedef struct { @@ -652,7 +652,7 @@ pull_fidmour_packet (MouseDevice *mouse, { int n; - n = read (mouse->fd, mouse->fidmour_bytes + mouse->fidmour_nbytes, 5 - mouse->fidmour_nbytes); + n = read (mouse->fd, mouse->mouse_packet + mouse->packet_nbytes, 5 - mouse->packet_nbytes); if (n < 0) return FALSE; else if (n == 0) @@ -662,31 +662,31 @@ pull_fidmour_packet (MouseDevice *mouse, return FALSE; } - mouse->fidmour_nbytes += n; + mouse->packet_nbytes += n; n = 0; - if (!(mouse->fidmour_bytes[0] & 0x80)) + 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->fidmour_nbytes; i++) + for (i = 1; i < mouse->packet_nbytes; i++) { - if (mouse->fidmour_bytes[i] & 0x80) + if (mouse->mouse_packet[i] & 0x80) { n = i; break; } } } - else if (mouse->fidmour_nbytes > 1 && - ((mouse->fidmour_bytes[0] & 0x90) == 0x90)) + 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 if (mouse->fidmour_nbytes == 5) + else if (mouse->packet_nbytes == 5) { - switch (mouse->fidmour_bytes[0] & 0xF) + switch (mouse->mouse_packet[0] & 0xF) { case 2: *btn_down = 0; @@ -700,10 +700,10 @@ pull_fidmour_packet (MouseDevice *mouse, break; } - *x = mouse->fidmour_bytes[1] + (mouse->fidmour_bytes[2] << 7); + *x = mouse->mouse_packet[1] + (mouse->mouse_packet[2] << 7); if (*x > 8192) *x -= 16384; - *y = mouse->fidmour_bytes[3] + (mouse->fidmour_bytes[4] << 7); + *y = mouse->mouse_packet[3] + (mouse->mouse_packet[4] << 7); if (*y > 8192) *y -= 16384; /* Now map touchscreen coords to screen coords */ @@ -715,8 +715,8 @@ pull_fidmour_packet (MouseDevice *mouse, if (n) { - memmove (mouse->fidmour_bytes, mouse->fidmour_bytes+n, mouse->fidmour_nbytes-n); - mouse->fidmour_nbytes -= n; + memmove (mouse->mouse_packet, mouse->mouse_packet+n, mouse->packet_nbytes-n); + mouse->packet_nbytes -= n; } } @@ -773,33 +773,32 @@ handle_input_ps2 (GIOChannel *gioc, gpointer data) { MouseDevice *mouse = data; - guchar buf[3]; - int n, left, dx=0, dy=0; + int n, dx=0, dy=0; gboolean new_button1, new_button2, new_button3; time_t the_time; GTimeVal curtime; gboolean got_motion = FALSE; + guchar *buf; g_get_current_time (&curtime); the_time = curtime.tv_usec; while (1) /* Go through as many mouse events as we can */ { - for (left = sizeof(buf); left > 0; ) - { - n = read (mouse->fd, buf+sizeof(buf)-left, left); - - if (n <= 0) - { - if (left != sizeof(buf)) - continue; /* XXX FIXME - this will be slow compared to turning on blocking mode, etc. */ - - goto done_reading_mouse_events; - } + n = read (mouse->fd, mouse->mouse_packet + mouse->packet_nbytes, 3 - mouse->packet_nbytes); + if (n<=0) /* error or nothing to read */ + break; + + mouse->packet_nbytes += n; + + if (mouse->packet_nbytes < 3) /* Mouse packet not finished */ + break; - left -= n; - } + mouse->packet_nbytes = 0; + /* Finished reading a packet */ + buf = mouse->mouse_packet; + new_button1 = (buf[0] & 1) && 1; new_button3 = (buf[0] & 2) && 1; new_button2 = (buf[0] & 4) && 1; @@ -848,7 +847,6 @@ handle_input_ps2 (GIOChannel *gioc, got_motion = TRUE; } - done_reading_mouse_events: if (got_motion) handle_mouse_input (mouse, TRUE); |