summaryrefslogtreecommitdiff
path: root/src/callbacks.c
blob: 197fc17c0e9600fe09b8a69eda01bf8d7dcb9a2c (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
/* 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 <signal.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkwindow.h>
#include "fakedev.h"

void on_send_signal_activate (GtkMenuItem *menuitem, FakeApp *app) {
  g_return_if_fail (app->xnest_pid != 0);
  kill (app->xnest_pid, SIGUSR1);
}

static void quit (FakeApp *app) {
  kill (app->xnest_pid, SIGKILL);
  gtk_main_quit ();
}

void on_quit_activate (GtkMenuItem *menuitem, FakeApp *app) {
  quit (app);
}

void on_window_destroy (GtkObject *object, FakeApp *app) {
  quit (app);
}

gboolean on_popup_menu_show (GtkWidget *widget, GdkEventButton *event, FakeApp *app) {
  if (event->button == 3) {
    gtk_menu_popup (GTK_MENU (app->popupmenu), NULL, NULL, NULL, NULL, event->button, event->time);
    return TRUE;
  }
  return FALSE;
}

void on_show_decorations_toggle (GtkCheckMenuItem *menuitem, FakeApp *app) {
  if (gtk_window_get_decorated (GTK_WINDOW (app->window))) {
    GdkBitmap *mask;
    mask = gdk_pixmap_new (app->fixed->window, app->device_width, app->device_height, 1);
    gdk_pixbuf_render_threshold_alpha (app->device_img, mask, 0, 0, 0, 0, -1, -1, 128);
    gtk_widget_realize(app->window);
    gdk_window_shape_combine_mask (app->window->window, mask, 0, 0);

    gtk_window_set_decorated (GTK_WINDOW (app->window), FALSE);
    gtk_check_menu_item_set_active (menuitem, FALSE);
  } else {
    gdk_window_shape_combine_mask (app->window->window, NULL, 0, 0);
    gtk_window_set_decorated (GTK_WINDOW (app->window), TRUE);
    gtk_check_menu_item_set_active (menuitem, TRUE);
  }
}

void on_about_activate (GtkMenuItem *menuitem, FakeApp *app) {
  gtk_window_present (GTK_WINDOW (app->about_window));
}

gboolean on_delete_event_hide (GtkWidget *widget, GdkEvent *event, FakeApp *app) {
  gtk_widget_hide (widget);
  return TRUE;
}