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>
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;
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;
typeOfClick (DisplayInfo *display_info, 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;
Olivier Fourdan
committed
g_return_val_if_fail (display_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);
XFlush (display_info->dpy);
g = XGrabPointer (display_info->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;
t0 = GDK_CURRENT_TIME;
Olivier Fourdan
committed
total = 0;
clicks = 1;
Olivier Fourdan
committed
while ((ABS (x - xcurrent) < 2) && (ABS (y - ycurrent) < 2)
&& (total < display_info->dbl_click_time)
&& ((GDK_CURRENT_TIME - t0) < display_info->dbl_click_time))
{
g_usleep (10000);
total += 10;
if (XCheckMaskEvent (display_info->dpy, FocusChangeMask, ev))
if (XCheckMaskEvent (display_info->dpy, ButtonReleaseMask | ButtonPressMask, ev))
{
if (ev->xbutton.button == button)
{
clicks++;
}
}
if ((XfwmButtonClickType) clicks == XFWM_BUTTON_DOUBLE_CLICK
|| (!allow_double_click
&& (XfwmButtonClickType) clicks == XFWM_BUTTON_CLICK))
{
break;
}
if (XCheckMaskEvent (display_info->dpy, ButtonMotionMask | PointerMotionMask, ev))
{
xcurrent = ev->xmotion.x_root;
ycurrent = ev->xmotion.y_root;
}
XUngrabPointer (display_info->dpy, ev->xbutton.time);
XFlush (display_info->dpy);
Olivier Fourdan
committed
return (XfwmButtonClickType) clicks;
}
clear_timeout (void)
if (raise_timeout)
g_source_remove (raise_timeout);
raise_timeout = 0;
raise_cb (gpointer data)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering raise_cb");
clear_timeout ();
c = clientGetFocus ();
if (c)
if (raise_timeout)
g_source_remove (raise_timeout);
raise_timeout = g_timeout_add_full (0, screen_info->params->raise_delay, (GtkFunction) raise_cb, NULL, NULL);
moveRequest (Client * c, XEvent * ev)
Loading
Loading full blame...