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.
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.
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., Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
#include <string.h>
Olivier Fourdan
committed
#include <X11/X.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>
Stephan Arts
committed
#include <libxfce4ui/libxfce4ui.h>
#include "moveresize.h"
#include "cycle.h"
#include "placement.h"
#include "stacking.h"
Olivier Fourdan
committed
#include "transients.h"
#include "focus.h"
#include "netwm.h"
#include "startup_notification.h"
#include "events.h"
#include "event_filter.h"
Olivier Fourdan
committed
#include "xsync.h"
#include "display.h"
Olivier Fourdan
committed
#ifndef CHECK_BUTTON_TIME
#define CHECK_BUTTON_TIME 0
#endif
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 DOUBLE_CLICK_GRAB (ButtonMotionMask | \
PointerMotionMask | \
ButtonPressMask | \
ButtonReleaseMask)
Olivier Fourdan
committed
static int edge_scroll_x = 0;
Olivier Fourdan
committed
static int edge_scroll_y = 0;
Olivier Fourdan
committed
/* Forward decl. */
static eventFilterStatus handleEvent (DisplayInfo *display_info,
XEvent * ev);
static void menu_callback (Menu * menu,
MenuOp op,
Window xid,
gpointer menu_data,
gpointer item_data);
static void show_window_menu (Client *c,
gint px,
gint py,
guint button,
guint32 time);
static gboolean show_popup_cb (GtkWidget * widget,
GdkEventButton * ev,
gpointer data);
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
typedef struct _XfwmButtonClickData XfwmButtonClickData;
struct _XfwmButtonClickData
{
Olivier Fourdan
committed
Window w;
guint button;
guint clicks;
Olivier Fourdan
committed
guint timeout;
gint x0;
gint y0;
guint t0;
gint xcurrent;
gint ycurrent;
guint tcurrent;
gint double_click_time;
gint double_click_distance;
Olivier Fourdan
committed
};
Olivier Fourdan
committed
static gboolean
typeOfClick_end (gpointer data)
{
XfwmButtonClickData *passdata;
passdata = (XfwmButtonClickData *) data;
if (passdata->timeout)
{
g_source_remove (passdata->timeout);
passdata->timeout = 0;
}
gtk_main_quit ();
return (FALSE);
}
Olivier Fourdan
committed
typeOfClick_event_filter (XEvent * xevent, gpointer data)
{
XfwmButtonClickData *passdata;
eventFilterStatus status;
gboolean keep_going;
keep_going = TRUE;
passdata = (XfwmButtonClickData *) data;
Olivier Fourdan
committed
status = EVENT_FILTER_CONTINUE;
timestamp = myDisplayUpdateCurrentTime (passdata->display_info, xevent);
Olivier Fourdan
committed
Olivier Fourdan
committed
{
Olivier Fourdan
committed
if (((gint) passdata->tcurrent - (gint) passdata->t0) > passdata->double_click_time)
{
keep_going = FALSE;
}
}
Olivier Fourdan
committed
if ((xevent->type == ButtonRelease) || (xevent->type == ButtonPress))
{
if (xevent->xbutton.button == passdata->button)
{
passdata->clicks++;
}
if (((XfwmButtonClickType) passdata->clicks == XFWM_BUTTON_DOUBLE_CLICK)
|| (!(passdata->allow_double_click) &&
Olivier Fourdan
committed
(XfwmButtonClickType) passdata->clicks == XFWM_BUTTON_CLICK))
{
keep_going = FALSE;
}
Olivier Fourdan
committed
status = EVENT_FILTER_STOP;
Olivier Fourdan
committed
}
else if (xevent->type == MotionNotify)
{
passdata->xcurrent = xevent->xmotion.x_root;
passdata->ycurrent = xevent->xmotion.y_root;
Olivier Fourdan
committed
if ((ABS (passdata->x0 - passdata->xcurrent) > passdata->double_click_distance) ||
(ABS (passdata->y0 - passdata->ycurrent) > passdata->double_click_distance))
{
keep_going = FALSE;
Loading
Loading full blame...