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; You may only use version 2 of the License,
you have no option to use any other 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-2003 Olivier Fourdan
Olivier Fourdan
committed
#include <config.h>
#include <X11/Xatom.h>
#ifdef HAVE_RANDR
#include <X11/extensions/Xrandr.h>
#endif
#include <libxfce4util/debug.h>
#include <libxfce4util/i18n.h>
#include <libxfcegui4/libxfcegui4.h>
#include "startup_notification.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 | \
PointerMotionHintMask | \
ButtonPressMask | \
ButtonReleaseMask)
#define MODIFIER_MASK (ShiftMask | \
ControlMask | \
AltMask | \
MetaMask | \
SuperMask | \
HyperMask)
static guint raise_timeout = 0;
static gulong button_handler_id = 0;
static GdkAtom atom_rcfiles = GDK_NONE;
Olivier Fourdan
committed
static int edge_scroll_x = 0;
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);
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;
static inline XfwmButtonClickType
typeOfClick (Window w, XEvent * ev, gboolean allow_double_click)
Olivier Fourdan
committed
{
Olivier Fourdan
committed
int xcurrent, ycurrent, x, y, total;
Olivier Fourdan
committed
int g = GrabSuccess;
Olivier Fourdan
committed
int clicks;
Time t0, t1;
g_return_val_if_fail (ev != NULL, XFWM_BUTTON_UNDEFINED);
g_return_val_if_fail (w != None, XFWM_BUTTON_UNDEFINED);
g = XGrabPointer (dpy, w, FALSE, DBL_CLICK_GRAB, GrabModeAsync,
GrabModeAsync, None, None, ev->xbutton.time);
if (g != GrabSuccess)
Olivier Fourdan
committed
{
TRACE ("grab failed in typeOfClick");
gdk_beep ();
return XFWM_BUTTON_UNDEFINED;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
Olivier Fourdan
committed
x = xcurrent = ev->xbutton.x_root;
y = ycurrent = ev->xbutton.y_root;
Olivier Fourdan
committed
t0 = ev->xbutton.time;
t1 = t0;
total = 0;
clicks = 1;
Olivier Fourdan
committed
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
while ((ABS (x - xcurrent) < 1) && (ABS (y - ycurrent) < 1)
&& (total < params.dbl_click_time)
&& ((t1 - t0) < params.dbl_click_time))
{
g_usleep (10000);
total += 10;
if (XCheckMaskEvent (dpy, ButtonReleaseMask | ButtonPressMask, ev))
{
if (ev->xbutton.button == button)
{
clicks++;
}
t1 = ev->xbutton.time;
}
if (XCheckMaskEvent (dpy,
ButtonMotionMask | PointerMotionMask | PointerMotionHintMask,
ev))
{
xcurrent = ev->xmotion.x_root;
ycurrent = ev->xmotion.y_root;
t1 = ev->xmotion.time;
}
if ((XfwmButtonClickType) clicks == XFWM_BUTTON_DOUBLE_CLICK
|| (!allow_double_click
&& (XfwmButtonClickType) clicks == XFWM_BUTTON_CLICK))
{
break;
}
}
XUngrabPointer (dpy, ev->xbutton.time);
Olivier Fourdan
committed
return (XfwmButtonClickType) clicks;
}
clear_timeout (void)
if (raise_timeout)
g_source_remove (raise_timeout);
raise_timeout = 0;
raise_cb (gpointer data)
TRACE ("entering raise_cb");
clear_timeout ();
c = clientGetFocus ();
if (c)
reset_timeout (void)
if (raise_timeout)
g_source_remove (raise_timeout);
raise_timeout =
g_timeout_add_full (0, params.raise_delay, (GtkFunction) raise_cb,
NULL, NULL);
static inline void
moveRequest (Client * c, XEvent * ev)
if (CLIENT_FLAG_TEST_AND_NOT (c, CLIENT_FLAG_HAS_MOVE, CLIENT_FLAG_FULLSCREEN))
clientMove (c, ev);
static inline void
resizeRequest (Client * c, int corner, XEvent * ev)
Loading
Loading full blame...