summaryrefslogtreecommitdiff
path: root/src/button.c
blob: f274e1d3ca6e88fe68edf98130514c9e80eb3d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Xoo - a graphical wrapper around xnest
 *
 *  Copyright 2004,2005 Matthew Allum, Openedhand Ltd <mallum@o-hand.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program 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 General Public License for more details.
 */

#include "config.h"
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "fakedev.h"

FakeButton *
button_new (FakeApp * app,
	    int x,
	    int y,
	    int width, int height, KeySym ks, int repeat, GdkPixbuf * img)
{
  FakeButton *button = malloc (sizeof (FakeButton));
  memset (button, 0, sizeof (FakeButton));

  button->app = app;
  button->x = x;
  button->y = y;
  button->height = height;
  button->width = width;
  button->keysym = ks;
  button->overlay = img;
  button->repeat = repeat;

  if (img)
    {
      if (gdk_pixbuf_get_width (img) != button->width
	  || gdk_pixbuf_get_height (img) != button->height)
	{
	  fprintf (stderr,
		   "** warning: Button image size does not equal defined button size.\n");

	}
    }

  /* keysyms */

  return button;
}

#if 0
FakeButton *
button_find_from_win (FakeApp * app, Window xevent_window_id)
{
  FakeButton *button;

  for (button = app->button_head; button; button = button->next)
    if (button->win == xevent_window_id)
      return button;

  return NULL;
}
#endif

void
button_press (GtkWidget * w, GdkEventButton * event, FakeButton * button)
{
  g_return_if_fail (button != NULL);
  gtk_image_set_from_pixbuf (GTK_IMAGE (button->image),
	  gdk_pixbuf_get_from_surface (button->active_img,
	  0, 0, button->width, button->height));
  keys_send_key (button->app, button->keysym, KEYDOWN);
}

void
button_release (GtkWidget * w, GdkEventButton * event, FakeButton * button)
{
  g_return_if_fail (button != NULL);
  gtk_image_set_from_pixbuf (GTK_IMAGE (button->image),
	  gdk_pixbuf_get_from_surface (button->normal_img,
	  0, 0, button->width, button->height));
  keys_send_key (button->app, button->keysym, KEYUP);
}

void
button_activate (FakeApp * app, FakeButton * button)
{
  ;
}