Newer
Older
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.
Olivier Fourdan
committed
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.
Olivier Fourdan
committed
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Olivier Fourdan
committed
xfwm4 - (c) 2002-2004 Olivier Fourdan
Olivier Fourdan
committed
#include <config.h>
#include <X11/Xatom.h>
#include <glib.h>
#include <gtk/gtk.h>
#ifdef HAVE_RANDR
#include <X11/extensions/Xrandr.h>
#endif
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/libxfcegui4.h>
#include "stacking.h"
Olivier Fourdan
committed
#include "transients.h"
#include "focus.h"
#include "netwm.h"
#include "startup_notification.h"
#include "events.h"
Olivier Fourdan
committed
#define WIN_IS_BUTTON(win) ((win == MYWINDOW_XWINDOW(c->buttons[HIDE_BUTTON])) || \
(win == MYWINDOW_XWINDOW(c->buttons[CLOSE_BUTTON])) || \
(win == MYWINDOW_XWINDOW(c->buttons[MAXIMIZE_BUTTON])) || \
(win == MYWINDOW_XWINDOW(c->buttons[SHADE_BUTTON])) || \
(win == MYWINDOW_XWINDOW(c->buttons[STICK_BUTTON])))
#define DBL_CLICK_GRAB (ButtonMotionMask | \
PointerMotionMask | \
ButtonPressMask | \
ButtonReleaseMask)
#define MODIFIER_MASK (ShiftMask | \
ControlMask | \
AltMask | \
MetaMask | \
SuperMask | \
HyperMask)
extern gboolean xfwm4_quit;
extern gboolean xfwm4_reload;
static guint raise_timeout = 0;
static GdkAtom atom_rcfiles = GDK_NONE;
Olivier Fourdan
committed
static int edge_scroll_x = 0;
Olivier Fourdan
committed
static int edge_scroll_y = 0;
static void handleEvent (DisplayInfo *display_info, XEvent * ev);
static void menu_callback (Menu * menu, MenuOp op, Window client_xwindow,
gpointer menu_data, gpointer item_data);
static gboolean show_popup_cb (GtkWidget * widget, GdkEventButton * ev,
static gboolean client_event_cb (GtkWidget * widget, GdkEventClient * ev, gpointer data);
Olivier Fourdan
committed
XFWM_BUTTON_UNDEFINED = 0,
XFWM_BUTTON_DRAG = 1,
XFWM_BUTTON_CLICK = 2,
XFWM_BUTTON_CLICK_AND_DRAG = 3,
XFWM_BUTTON_DOUBLE_CLICK = 4
}
XfwmButtonClickType;
Olivier Fourdan
committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
typedef struct _XfwmButtonClickData XfwmButtonClickData;
struct _XfwmButtonClickData
{
Time event_time;
Window w;
guint button;
gboolean allow_double_click;
guint clicks;
gint x;
gint y;
gint xcurrent;
gint ycurrent;
guint timeout;
};
static gboolean
typeOfClick_break (gpointer data)
{
XfwmButtonClickData *passdata = (XfwmButtonClickData *) data;
if (passdata->timeout)
{
g_source_remove (passdata->timeout);
passdata->timeout = 0;
}
gtk_main_quit ();
return (TRUE);
}
static XfceFilterStatus
typeOfClick_event_filter (XEvent * xevent, gpointer data)
{
gboolean keep_going = TRUE;
XfceFilterStatus status = XEV_FILTER_STOP;
XfwmButtonClickData *passdata = (XfwmButtonClickData *) data;
if ((xevent->type == ButtonRelease) || (xevent->type == ButtonPress))
{
if (xevent->xbutton.button == passdata->button)
{
passdata->clicks++;
}
passdata->event_time = xevent->xbutton.time;
if (((XfwmButtonClickType) passdata->clicks == XFWM_BUTTON_DOUBLE_CLICK)
|| (!(passdata->allow_double_click) &&
(XfwmButtonClickType) passdata->clicks == XFWM_BUTTON_CLICK))
{
keep_going = FALSE;
}
}
else if (xevent->type == MotionNotify)
{
passdata->xcurrent = xevent->xmotion.x_root;
passdata->ycurrent = xevent->xmotion.y_root;
}
else if ((xevent->type == DestroyNotify) || (xevent->type == UnmapNotify))
{
if (xevent->xany.window == passdata->w)
{
/* Discard, mark the click as undefined */
passdata->clicks = (guint) XFWM_BUTTON_UNDEFINED;
keep_going = FALSE;
}
status = XEV_FILTER_CONTINUE;
}
else
{
status = XEV_FILTER_CONTINUE;
}
if ((ABS (passdata->x - passdata->xcurrent) > 1) ||
(ABS (passdata->y - passdata->ycurrent) > 1) ||
(!keep_going))
{
TRACE ("event loop now finished");
typeOfClick_break (data);
}
return status;
}
Olivier Fourdan
committed
typeOfClick (ScreenInfo *screen_info, Window w, XEvent * ev, gboolean allow_double_click)
Olivier Fourdan
committed
{
int g = GrabSuccess;
Olivier Fourdan
committed
DisplayInfo *display_info;
XfwmButtonClickData passdata;
Olivier Fourdan
committed
Olivier Fourdan
committed
g_return_val_if_fail (screen_info != NULL, XFWM_BUTTON_UNDEFINED);
g_return_val_if_fail (ev != NULL, XFWM_BUTTON_UNDEFINED);
g_return_val_if_fail (w != None, XFWM_BUTTON_UNDEFINED);
Olivier Fourdan
committed
display_info = screen_info->display_info;
Olivier Fourdan
committed
g = XGrabPointer (display_info->dpy, screen_info->gnome_win,
FALSE, DBL_CLICK_GRAB, GrabModeAsync,
GrabModeAsync, None, None, ev->xbutton.time);
if (g != GrabSuccess)
Loading
Loading full blame...