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 xid,
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)
Olivier Fourdan
committed
{
TRACE ("grab failed in typeOfClick");
gdk_beep ();
return XFWM_BUTTON_UNDEFINED;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
Olivier Fourdan
committed
passdata.button = ev->xbutton.button;
passdata.w = w;
passdata.x = ev->xbutton.x_root;
passdata.y = ev->xbutton.y_root;
passdata.xcurrent = passdata.x;
passdata.ycurrent = passdata.y;
passdata.clicks = 1;
passdata.allow_double_click = allow_double_click;
passdata.event_time = ev->xbutton.time;
passdata.timeout = g_timeout_add_full (0, display_info->dbl_click_time,
(GtkFunction) typeOfClick_break,
(gpointer) &passdata, NULL);
TRACE ("entering typeOfClick loop");
xfce_push_event_filter (display_info->xfilter, typeOfClick_event_filter, &passdata);
gtk_main ();
xfce_pop_event_filter (display_info->xfilter);
TRACE ("leaving typeOfClick loop");
XUngrabPointer (display_info->dpy, passdata.event_time);
Olivier Fourdan
committed
return (XfwmButtonClickType) passdata.clicks;
Olivier Fourdan
committed
}
static gboolean
check_button_time (XButtonEvent *ev)
{
static Time last_button_time = (Time) 0;
if (last_button_time > ev->time)
{
return FALSE;
}
last_button_time = ev->time;
return TRUE;
}
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 ();
Olivier Fourdan
committed
clientPassGrabMouseButton (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)
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE)
&& !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
clientMove (c, ev);
resizeRequest (Client * c, int corner, XEvent * ev)
if (FLAG_TEST_ALL (c->xfwm_flags,
XFWM_FLAG_HAS_RESIZE | XFWM_FLAG_IS_RESIZABLE))
clientResize (c, corner, ev);
else if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE)
&& !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
clientMove (c, ev);
spawn_shortcut (ScreenInfo *screen_info, int i)
{
GError *error = NULL;
if ((i >= NB_KEY_SHORTCUTS) || (!screen_info->params->shortcut_exec[i])
|| !strlen (screen_info->params->shortcut_exec[i]))
if (!xfce_gdk_spawn_command_line_on_screen (screen_info->gscr, screen_info->params->shortcut_exec[i], &error))
if (error)
{
g_warning ("%s: %s", g_get_prgname (), error->message);
g_error_free (error);
}
handleMotionNotify (DisplayInfo *display_info, XMotionEvent * ev)
Olivier Fourdan
committed
{
Olivier Fourdan
committed
int msx, msy, maxx, maxy;
TRACE ("entering handleMotionNotify");
if (display_info->nb_screens > 1)
{
/* Wrap workspace/wrap windows is disabled with multiscreen */
return;
}
/* Get the screen structure from the root of the event */
screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
if (!screen_info)
{
return;
}
if (screen_info->workspace_count && screen_info->params->wrap_workspaces
&& screen_info->params->wrap_resistance)
{
msx = ev->x_root;
msy = ev->y_root;
Olivier Fourdan
committed
maxx = gdk_screen_get_width (screen_info->gscr) - 1;
maxy = gdk_screen_get_height (screen_info->gscr) - 1;
Olivier Fourdan
committed
if ((msx == 0) || (msx == maxx))
{
edge_scroll_x++;
}
else
{
edge_scroll_x = 0;
}
Olivier Fourdan
committed
if ((msy == 0) || (msy == maxy))
{
edge_scroll_y++;
}
else
{
edge_scroll_y = 0;
}
if (edge_scroll_x > screen_info->params->wrap_resistance)
{
edge_scroll_x = 0;
if (msx == 0)
{
Olivier Fourdan
committed
if (workspaceMove (screen_info, 0, -1, NULL))
{
XWarpPointer (display_info->dpy, None, screen_info->xroot, 0, 0, 0, 0, maxx - 10, msy);
}
}
else if (msx == maxx)
{
if (workspaceMove (screen_info, 0, 1, NULL))
{
XWarpPointer (display_info->dpy, None, screen_info->xroot, 0, 0, 0, 0, 10, msy);
}
}
while (XCheckWindowEvent(display_info->dpy, ev->window, PointerMotionMask, (XEvent *) ev))
; /* Skip event */
}
if (edge_scroll_y > screen_info->params->wrap_resistance)
{
edge_scroll_y = 0;
if (msy == 0)
{
if (workspaceMove (screen_info, -1, 0, NULL))
{
XWarpPointer (display_info->dpy, None, screen_info->xroot, 0, 0, 0, 0, msx, maxy - 10);
}
Olivier Fourdan
committed
else if (msy == maxy)
Olivier Fourdan
committed
if (workspaceMove (screen_info, 1, 0, NULL))
{
XWarpPointer (display_info->dpy, None, screen_info->xroot, 0, 0, 0, 0, msx, 10);
}
while (XCheckWindowEvent(display_info->dpy, ev->window, PointerMotionMask, (XEvent *) ev))
; /* Skip event */
Olivier Fourdan
committed
}
}
static int
getKeyPressed (ScreenInfo *screen_info, XKeyEvent * ev)
state = ev->state & MODIFIER_MASK;
for (key = 0; key < KEY_COUNT; key++)
{
if ((screen_info->params->keys[key].keycode == ev->keycode)
&& (screen_info->params->keys[key].modifier == state))
{
break;
}
static void
handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
{
ScreenInfo *screen_info = NULL;
Client *c = NULL;
int key;
TRACE ("entering handleKeyEvent");
c = clientGetFocus ();
key = getKeyPressed (screen_info, ev);
switch (key)
{
case KEY_MOVE_UP:
case KEY_MOVE_DOWN:
case KEY_MOVE_LEFT:
case KEY_MOVE_RIGHT:
moveRequest (c, (XEvent *) ev);
break;
case KEY_RESIZE_UP:
case KEY_RESIZE_DOWN:
case KEY_RESIZE_LEFT:
case KEY_RESIZE_RIGHT:
if (FLAG_TEST_ALL (c->xfwm_flags,
XFWM_FLAG_HAS_RESIZE | XFWM_FLAG_IS_RESIZABLE))
{
clientResize (c, CORNER_BOTTOM_RIGHT, (XEvent *) ev);
}
break;
case KEY_CYCLE_WINDOWS:
clientCycle (c, (XEvent *) ev);
break;
case KEY_CLOSE_WINDOW:
clientClose (c);
break;
case KEY_HIDE_WINDOW:
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER) && CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
break;
case KEY_MAXIMIZE_WINDOW:
clientToggleMaximized (c, WIN_STATE_MAXIMIZED);
break;
case KEY_MAXIMIZE_VERT:
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_VERT);
break;
case KEY_MAXIMIZE_HORIZ:
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_HORIZ);
break;
case KEY_SHADE_WINDOW:
clientToggleShaded (c);
break;
case KEY_STICK_WINDOW:
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER) && CLIENT_CAN_STICK_WINDOW(c))
{
clientToggleSticky (c, TRUE);
frameDraw (c, FALSE, FALSE);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
case KEY_TOGGLE_FULLSCREEN:
clientToggleFullscreen (c);
break;
case KEY_MOVE_NEXT_WORKSPACE:
workspaceSwitch (screen_info, screen_info->current_ws + 1, c);
break;
case KEY_MOVE_PREV_WORKSPACE:
workspaceSwitch (screen_info, screen_info->current_ws - 1, c);
Olivier Fourdan
committed
case KEY_MOVE_UP_WORKSPACE:
workspaceMove (screen_info, -1, 0, c);
break;
case KEY_MOVE_DOWN_WORKSPACE:
workspaceMove (screen_info, 1, 0, c);
break;
case KEY_MOVE_LEFT_WORKSPACE:
workspaceMove (screen_info, 0, -1, c);
break;
case KEY_MOVE_RIGHT_WORKSPACE:
workspaceMove (screen_info, 0, 1, c);
break;
case KEY_MOVE_WORKSPACE_1:
case KEY_MOVE_WORKSPACE_2:
case KEY_MOVE_WORKSPACE_3:
case KEY_MOVE_WORKSPACE_4:
case KEY_MOVE_WORKSPACE_5:
case KEY_MOVE_WORKSPACE_6:
case KEY_MOVE_WORKSPACE_7:
case KEY_MOVE_WORKSPACE_8:
case KEY_MOVE_WORKSPACE_9:
workspaceSwitch (screen_info, key - KEY_MOVE_WORKSPACE_1, c);
break;
default:
break;
}
Olivier Fourdan
committed
}
else
{
screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
if (!screen_info)
{
return;
}
key = getKeyPressed (screen_info, ev);
switch (key)
{
case KEY_CYCLE_WINDOWS:
clientCycle (screen_info->clients->prev, (XEvent *) ev);
}
break;
default:
break;
}
Olivier Fourdan
committed
}
/*
Here we know that "screen_info" is defined, otherwise, we would
already have returned...
*/
Olivier Fourdan
committed
switch (key)
{
case KEY_NEXT_WORKSPACE:
workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL);
break;
case KEY_PREV_WORKSPACE:
workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL);
Olivier Fourdan
committed
case KEY_UP_WORKSPACE:
workspaceMove(screen_info, -1, 0, NULL);
break;
case KEY_DOWN_WORKSPACE:
workspaceMove(screen_info, 1, 0, NULL);
break;
case KEY_LEFT_WORKSPACE:
workspaceMove(screen_info, 0, -1, NULL);
break;
case KEY_RIGHT_WORKSPACE:
workspaceMove(screen_info, 0, 1, NULL);
break;
case KEY_ADD_WORKSPACE:
workspaceSetCount (screen_info, screen_info->workspace_count + 1);
break;
case KEY_DEL_WORKSPACE:
workspaceSetCount (screen_info, screen_info->workspace_count - 1);
break;
case KEY_WORKSPACE_1:
case KEY_WORKSPACE_2:
case KEY_WORKSPACE_3:
case KEY_WORKSPACE_4:
case KEY_WORKSPACE_5:
case KEY_WORKSPACE_6:
case KEY_WORKSPACE_7:
case KEY_WORKSPACE_8:
case KEY_WORKSPACE_9:
workspaceSwitch (screen_info, key - KEY_WORKSPACE_1, NULL);
break;
case KEY_SHORTCUT_1:
case KEY_SHORTCUT_2:
case KEY_SHORTCUT_3:
case KEY_SHORTCUT_4:
case KEY_SHORTCUT_5:
case KEY_SHORTCUT_6:
case KEY_SHORTCUT_7:
case KEY_SHORTCUT_8:
case KEY_SHORTCUT_9:
case KEY_SHORTCUT_10:
spawn_shortcut (screen_info, key - KEY_SHORTCUT_1);
break;
default:
break;
/* User has clicked on an edge or corner.
* Button 1 : Raise and resize
* Button 2 : Move
* Button 3 : Resize
*/
edgeButton (Client * c, int part, XButtonEvent * ev)
if (ev->button == Button2)
XfwmButtonClickType tclick;
Olivier Fourdan
committed
Olivier Fourdan
committed
tclick = typeOfClick (screen_info, c->window, (XEvent *) ev, FALSE);
if (tclick == XFWM_BUTTON_CLICK)
{
clientLower (c);
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
Olivier Fourdan
committed
else if (tclick != XFWM_BUTTON_UNDEFINED)
{
moveRequest (c, (XEvent *) ev);
}
if (ev->button == Button1)
{
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (c->screen_info, c, GDK_CURRENT_TIME, NO_FOCUS_FLAG);
}
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
}
if ((ev->button == Button1) || (ev->button == Button3))
{
resizeRequest (c, part, (XEvent *) ev);
}
button1Action (Client * c, XButtonEvent * ev)
ScreenInfo *screen_info = NULL;
DisplayInfo *display_info = NULL;
XfwmButtonClickType tclick;
g_return_if_fail (c != NULL);
g_return_if_fail (ev != NULL);
screen_info = c->screen_info;
display_info = screen_info->display_info;
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (screen_info, c, ev->time, NO_FOCUS_FLAG);
}
clientRaise (c);
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
Olivier Fourdan
committed
tclick = typeOfClick (screen_info, c->window, ©_event, TRUE);
if ((tclick == XFWM_BUTTON_DRAG)
|| (tclick == XFWM_BUTTON_CLICK_AND_DRAG))
moveRequest (c, (XEvent *) ev);
else if (tclick == XFWM_BUTTON_DOUBLE_CLICK)
switch (screen_info->params->double_click_action)
{
case ACTION_MAXIMIZE:
clientToggleMaximized (c, WIN_STATE_MAXIMIZED);
break;
case ACTION_SHADE:
clientToggleShaded (c);
break;
case ACTION_HIDE:
if (CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
titleButton (Client * c, int state, XButtonEvent * ev)
ScreenInfo *screen_info = NULL;
DisplayInfo *display_info = NULL;
g_return_if_fail (c != NULL);
g_return_if_fail (ev != NULL);
/* Get Screen data from the client itself */
screen_info = c->screen_info;
display_info = screen_info->display_info;
if (ev->button == Button1)
{
button1Action (c, ev);
}
else if (ev->button == Button2)
{
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
}
else if (ev->button == Button3)
{
/*
We need to copy the event to keep the original event untouched
for gtk to handle it (in case we open up the menu)
*/
XfwmButtonClickType tclick;
memcpy(©_event, ev, sizeof(XEvent));
Olivier Fourdan
committed
tclick = typeOfClick (screen_info, c->window, ©_event, FALSE);
if (tclick == XFWM_BUTTON_DRAG)
{
moveRequest (c, (XEvent *) ev);
}
Olivier Fourdan
committed
else if (tclick != XFWM_BUTTON_UNDEFINED)
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (screen_info, c, ev->time, NO_FOCUS_FLAG);
}
{
clientRaise (c);
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
}
ev->window = ev->root;
g_signal_handler_disconnect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)), screen_info->button_handler_id);
screen_info->button_handler_id = g_signal_connect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)),
"button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) c);
/* Let GTK handle this for us. */
}
}
else if (ev->button == Button4)
{
/* Mouse wheel scroll up */
if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
{
clientShade (c);
}
else if (ev->button == Button5)
/* Mouse wheel scroll down */
if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
{
clientUnshade (c);
}
rootScrollButton (DisplayInfo *display_info, XButtonEvent * ev)
{
static Time lastscroll = (Time) 0;
Olivier Fourdan
committed
if ((ev->time - lastscroll) < 25) /* ms */
/* Too many events in too little time, drop this event... */
return;
}
lastscroll = ev->time;
/* Get the screen structure from the root of the event */
screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
if (!screen_info)
{
return;
}
if (ev->button == Button4)
{
workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL);
}
else if (ev->button == Button5)
{
workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL);
}
}
handleButtonPress (DisplayInfo *display_info, XButtonEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
int state, replay = FALSE;
TRACE ("entering handleButtonPress");
/* Avoid treating the same event twice */
if (!check_button_time (ev))
{
TRACE ("ignoring ButtonPress event because it has been already handled");
return;
}
clear_timeout ();
c = myDisplayGetClientFromWindow (display_info, ev->window, ANY);
state = ev->state & MODIFIER_MASK;
win = ev->subwindow;
if ((ev->button == Button1) && (state == AltMask) && (screen_info->params->easy_click))
{
button1Action (c, ev);
}
else if ((ev->button == Button2) && (state == AltMask) && (screen_info->params->easy_click))
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
else if ((ev->button == Button3) && (state == AltMask) && (screen_info->params->easy_click))
if ((ev->x < c->width / 2) && (ev->y < c->height / 2))
{
edgeButton (c, CORNER_TOP_LEFT, ev);
}
else if ((ev->x < c->width / 2) && (ev->y > c->height / 2))
{
edgeButton (c, CORNER_BOTTOM_LEFT, ev);
}
else if ((ev->x > c->width / 2) && (ev->y < c->height / 2))
{
edgeButton (c, CORNER_TOP_RIGHT, ev);
}
else
{
edgeButton (c, CORNER_BOTTOM_RIGHT, ev);
}
}
else if (WIN_IS_BUTTON (win))
{
if (ev->button <= Button3)
{
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (screen_info, c, ev->time, NO_FOCUS_FLAG);
}
{
clientRaise (c);
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
}
clientButtonPress (c, win, ev);
}
}
else if (win == MYWINDOW_XWINDOW (c->title))
{
titleButton (c, state, ev);
}
else if (win == MYWINDOW_XWINDOW (c->buttons[MENU_BUTTON]))
{
if (ev->button == Button1)
{
/*
We need to copy the event to keep the original event untouched
for gtk to handle it (in case we open up the menu)
*/
XfwmButtonClickType tclick;
Olivier Fourdan
committed
tclick = typeOfClick (screen_info, c->window, ©_event, TRUE);
if (tclick == XFWM_BUTTON_DOUBLE_CLICK)
{
clientClose (c);
}
Olivier Fourdan
committed
else if (tclick != XFWM_BUTTON_UNDEFINED)
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (screen_info, c, ev->time, NO_FOCUS_FLAG);
}
{
clientRaise (c);
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
}
ev->window = ev->root;
g_signal_handler_disconnect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)), screen_info->button_handler_id);
screen_info->button_handler_id = g_signal_connect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)),
"button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) c);
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
/* Let GTK handle this for us. */
}
}
}
else if ((win == MYWINDOW_XWINDOW (c->corners[CORNER_TOP_LEFT]))
&& (state == 0))
{
edgeButton (c, CORNER_TOP_LEFT, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->corners[CORNER_TOP_RIGHT]))
&& (state == 0))
{
edgeButton (c, CORNER_TOP_RIGHT, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_LEFT]))
&& (state == 0))
{
edgeButton (c, CORNER_BOTTOM_LEFT, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->corners[CORNER_BOTTOM_RIGHT]))
&& (state == 0))
{
edgeButton (c, CORNER_BOTTOM_RIGHT, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->sides[SIDE_BOTTOM]))
&& (state == 0))
{
edgeButton (c, 4 + SIDE_BOTTOM, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->sides[SIDE_LEFT]))
&& (state == 0))
{
edgeButton (c, 4 + SIDE_LEFT, ev);
}
else if ((win == MYWINDOW_XWINDOW (c->sides[SIDE_RIGHT]))
&& (state == 0))
{
edgeButton (c, 4 + SIDE_RIGHT, ev);
}
Olivier Fourdan
committed
else if (ev->window == c->window)
Olivier Fourdan
committed
if ((screen_info->params->raise_with_any_button) ||
(ev->button == Button1))
Olivier Fourdan
committed
clientPassGrabMouseButton (c);
if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
{
clientSetFocus (screen_info, c, ev->time, NO_FOCUS_FLAG);
}
Olivier Fourdan
committed
if ((screen_info->params->raise_on_click) ||
!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER))
{
clientRaise (c);
}
}
Olivier Fourdan
committed
replay = TRUE;
}
if (replay)
{
XAllowEvents (display_info->dpy, ReplayPointer, ev->time);
XAllowEvents (display_info->dpy, SyncPointer, ev->time);