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
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
#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 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
typedef struct _XfwmButtonClickData XfwmButtonClickData;
struct _XfwmButtonClickData
{
Olivier Fourdan
committed
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
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;
/* Update the display time */
myDisplayUpdateCurentTime (passdata->display_info, xevent);
Olivier Fourdan
committed
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
183
184
185
186
187
188
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) &&
(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
{
DisplayInfo *display_info = NULL;
Olivier Fourdan
committed
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;
g = myScreenGrabPointer (screen_info, DBL_CLICK_GRAB, None, ev->xbutton.time);
if (!g)
Olivier Fourdan
committed
{
TRACE ("grab failed in typeOfClick");
gdk_beep ();
myScreenUngrabPointer (screen_info, ev->xbutton.time);
return XFWM_BUTTON_UNDEFINED;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
passdata.display_info = display_info;
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.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");
myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
Olivier Fourdan
committed
return (XfwmButtonClickType) passdata.clicks;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
#if CHECK_BUTTON_TIME
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;
}
Olivier Fourdan
committed
#endif
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
clientRaise (c, None);
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);
static void
toggle_show_desktop (ScreenInfo *screen_info)
{
long visible = 0;
getHint (screen_info->display_info, screen_info->xroot,
NET_SHOWING_DESKTOP, &visible);
sendRootMessage (screen_info, NET_SHOWING_DESKTOP, !visible,
myDisplayGetCurrentTime (screen_info->display_info));
}
handleMotionNotify (DisplayInfo *display_info, XMotionEvent * ev)
Olivier Fourdan
committed
{
TRACE ("entering handleMotionNotify");
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);
Olivier Fourdan
committed
c->user_time = myDisplayGetCurrentTime (display_info);
Olivier Fourdan
committed
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:
{
clientHide (c, c->win_workspace, TRUE);
}
break;
case KEY_MAXIMIZE_WINDOW:
Olivier Fourdan
committed
clientToggleMaximized (c, WIN_STATE_MAXIMIZED, TRUE);
break;
case KEY_MAXIMIZE_VERT:
Olivier Fourdan
committed
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_VERT, TRUE);
break;
case KEY_MAXIMIZE_HORIZ:
Olivier Fourdan
committed
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_HORIZ, TRUE);
break;
case KEY_SHADE_WINDOW:
clientToggleShaded (c);
break;
case KEY_STICK_WINDOW:
{
clientToggleSticky (c, TRUE);
frameDraw (c, FALSE, FALSE);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
clientRaise (c, None);
Olivier Fourdan
committed
clientLower (c, None);
case KEY_TOGGLE_FULLSCREEN:
clientToggleFullscreen (c);
break;
case KEY_MOVE_NEXT_WORKSPACE:
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE);
break;
case KEY_MOVE_PREV_WORKSPACE:
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws - 1, c, TRUE);
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:
case KEY_MOVE_WORKSPACE_10:
case KEY_MOVE_WORKSPACE_11:
case KEY_MOVE_WORKSPACE_12:
Olivier Fourdan
committed
if (key - KEY_MOVE_WORKSPACE_1 < screen_info->workspace_count)
Olivier Fourdan
committed
{
clientRaise (c, None);
Olivier Fourdan
committed
workspaceSwitch (screen_info, key - KEY_MOVE_WORKSPACE_1, c, TRUE);
Olivier Fourdan
committed
}
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:
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE);
break;
case KEY_PREV_WORKSPACE:
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE);
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:
case KEY_WORKSPACE_10:
case KEY_WORKSPACE_11:
case KEY_WORKSPACE_12:
Olivier Fourdan
committed
if (key - KEY_WORKSPACE_1 < screen_info->workspace_count)
{
Olivier Fourdan
committed
workspaceSwitch (screen_info, key - KEY_WORKSPACE_1, NULL, TRUE);
Olivier Fourdan
committed
}
case KEY_SHOW_DESKTOP:
toggle_show_desktop (screen_info);
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)
{
Olivier Fourdan
committed
clientLower (c, None);
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, ev->time, NO_FOCUS_FLAG);
}
Olivier Fourdan
committed
clientRaise (c, None);
}
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);
}
Olivier Fourdan
committed
clientRaise (c, None);
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:
Olivier Fourdan
committed
clientToggleMaximized (c, WIN_STATE_MAXIMIZED, TRUE);
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
clientLower (c, None);
}
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);
}
Olivier Fourdan
committed
clientRaise (c, None);
}
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 (state == AltMask)
{
clientIncOpacity(c);
}
else if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
{
clientShade (c);
}
else if (ev->button == Button5)
/* Mouse wheel scroll down */
if (state == AltMask)
{
clientDecOpacity(c);
}
else 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)
{
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE);
}
else if (ev->button == Button5)
{
Olivier Fourdan
committed
workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE);
}
}
handleButtonPress (DisplayInfo *display_info, XButtonEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
int state, replay = FALSE;
TRACE ("entering handleButtonPress");
Olivier Fourdan
committed
#if CHECK_BUTTON_TIME
Olivier Fourdan
committed
/* Avoid treating the same event twice */
if (!check_button_time (ev))
{
TRACE ("ignoring ButtonPress event because it has been already handled");
return;
}
Olivier Fourdan
committed
#endif
c = myDisplayGetClientFromWindow (display_info, ev->window, ANY);
win = ev->subwindow;
Olivier Fourdan
committed
c->user_time = myDisplayGetCurrentTime (display_info);
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
clientLower (c, None);
else if ((ev->button == Button3) && (state == AltMask) && (screen_info->params->easy_click))
Olivier Fourdan
committed
int part, x_corner_pixels, y_corner_pixels, x_distance, y_distance;
/* Corner is 1/3 of the side */
x_corner_pixels = MAX(c->width / 3, 50);
y_corner_pixels = MAX(c->height / 3, 50);
/* Distance from event to edge of client window */
x_distance = c->width / 2 - abs(c->width / 2 - ev->x);
y_distance = c->height / 2 - abs(c->height / 2 - ev->y);
if (x_distance < x_corner_pixels && y_distance < y_corner_pixels)
Olivier Fourdan
committed
/* In a corner */
if (ev->x < c->width / 2)
{
if (ev->y < c->height / 2)
{
part = CORNER_TOP_LEFT;
}
else
{
part = CORNER_BOTTOM_LEFT;
}
}
else
{
if (ev->y < c->height / 2)
{
part = CORNER_TOP_RIGHT;
}
else
{
part = CORNER_BOTTOM_RIGHT;
}
}
}
else
{
Olivier Fourdan
committed
/* Not a corner - some side */
if (x_distance / x_corner_pixels < y_distance / y_corner_pixels)
{
/* Left or right side */
if (ev->x < c->width / 2)
{
part = 4 + SIDE_LEFT;
}
else
{
part = 4 + SIDE_RIGHT;
}
}
else
{
/* Top or bottom side */
if (ev->y < c->height / 2)
{
part = 4 + SIDE_TOP;
}
else
{
part = 4 + SIDE_BOTTOM;
}
}
Olivier Fourdan
committed
edgeButton (c, part, 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);
}
/* Clear timeout */
clear_timeout ();
Olivier Fourdan
committed
clientRaise (c, None);
}
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);
}
/* Clear timeout */
clear_timeout ();
Olivier Fourdan
committed
clientRaise (c, None);
}
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);
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
/* 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)
clientPassGrabMouseButton (c);
if ((screen_info->params->raise_with_any_button) || (ev->button == Button1))
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))
/* Clear timeout */
clear_timeout ();
Olivier Fourdan
committed
clientRaise (c, None);
Olivier Fourdan
committed
replay = TRUE;
}
if (replay)
{
XAllowEvents (display_info->dpy, ReplayPointer, ev->time);
XAllowEvents (display_info->dpy, SyncPointer, ev->time);
return;
}
/*
The event did not occur in one of our known good client...
Get the screen structure from the root of the event.
*/
screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
if (!screen_info)
{
return;
if ((ev->window == screen_info->xroot) && (screen_info->params->scroll_workspaces)
&& ((ev->button == Button4) || (ev->button == Button5)))
Olivier Fourdan
committed
}
XUngrabPointer (display_info->dpy, CurrentTime);
Olivier Fourdan
committed
XSendEvent (display_info->dpy, screen_info->xfwm4_win, FALSE, SubstructureNotifyMask, (XEvent *) ev);
handleButtonRelease (DisplayInfo *display_info, XButtonEvent * ev)
TRACE ("entering handleButtonRelease");
Olivier Fourdan
committed
#if CHECK_BUTTON_TIME
Olivier Fourdan
committed
/* Avoid treating the same event twice */
if (!check_button_time (ev))
{
TRACE ("ignoring ButtonRelease event because it has been already handled");
return;
}
Olivier Fourdan
committed
#endif
Olivier Fourdan
committed
/* Get the screen structure from the root of the event */
screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
if (!screen_info)
{
return;
}
Olivier Fourdan
committed
XSendEvent (display_info->dpy, screen_info->xfwm4_win, FALSE, SubstructureNotifyMask, (XEvent *) ev);
handleDestroyNotify (DisplayInfo *display_info, XDestroyWindowEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering handleDestroyNotify");
TRACE ("DestroyNotify on window (0x%lx)", ev->window);
screen_info = myDisplayGetScreenFromSystray (display_info, ev->window);
if (screen_info)
/* systray window is gone */
screen_info->systray = None;
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
TRACE ("DestroyNotify for \"%s\" (0x%lx)", c->name, c->window);
clientUnframe (c, FALSE);
}
}
handleMapRequest (DisplayInfo *display_info, XMapRequestEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering handleMapRequest");
TRACE ("MapRequest on window (0x%lx)", ev->window);
if (ev->window == None)
TRACE ("Mapping None ???");
return;
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
ScreenInfo *screen_info = c->screen_info;
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MAP_PENDING))
{
TRACE ("Ignoring MapRequest on window (0x%lx)", ev->window);
return;
}
clientShow (c, TRUE);
if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY) ||
(c->win_workspace == screen_info->current_ws))
clientFrame (display_info, ev->window, FALSE);
handleMapNotify (DisplayInfo *display_info, XMapEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("MapNotify on window (0x%lx)", ev->window);
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (c)
{
TRACE ("MapNotify for \"%s\" (0x%lx)", c->name, c->window);
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MAP_PENDING))
FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_MAP_PENDING);
compositorMapWindow (display_info, c->frame);
else if (myDisplayGetScreenFromRoot (display_info, ev->event))
{
compositorMapWindow (display_info, ev->window);
handleUnmapNotify (DisplayInfo *display_info, XUnmapEvent * ev)
Client *c = NULL;
TRACE ("entering handleUnmapNotify");
TRACE ("UnmapNotify on window (0x%lx)", ev->window);
if (ev->from_configure)
{
TRACE ("Ignoring UnmapNotify caused by parent's resize");
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (screen_info && (ev->event != ev->window) && (ev->event != screen_info->xroot || !ev->send_event))
TRACE ("handleUnmapNotify (): Event ignored");
return;
}
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (c)
{
TRACE ("UnmapNotify for \"%s\" (0x%lx)", c->name, c->window);
Olivier Fourdan
committed
TRACE ("ignore_unmap for \"%s\" is %i", c->name, c->ignore_unmap);
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MAP_PENDING))
* This UnmapNotify event is caused by reparenting
* so we just ignore it, so the window won't return
* to withdrawn state by mistake.
*/
TRACE ("Client \"%s\" is not mapped, event ignored", c->name);
compositorUnmapWindow (display_info, c->frame);
/*
* ICCCM spec states that a client wishing to switch
* to WithdrawnState should send a synthetic UnmapNotify
* with the event field set to root if the client window
* is already unmapped.
* Therefore, bypass the ignore_unmap counter and
* unframe the client.
*/
Olivier Fourdan
committed
if ((ev->event == screen_info->xroot) && (ev->send_event))
{
TRACE ("ICCCM UnmapNotify for \"%s\"", c->name);
clientUnframe (c, FALSE);
return;
}
if (c->ignore_unmap)
{
c->ignore_unmap--;
Olivier Fourdan
committed
TRACE ("ignore_unmap for \"%s\" is now %i",
c->name, c->ignore_unmap);
}
else
{
TRACE ("unmapping \"%s\" as ignore_unmap is %i",
c->name, c->ignore_unmap);
clientUnframe (c, FALSE);
compositorUnmapWindow (display_info, ev->window);
handleConfigureNotify (DisplayInfo *display_info, XConfigureEvent * ev)
screen_info = myDisplayGetScreenFromRoot (display_info, ev->window);
if (!screen_info)
{
return;
}
if (display_info->have_xrandr)
XRRUpdateConfiguration ((XEvent *) ev);
#endif
}
else
Olivier Fourdan
committed
TRACE ("ConfigureNotify on the screen_info->xroot win (0x%lx)", ev->window);
screen_info->xscreen->width = ev->width;
screen_info->xscreen->height = ev->height;
setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
gdk_screen_get_width (screen_info->gscr),
gdk_screen_get_height (screen_info->gscr),
screen_info->margins);
placeSidewalks (screen_info, screen_info->params->wrap_workspaces);
clientScreenResize (screen_info);
handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering handleConfigureRequest");
TRACE ("ConfigureRequest on window (0x%lx)", ev->window);
while (XCheckTypedWindowEvent (display_info->dpy, ev->window, ConfigureRequest, &otherEvent))
/* Update the display time */
myDisplayUpdateCurentTime (display_info, &otherEvent);
if (otherEvent.xconfigurerequest.value_mask == ev->value_mask)
{
ev = &otherEvent.xconfigurerequest;
}
else
{
XPutBackEvent (display_info->dpy, &otherEvent);
wc.x = ev->x;
wc.y = ev->y;
wc.width = ev->width;
wc.height = ev->height;
wc.sibling = ev->above;
wc.stack_mode = ev->detail;
wc.border_width = ev->border_width;
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (!c)
{
/* Some app tend or try to manipulate the wm frame to achieve fullscreen mode */
c = myDisplayGetClientFromWindow (display_info, ev->window, FRAME);
TRACE ("client %s (0x%lx) is attempting to manipulate its frame!", c->name, c->window);
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
if (ev->value_mask & CWX)
{
wc.x += frameLeft (c);
}
if (ev->value_mask & CWY)
{
wc.y += frameTop (c);
}
if (ev->value_mask & CWWidth)
{
wc.width -= frameLeft (c) + frameRight (c);
}
if (ev->value_mask & CWHeight)
{
wc.height -= frameTop (c) + frameBottom (c);
}
/* We don't allow changing stacking order by accessing the frame
window because that would break the layer management in xfwm4
*/
ev->value_mask &= ~(CWSibling | CWStackMode);
}
}
if (c)
{
gboolean constrained = FALSE;
TRACE ("handleConfigureRequest managed window \"%s\" (0x%lx)", c->name, c->window);
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING))
{
/* Sorry, but it's not the right time for configure request */
return;
}
if (c->type == WINDOW_DESKTOP)
{
/* Ignore stacking request for DESKTOP windows */
ev->value_mask &= ~(CWSibling | CWStackMode);
}
clientCoordGravitate (c, APPLY, &wc.x, &wc.y);
if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
Olivier Fourdan
committed
GdkRectangle rect;
gint monitor_nbr;
int cx, cy;
/* size request from fullscreen windows get fullscreen */
cx = frameX (c) + (frameWidth (c) / 2);
cy = frameY (c) + (frameHeight (c) / 2);
monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
Olivier Fourdan
committed
wc.x = rect.x;
wc.y = rect.y;
wc.width = rect.width;
wc.height = rect.height;
/* Clean up buggy requests that set all flags */
if ((ev->value_mask & CWX) && (wc.x == c->x))
{
ev->value_mask &= ~CWX;
}
if ((ev->value_mask & CWY) && (wc.y == c->y))
{
ev->value_mask &= ~CWY;
}
if ((ev->value_mask & CWWidth) && (wc.width == c->width))
{
ev->value_mask &= ~CWWidth;
}
if ((ev->value_mask & CWHeight) && (wc.height == c->height))
{
ev->value_mask &= ~CWHeight;
}
/* Still a move/resize after cleanup? */
if (ev->value_mask & (CWX | CWY | CWWidth | CWHeight))
{
if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
{
clientRemoveMaximizeFlag (c);
}
constrained = TRUE;
}
if (ev->value_mask & CWStackMode)
{
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
#if 0
/* Let's say that if the client performs a XRaiseWindow, we show the window if hidden */
if ((ev->value_mask & CWStackMode) && (wc.stack_mode == Above))
{
if ((c->win_workspace == screen_info->current_ws) ||
(FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)))
if (FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED))
{
clientShow (c, TRUE);
}
}
}
Olivier Fourdan
committed
#endif
clientConfigure (c, &wc, ev->value_mask, (constrained ? CFG_CONSTRAINED : 0) | CFG_REQUEST);
TRACE ("unmanaged configure request for win 0x%lx", ev->window);
XConfigureWindow (display_info->dpy, ev->window, ev->value_mask, &wc);
handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
static Time lastresist = (Time) 0;
Olivier Fourdan
committed
Client *c = NULL;
Olivier Fourdan
committed
ScreenInfo *screen_info = NULL;
gboolean warp_pointer = FALSE;
TRACE ("entering handleEnterNotify");
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab)
|| (ev->detail > NotifyNonlinearVirtual))
/* We're not interested in such notifications */
return;
TRACE ("EnterNotify on window (0x%lx)", ev->window);
c = myDisplayGetClientFromWindow (display_info, ev->window, FRAME);
if (c)
screen_info = c->screen_info;
if (!(screen_info->params->click_to_focus) && clientAcceptFocus (c))
TRACE ("EnterNotify window is \"%s\"", c->name);
if (!(c->type & (WINDOW_DOCK | WINDOW_DESKTOP)))
Olivier Fourdan
committed
{
clientSetFocus (c->screen_info, c, ev->time, NO_FOCUS_FLAG);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
/* No need to process the event any further */
return;
}
/* The event was not for a client window */
if (display_info->nb_screens > 1)
{
/* Wrap workspace/wrap windows is disabled with multiscreen */
return;
}
Olivier Fourdan
committed
/* 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)
{
int msx, msy, maxx, maxy;
int rx, ry;
msx = ev->x_root;
msy = ev->y_root;
maxx = gdk_screen_get_width (screen_info->gscr) - 1;
maxy = gdk_screen_get_height (screen_info->gscr) - 1;
warp_pointer = FALSE;
if ((msx == 0) || (msx == maxx))
Olivier Fourdan
committed
{
if ((ev->time - lastresist) > 250) /* ms */
{
edge_scroll_x = 0;
}
else
{
edge_scroll_x++;
}
if (msx == 0)
{
lastresist = ev->time;
}
if ((msy == 0) || (msy == maxy))
{
if ((ev->time - lastresist) > 250) /* ms */
{
edge_scroll_y = 0;
}
else
{
edge_scroll_y++;
}
if (msy == 0)
{
}
else
{
lastresist = ev->time;
}
Olivier Fourdan
committed
if (edge_scroll_x > screen_info->params->wrap_resistance)
{
Olivier Fourdan
committed
edge_scroll_x = 0;
Olivier Fourdan
committed
{
if (workspaceMove (screen_info, 0, -1, NULL))
{
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
if (workspaceMove (screen_info, 0, 1, NULL))
{
Olivier Fourdan
committed
}
warp_pointer = TRUE;
}
if (edge_scroll_y > screen_info->params->wrap_resistance)
{
edge_scroll_y = 0;
Olivier Fourdan
committed
{
if (workspaceMove (screen_info, -1, 0, NULL))
{
}
}
{
if (workspaceMove (screen_info, 1, 0, NULL))
{
}
}
warp_pointer = TRUE;
}
if (warp_pointer)
{
XWarpPointer (display_info->dpy, None, None, 0, 0, 0, 0, rx, ry);
XFlush (display_info->dpy);
Olivier Fourdan
committed
}
handleLeaveNotify (DisplayInfo *display_info, XCrossingEvent * ev)
Olivier Fourdan
committed
{
TRACE ("entering handleLeaveNotify");
Olivier Fourdan
committed
}
handleFocusIn (DisplayInfo *display_info, XFocusChangeEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
Client *last_raised = NULL;
TRACE ("entering handleFocusIn");
Olivier Fourdan
committed
TRACE ("handleFocusIn (0x%lx) mode = %s",
ev->window,
(ev->mode == NotifyNormal) ?
"NotifyNormal" :
(ev->mode == NotifyWhileGrabbed) ?
"NotifyWhileGrabbed" :
"(unknown)");
Olivier Fourdan
committed
TRACE ("handleFocusIn (0x%lx) detail = %s",
ev->window,
(ev->detail == NotifyAncestor) ?
"NotifyAncestor" :
(ev->detail == NotifyVirtual) ?
"NotifyVirtual" :
(ev->detail == NotifyInferior) ?
"NotifyInferior" :
(ev->detail == NotifyNonlinear) ?
"NotifyNonlinear" :
(ev->detail == NotifyNonlinearVirtual) ?
"NotifyNonlinearVirtual" :
(ev->detail == NotifyPointer) ?
"NotifyPointer" :
(ev->detail == NotifyPointerRoot) ?
"NotifyPointerRoot" :
(ev->detail == NotifyDetailNone) ?
"NotifyDetailNone" :
"(unknown)");
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (screen_info && (ev->window == screen_info->xroot) && (ev->mode == NotifyNormal) &&
Olivier Fourdan
committed
(ev->detail == NotifyDetailNone))
{
/* Handle focus transition to root (means that an unknown
window has vanished and the focus is returned to the root
Olivier Fourdan
committed
*/
c = clientGetFocus ();
if (c)
{
clientSetFocus (c->screen_info, c, myDisplayGetCurrentTime (display_info), FOCUS_FORCE);
Olivier Fourdan
committed
}
return;
}
if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab) ||
Olivier Fourdan
committed
(ev->detail > NotifyNonlinearVirtual))
{
/* We're not interested in such notifications */
return;
}
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
TRACE ("FocusIn on window (0x%lx)", ev->window);
TRACE ("focus set to \"%s\" (0x%lx)", c->name, c->window);
clientUpdateFocus (screen_info, c, FOCUS_SORT);
last_raised = clientGetLastRaise (screen_info);
if ((screen_info->params->click_to_focus) &&
(screen_info->params->raise_on_click) &&
(last_raised != NULL) && (c != last_raised))
Olivier Fourdan
committed
clientRaise (c, None);
if (screen_info->params->raise_on_focus)
handleFocusOut (DisplayInfo *display_info, XFocusChangeEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
Olivier Fourdan
committed
TRACE ("entering handleFocusOut");
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
TRACE ("handleFocusOut (0x%lx) mode = %s",
ev->window,
(ev->mode == NotifyNormal) ?
"NotifyNormal" :
(ev->mode == NotifyWhileGrabbed) ?
"NotifyWhileGrabbed" :
"(unknown)");
TRACE ("handleFocusOut (0x%lx) detail = %s",
ev->window,
(ev->detail == NotifyAncestor) ?
"NotifyAncestor" :
(ev->detail == NotifyVirtual) ?
"NotifyVirtual" :
(ev->detail == NotifyInferior) ?
"NotifyInferior" :
(ev->detail == NotifyNonlinear) ?
"NotifyNonlinear" :
(ev->detail == NotifyNonlinearVirtual) ?
"NotifyNonlinearVirtual" :
(ev->detail == NotifyPointer) ?
"NotifyPointer" :
(ev->detail == NotifyPointerRoot) ?
"NotifyPointerRoot" :
(ev->detail == NotifyDetailNone) ?
"NotifyDetailNone" :
"(unknown)");
if ((ev->mode == NotifyNormal)
&& ((ev->detail == NotifyNonlinear)
|| (ev->detail == NotifyNonlinearVirtual)))
Olivier Fourdan
committed
{
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
TRACE ("FocusOut on window (0x%lx)", ev->window);
Olivier Fourdan
committed
if ((c) && (c == clientGetFocus ()))
{
TRACE ("focus lost from \"%s\" (0x%lx)", c->name, c->window);
Olivier Fourdan
committed
clientPassGrabMouseButton (NULL);
clientUpdateFocus (c->screen_info, NULL, NO_FOCUS_FLAG);
/* Clear timeout */
clear_timeout ();
}
Olivier Fourdan
committed
}
handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
Window w = None;
char *names;
int length;
TRACE ("entering handlePropertyNotify");
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (c)
{
screen_info = c->screen_info;
if (ev->atom == XA_WM_NORMAL_HINTS)
{
TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NORMAL_HINTS notify", c->name, c->window);
else if ((ev->atom == XA_WM_NAME) || (ev->atom == display_info->atoms[NET_WM_NAME]))
Benedikt Meurer
committed
TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NAME notify", c->name, c->window);
if (c->name)
{
free (c->name);
}
getWindowName (display_info, c->window, &c->name);
FLAG_SET (c->flags, CLIENT_FLAG_NAME_CHANGED);
frameDraw (c, TRUE, FALSE);
}
else if (ev->atom == display_info->atoms[MOTIF_WM_HINTS])
TRACE ("client \"%s\" (0x%lx) has received a motif_wm_hints notify", c->name, c->window);
}
else if (ev->atom == XA_WM_HINTS)
{
TRACE ("client \"%s\" (0x%lx) has received a XA_WM_HINTS notify", c->name, c->window);
c->wmhints = XGetWMHints (display_info->dpy, c->window);
if (c->wmhints)
{
if (c->wmhints->flags & WindowGroupHint)
{
c->group_leader = c->wmhints->window_group;
}
if ((c->wmhints->flags & IconPixmapHint) && (screen_info->params->show_app_icon))
{
clientUpdateIcon (c);
frameDraw (c, TRUE, FALSE);
}
else if (ev->atom == display_info->atoms[WM_PROTOCOLS])
TRACE ("client \"%s\" (0x%lx) has received a wm_protocols notify", c->name, c->window);
else if (ev->atom == display_info->atoms[WM_TRANSIENT_FOR])
{
TRACE ("client \"%s\" (0x%lx) has received a wm_transient_for notify", c->name, c->window);
getTransientFor (display_info, c->screen_info->xroot, c->window, &w);
if (clientCheckTransientWindow (c, w))
{
c->transient_for = w;
Olivier Fourdan
committed
clientRaise (c, w);
}
}
else if (ev->atom == display_info->atoms[WIN_HINTS])
TRACE ("client \"%s\" (0x%lx) has received a win_hints notify", c->name, c->window);
getHint (display_info, c->window, WIN_HINTS, (long *) &c->win_hints);
else if (ev->atom == display_info->atoms[NET_WM_WINDOW_TYPE])
TRACE ("client \"%s\" (0x%lx) has received a net_wm_window_type notify", c->name, c->window);
clientGetNetWmType (c);
frameDraw (c, TRUE, FALSE);
}
else if ((ev->atom == display_info->atoms[NET_WM_STRUT]) ||
(ev->atom == display_info->atoms[NET_WM_STRUT_PARTIAL]))
TRACE ("client \"%s\" (0x%lx) has received a net_wm_strut notify", c->name, c->window);
clientGetNetStruts (c);
}
else if (ev->atom == display_info->atoms[WM_COLORMAP_WINDOWS])
TRACE ("client \"%s\" (0x%lx) has received a wm_colormap_windows notify", c->name, c->window);
clientUpdateColormaps (c);
if (c == clientGetFocus ())
{
clientInstallColormaps (c);
}
}
else if (ev->atom == display_info->atoms[NET_WM_USER_TIME])
Olivier Fourdan
committed
{
TRACE ("client \"%s\" (0x%lx) has received a net_wm_user_time notify", c->name, c->window);
if (getNetWMUserTime (display_info, c->window, &c->user_time))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
FLAG_SET (c->flags, CLIENT_FLAG_HAS_USER_TIME);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
}
else if (ev->atom == display_info->atoms[NET_WM_WINDOW_OPACITY])
TRACE ("client \"%s\" (0x%lx) has received a net_wm_opacity notify", c->name, c->window);
if (!getOpacity (display_info, c->window, &c->opacity))
compositorWindowSetOpacity (display_info, c->frame, c->opacity);
else if ((screen_info->params->show_app_icon) &&
((ev->atom == display_info->atoms[NET_WM_ICON]) ||
(ev->atom == display_info->atoms[KWM_WIN_ICON])))
{
clientUpdateIcon (c);
frameDraw (c, TRUE, FALSE);
}
#ifdef HAVE_STARTUP_NOTIFICATION
else if (ev->atom == display_info->atoms[NET_STARTUP_ID])
{
if (c->startup_id)
{
free (c->startup_id);
c->startup_id = NULL;
}
getWindowStartupId (display_info, c->window, &c->startup_id);
#endif
return;
}
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (!screen_info)
{
return;
if (ev->atom == display_info->atoms[NET_DESKTOP_NAMES])
{
TRACE ("root has received a net_desktop_names notify");
if (getUTF8String (display_info, screen_info->xroot, NET_DESKTOP_NAMES, &names, &length))
{
workspaceSetNames (screen_info, names, length);
}
}
else if (ev->atom == display_info->atoms[GNOME_PANEL_DESKTOP_AREA])
TRACE ("root has received a gnome_panel_desktop_area notify");
getGnomeDesktopMargins (display_info, screen_info->xroot, screen_info->gnome_margins);
else if (ev->atom == display_info->atoms[NET_DESKTOP_LAYOUT])
Olivier Fourdan
committed
{
TRACE ("root has received a net_desktop_layout notify");
getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
Olivier Fourdan
committed
placeSidewalks(screen_info, screen_info->params->wrap_workspaces);
Olivier Fourdan
committed
}
handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering handleClientMessage");
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (c)
{
if ((ev->message_type == display_info->atoms[WM_CHANGE_STATE]) && (ev->format == 32) && (ev->data.l[0] == IconicState))
TRACE ("client \"%s\" (0x%lx) has received a wm_change_state event", c->name, c->window);
if (!FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED) && CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
}
else if ((ev->message_type == display_info->atoms[WIN_STATE]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a win_state event", c->name, c->window);
clientUpdateWinState (c, ev);
}
else if ((ev->message_type == display_info->atoms[WIN_LAYER]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a win_layer event", c->name, c->window);
if ((ev->data.l[0] != c->win_layer) && !is_transient)
{
clientSetLayer (c, ev->data.l[0]);
}
}
else if ((ev->message_type == display_info->atoms[WIN_WORKSPACE]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a win_workspace event", c->name, c->window);
if ((ev->data.l[0] != c->win_workspace) && !is_transient)
{
clientSetWorkspace (c, ev->data.l[0], TRUE);
}
}
else if ((ev->message_type == display_info->atoms[NET_WM_DESKTOP]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a net_wm_desktop event", c->name, c->window);
{
if (ev->data.l[0] == ALL_WORKSPACES)
{
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_STICK) && !FLAG_TEST (c->flags, CLIENT_FLAG_STICKY))
{
clientStick (c, TRUE);
frameDraw (c, FALSE, FALSE);
}
}
else
{
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_STICK) && FLAG_TEST (c->flags, CLIENT_FLAG_STICKY))
{
clientUnstick (c, TRUE);
frameDraw (c, FALSE, FALSE);
}
if (ev->data.l[0] != c->win_workspace)
{
clientSetWorkspace (c, ev->data.l[0], TRUE);
}
}
}
}
else if ((ev->message_type == display_info->atoms[NET_CLOSE_WINDOW]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a net_close_window event", c->name, c->window);
clientClose (c);
}
else if ((ev->message_type == display_info->atoms[NET_WM_STATE]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a net_wm_state event", c->name, c->window);
clientUpdateNetState (c, ev);
}
else if ((ev->message_type == display_info->atoms[NET_WM_MOVERESIZE]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a net_wm_moveresize event", c->name, c->window);
g_warning ("Operation not supported (yet)");
else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
TRACE ("client \"%s\" (0x%lx) has received a net_active_window event", c->name, c->window);
Time current = myDisplayGetCurrentTime (screen_info->display_info);
Time ev_time = (Time) ev->data.l[1];
/* We are simply ignoring XServer time wraparound here */
TRACE ("Time of event received is %u, current XServer time is %u", ev_time, current);
if ((ev_time != (Time) 0) && (ev_time <= current))
{
FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
clientSetNetState (c);
}
else
{
clientSetWorkspace (c, screen_info->current_ws, TRUE);
clientShow (c, TRUE);
clientRaise (c, None);
clientSetFocus (screen_info, c, (Time) ev_time, NO_FOCUS_FLAG);
}
clientSetWorkspace (c, screen_info->current_ws, TRUE);
clientShow (c, TRUE);
clientRaise (c, None);
clientSetFocus (screen_info, c, CurrentTime, NO_FOCUS_FLAG);
}
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
Olivier Fourdan
committed
{
TRACE ("client \"%s\" (0x%lx) has received a net_request_frame_extents event", c->name, c->window);
setNetFrameExtents (display_info, c->window, frameTop (c), frameLeft (c),
frameRight (c), frameBottom (c));
Olivier Fourdan
committed
}
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (!screen_info)
{
return;
}
if (((ev->message_type == display_info->atoms[WIN_WORKSPACE]) ||
(ev->message_type == display_info->atoms[NET_CURRENT_DESKTOP])) && (ev->format == 32))
Olivier Fourdan
committed
TRACE ("root has received a win_workspace or a net_current_desktop event %i", ev->data.l[0]);
if ((ev->data.l[0] >= 0) && (ev->data.l[0] < screen_info->workspace_count) && (ev->data.l[0] != screen_info->current_ws))
Olivier Fourdan
committed
workspaceSwitch (screen_info, ev->data.l[0], NULL, TRUE);
else if (((ev->message_type == display_info->atoms[WIN_WORKSPACE_COUNT]) ||
(ev->message_type == display_info->atoms[NET_NUMBER_OF_DESKTOPS])) && (ev->format == 32))
{
TRACE ("root has received a win_workspace_count event");
if (ev->data.l[0] != screen_info->workspace_count)
workspaceSetCount (screen_info, ev->data.l[0]);
getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
else if ((ev->message_type == display_info->atoms[MANAGER]) && (ev->data.l[1] == screen_info->net_system_tray_selection) && (ev->format == 32))
{
TRACE ("root has received a net_system_tray_manager event");
screen_info->systray = getSystrayWindow (display_info, screen_info->net_system_tray_selection);
else if ((ev->message_type == display_info->atoms[NET_SHOWING_DESKTOP]) && (ev->format == 32))
{
TRACE ("root has received a net_showing_desktop event");
clientToggleShowDesktop (screen_info, ev->data.l[0]);
setHint (display_info, screen_info->xroot, NET_SHOWING_DESKTOP, ev->data.l[0]);
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
Olivier Fourdan
committed
{
TRACE ("window (0x%lx) has received a net_request_frame_extents event", c->name, ev->window);
/* Size estimate from the decoration extents */
setNetFrameExtents (display_info, ev->window,
Olivier Fourdan
committed
frameDecorationTop (screen_info),
frameDecorationLeft (screen_info),
frameDecorationRight (screen_info),
frameDecorationBottom (screen_info));
}
TRACE ("unidentified client message for window 0x%lx", ev->window);
handleShape (DisplayInfo *display_info, XShapeEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
TRACE ("entering handleShape");
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if (ev->kind == ShapeBounding)
{
if ((ev->shaped) && !FLAG_TEST (c->flags, CLIENT_FLAG_HAS_SHAPE))
{
FLAG_SET (c->flags, CLIENT_FLAG_HAS_SHAPE);
}
else if (!(ev->shaped) && FLAG_TEST (c->flags, CLIENT_FLAG_HAS_SHAPE))
{
FLAG_UNSET (c->flags, CLIENT_FLAG_HAS_SHAPE);
}
}
frameDraw (c, FALSE, TRUE);
handleColormapNotify (DisplayInfo *display_info, XColormapEvent * ev)
Olivier Fourdan
committed
Client *c = NULL;
Olivier Fourdan
committed
TRACE ("entering handleColormapNotify");
Olivier Fourdan
committed
c = myDisplayGetClientFromWindow (display_info, ev->window, WINDOW);
if ((c) && (ev->window == c->window) && (ev->new))
if (c == clientGetFocus ())
{
clientInstallColormaps (c);
}
static void
handleMappingNotify (DisplayInfo *display_info, XMappingEvent * ev)
{
GSList *screens;
TRACE ("entering handleMappingNotify");
/* Refreshes the stored modifier and keymap information */
XRefreshKeyboardMapping (ev);
/* Update internal modifiers masks if necessary */
if (ev->request == MappingModifier)
{
TRACE ("handleMappingNotify: modifiers mapping has changed");
initModifiers (display_info->dpy);
}
/* Regrab all keys if the notify is for keyboard (ie not pointer) */
if (ev->request != MappingPointer)
{
TRACE ("handleMappingNotify: Regrab keys");
for (screens = display_info->screens; screens; screens = g_slist_next (screens))
{
ScreenInfo *screen_info = (ScreenInfo *) screens->data;
/* We need to reload all the settings to recompute the key bindings... */
loadSettings (screen_info);
/* ...then update all frames grabs... */
clientUpdateAllFrames (screen_info, UPDATE_BUTTON_GRABS | UPDATE_KEY_GRABS);
/* ...and regrab the keys we have on the root win... */
myScreenGrabKeys (screen_info);
static void
handleEvent (DisplayInfo *display_info, XEvent * ev)
TRACE ("entering handleEvent");
/* Update the display time */
myDisplayUpdateCurentTime (display_info, ev);
sn_process_event (ev);
case MotionNotify:
handleMotionNotify (display_info, (XMotionEvent *) ev);
break;
case KeyPress:
handleKeyPress (display_info, (XKeyEvent *) ev);
break;
case ButtonPress:
handleButtonPress (display_info, (XButtonEvent *) ev);
break;
case ButtonRelease:
handleButtonRelease (display_info, (XButtonEvent *) ev);
break;
case DestroyNotify:
handleDestroyNotify (display_info, (XDestroyWindowEvent *) ev);
break;
case UnmapNotify:
handleUnmapNotify (display_info, (XUnmapEvent *) ev);
break;
case MapRequest:
handleMapRequest (display_info, (XMapRequestEvent *) ev);
handleMapNotify (display_info, (XMapEvent *) ev);
handleConfigureNotify (display_info, (XConfigureEvent *) ev);
case ConfigureRequest:
handleConfigureRequest (display_info, (XConfigureRequestEvent *) ev);
break;
case EnterNotify:
handleEnterNotify (display_info, (XCrossingEvent *) ev);
break;
case LeaveNotify:
handleLeaveNotify (display_info, (XCrossingEvent *) ev);
break;
case FocusIn:
handleFocusIn (display_info, (XFocusChangeEvent *) ev);
break;
case FocusOut:
handleFocusOut (display_info, (XFocusChangeEvent *) ev);
break;
case PropertyNotify:
handlePropertyNotify (display_info, (XPropertyEvent *) ev);
break;
case ClientMessage:
handleClientMessage (display_info, (XClientMessageEvent *) ev);
break;
case ColormapNotify:
handleColormapNotify (display_info, (XColormapEvent *) ev);
case MappingNotify:
handleMappingNotify (display_info, (XMappingEvent *) ev);
break;
if ((display_info->have_shape) && (ev->type == display_info->shape_event_base))
handleShape (display_info, (XShapeEvent *) ev);
if (!gdk_events_pending () && !XPending (display_info->dpy))
if (xfwm4_reload)
xfwm4_reload = FALSE;
else if (xfwm4_quit)
{
gtk_main_quit ();
}
Olivier Fourdan
committed
XfceFilterStatus
xfwm4_event_filter (XEvent * xevent, gpointer data)
DisplayInfo *display_info = (DisplayInfo *) data;
TRACE ("entering xfwm4_event_filter");
TRACE ("leaving xfwm4_event_filter");
/* GTK specific stuff */
menu_callback (Menu * menu, MenuOp op, Window xid, gpointer menu_data, gpointer item_data)
Olivier Fourdan
committed
TRACE ("entering menu_callback");
Loading
Loading full blame...