Newer
Older
clientSetWorkspace (c, (guint) ev->data.l[0], TRUE);
else if ((ev->message_type == display_info->atoms[NET_CLOSE_WINDOW]) && (ev->format == 32))
Olivier Fourdan
committed
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))
Olivier Fourdan
committed
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))
Olivier Fourdan
committed
TRACE ("client \"%s\" (0x%lx) has received a NET_WM_MOVERESIZE event", c->name, c->window);
else if ((ev->message_type == display_info->atoms[NET_MOVERESIZE_WINDOW]) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a NET_MOVERESIZE_WINDOW event", c->name, c->window);
clientNetMoveResizeWindow (c, ev);
}
else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
Olivier Fourdan
committed
TRACE ("client \"%s\" (0x%lx) has received a NET_ACTIVE_WINDOW event", c->name, c->window);
Olivier Fourdan
committed
clientHandleNetActiveWindow (c, (guint32) ev->data.l[1], (gboolean) (ev->data.l[0] == 1));
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
Olivier Fourdan
committed
{
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
}
else if (ev->message_type == display_info->atoms[NET_WM_FULLSCREEN_MONITORS])
{
TRACE ("client \"%s\" (0x%lx) has received a NET_WM_FULLSCREEN_MONITORS event", c->name, c->window);
clientSetFullscreenMonitor (c, (gint) ev->data.l[0], (gint) ev->data.l[1],
(gint) ev->data.l[2], (gint) ev->data.l[3]);
}
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (!screen_info)
{
return status;
status = EVENT_FILTER_REMOVE;
if ((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 %li", ev->data.l[0]);
if ((ev->data.l[0] >= 0) && (ev->data.l[0] < (long) screen_info->workspace_count) &&
(ev->data.l[0] != (long) screen_info->current_ws))
workspaceSwitch (screen_info, ev->data.l[0], NULL, TRUE,
myDisplayGetTime (display_info, (guint32) ev->data.l[1]));
else if ((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] != (long) 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[NET_SHOWING_DESKTOP]) && (ev->format == 32))
Olivier Fourdan
committed
TRACE ("root has received a NET_SHOWING_DESKTOP event");
Olivier Fourdan
committed
screen_info->show_desktop = (ev->data.l[0] != 0);
clientToggleShowDesktop (screen_info);
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
{
Olivier Fourdan
committed
TRACE ("window (0x%lx) has received a NET_REQUEST_FRAME_EXTENTS event", ev->window);
Olivier Fourdan
committed
/* 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));
}
Olivier Fourdan
committed
else if ((ev->message_type == display_info->atoms[MANAGER]) && (ev->format == 32))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
Atom selection;
Olivier Fourdan
committed
TRACE ("window (0x%lx) has received a MANAGER event", ev->window);
selection = (Atom) ev->data.l[1];
Olivier Fourdan
committed
#ifdef ENABLE_KDE_SYSTRAY_PROXY
if (selection == screen_info->net_system_tray_selection)
{
TRACE ("root has received a NET_SYSTEM_TRAY_MANAGER selection event");
screen_info->systray = getSystrayWindow (display_info, screen_info->net_system_tray_selection);
}
else
#endif
if (myScreenCheckWMAtom (screen_info, selection))
{
TRACE ("root has received a WM_Sn selection event");
display_info->quit = TRUE;
}
Olivier Fourdan
committed
}
else if (ev->message_type == display_info->atoms[WM_PROTOCOLS])
{
if ((Atom) ev->data.l[0] == display_info->atoms[NET_WM_PING])
{
TRACE ("root has received a NET_WM_PING (pong) event\n");
clientReceiveNetWMPong (screen_info, (guint32) ev->data.l[1]);
TRACE ("unidentified client message for window 0x%lx", ev->window);
return status;
Olivier Fourdan
committed
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
static eventFilterStatus
handleSelectionClear (DisplayInfo *display_info, XSelectionClearEvent * ev)
{
eventFilterStatus status;
ScreenInfo *screen_info;
TRACE ("entering handleSelectionClear");
status = EVENT_FILTER_PASS;
screen_info = myDisplayGetScreenFromWindow (display_info, ev->window);
if (screen_info)
{
if (myScreenCheckWMAtom (screen_info, ev->selection))
{
TRACE ("root has received a WM_Sn selection event");
display_info->quit = TRUE;
status = EVENT_FILTER_REMOVE;
}
}
return status;
}
static eventFilterStatus
handleShape (DisplayInfo *display_info, XShapeEvent * ev)
Olivier Fourdan
committed
gboolean update;
TRACE ("entering handleShape");
c = myDisplayGetClientFromWindow (display_info, ev->window, SEARCH_WINDOW);
Olivier Fourdan
committed
update = FALSE;
if (ev->kind == ShapeInput)
{
frameSetShapeInput (c);
update = TRUE;
}
else if (ev->kind == ShapeBounding)
{
if ((ev->shaped) && !FLAG_TEST (c->flags, CLIENT_FLAG_HAS_SHAPE))
{
Olivier Fourdan
committed
update = TRUE;
FLAG_SET (c->flags, CLIENT_FLAG_HAS_SHAPE);
clientGetMWMHints (c, update);
}
else if (!(ev->shaped) && FLAG_TEST (c->flags, CLIENT_FLAG_HAS_SHAPE))
{
Olivier Fourdan
committed
update = TRUE;
FLAG_UNSET (c->flags, CLIENT_FLAG_HAS_SHAPE);
clientGetMWMHints (c, update);
Olivier Fourdan
committed
if (!update)
{
Olivier Fourdan
committed
}
return EVENT_FILTER_REMOVE;
static eventFilterStatus
handleColormapNotify (DisplayInfo *display_info, XColormapEvent * ev)
Olivier Fourdan
committed
TRACE ("entering handleColormapNotify");
Olivier Fourdan
committed
c = myDisplayGetClientFromWindow (display_info, ev->window, SEARCH_WINDOW);
if ((c) && (ev->window == c->window) && (ev->new))
if (c == clientGetFocus ())
{
clientInstallColormaps (c);
}
return EVENT_FILTER_REMOVE;
return EVENT_FILTER_PASS;
Olivier Fourdan
committed
static eventFilterStatus
handleReparentNotify (DisplayInfo *display_info, XReparentEvent * ev)
{
TRACE ("entering handleReparentNotify, 0x%lx reparented in 0x%lx", ev->window, ev->parent);
return EVENT_FILTER_PASS;
}
static eventFilterStatus
handleXSyncAlarmNotify (DisplayInfo *display_info, XSyncAlarmNotifyEvent * ev)
{
Client *c;
TRACE ("entering handleXSyncAlarmNotify");
Olivier Fourdan
committed
if (!display_info->have_xsync)
{
return EVENT_FILTER_REMOVE;
Olivier Fourdan
committed
}
c = myDisplayGetClientFromXSyncAlarm (display_info, ev->alarm);
if (c)
{
c->xsync_waiting = FALSE;
c->xsync_value = ev->counter_value;
Olivier Fourdan
committed
clientXSyncClearTimeout (c);
return EVENT_FILTER_REMOVE;
static eventFilterStatus
handleEvent (DisplayInfo *display_info, XEvent * ev)
eventFilterStatus status;
status = EVENT_FILTER_PASS;
TRACE ("entering handleEvent");
myDisplayUpdateCurrentTime (display_info, ev);
sn_process_event (ev);
case MotionNotify:
status = handleMotionNotify (display_info, (XMotionEvent *) ev);
break;
case KeyPress:
status = handleKeyPress (display_info, (XKeyEvent *) ev);
Olivier Fourdan
committed
break;
case KeyRelease:
status = handleKeyRelease (display_info, (XKeyEvent *) ev);
break;
case ButtonPress:
status = handleButtonPress (display_info, (XButtonEvent *) ev);
break;
case ButtonRelease:
status = handleButtonRelease (display_info, (XButtonEvent *) ev);
break;
case DestroyNotify:
status = handleDestroyNotify (display_info, (XDestroyWindowEvent *) ev);
break;
case UnmapNotify:
status = handleUnmapNotify (display_info, (XUnmapEvent *) ev);
break;
case MapRequest:
status = handleMapRequest (display_info, (XMapRequestEvent *) ev);
status = handleMapNotify (display_info, (XMapEvent *) ev);
status = handleConfigureNotify (display_info, (XConfigureEvent *) ev);
case ConfigureRequest:
status = handleConfigureRequest (display_info, (XConfigureRequestEvent *) ev);
break;
case EnterNotify:
status = handleEnterNotify (display_info, (XCrossingEvent *) ev);
break;
case LeaveNotify:
status = handleLeaveNotify (display_info, (XCrossingEvent *) ev);
break;
case FocusIn:
status = handleFocusIn (display_info, (XFocusChangeEvent *) ev);
break;
case FocusOut:
status = handleFocusOut (display_info, (XFocusChangeEvent *) ev);
break;
case PropertyNotify:
status = handlePropertyNotify (display_info, (XPropertyEvent *) ev);
break;
case ClientMessage:
status = handleClientMessage (display_info, (XClientMessageEvent *) ev);
Olivier Fourdan
committed
case SelectionClear:
status = handleSelectionClear (display_info, (XSelectionClearEvent *) ev);
break;
case ColormapNotify:
handleColormapNotify (display_info, (XColormapEvent *) ev);
Olivier Fourdan
committed
case ReparentNotify:
status = handleReparentNotify (display_info, (XReparentEvent *) ev);
break;
if ((display_info->have_shape) && (ev->type == display_info->shape_event_base))
status = handleShape (display_info, (XShapeEvent *) ev);
#ifdef HAVE_XSYNC
if ((display_info->have_xsync) && (ev->type == (display_info->xsync_event_base + XSyncAlarmNotify)))
{
status = handleXSyncAlarmNotify (display_info, (XSyncAlarmNotifyEvent *) ev);
if (!gdk_events_pending () && !XPending (display_info->dpy))
Olivier Fourdan
committed
if (display_info->reload)
Olivier Fourdan
committed
display_info->reload = FALSE;
Olivier Fourdan
committed
else if (display_info->quit)
Olivier Fourdan
committed
/*
* Qutting on purpose, update session manager so
* it does not restart the program immediately
Olivier Fourdan
committed
*/
Stephan Arts
committed
xfce_sm_client_set_restart_style(display_info->session, XFCE_SM_CLIENT_RESTART_NORMAL);
gtk_main_quit ();
}
Olivier Fourdan
committed
compositorHandleEvent (display_info, ev);
return status;
xfwm4_event_filter (XEvent * xevent, gpointer data)
eventFilterStatus status;
DisplayInfo *display_info;
display_info = (DisplayInfo *) data;
TRACE ("entering xfwm4_event_filter");
status = handleEvent (display_info, xevent);
TRACE ("leaving xfwm4_event_filter");
return EVENT_FILTER_STOP | status;
/* GTK specific stuff */
menu_callback (Menu * menu, MenuOp op, Window xid, gpointer menu_data, gpointer item_data)
Olivier Fourdan
committed
TRACE ("entering menu_callback");
if ((menu_data != NULL) && (xid != None))
ScreenInfo *screen_info = (ScreenInfo *) menu_data;
c = myScreenGetClientFromWindow (screen_info, xid, SEARCH_WINDOW);
}
if (c)
{
c->button_status[MENU_BUTTON] = BUTTON_STATE_NORMAL;
switch (op)
case MENU_OP_QUIT:
gtk_main_quit ();
break;
case MENU_OP_MAXIMIZE:
case MENU_OP_UNMAXIMIZE:
if (CLIENT_CAN_MAXIMIZE_WINDOW (c))
{
clientToggleMaximized (c, CLIENT_FLAG_MAXIMIZED, TRUE);
}
break;
case MENU_OP_MINIMIZE:
if (CLIENT_CAN_HIDE_WINDOW (c))
{
Olivier Fourdan
committed
clientWithdraw (c, c->win_workspace, TRUE);
}
break;
Olivier Fourdan
committed
case MENU_OP_MOVE:
clientMove (c, NULL);
break;
case MENU_OP_RESIZE:
clientResize (c, CORNER_BOTTOM_RIGHT, NULL);
break;
case MENU_OP_MINIMIZE_ALL:
Olivier Fourdan
committed
clientWithdrawAll (c, c->win_workspace);
break;
case MENU_OP_UNMINIMIZE:
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN))
{
clientClearAllShowDesktop (c->screen_info);
}
clientShow (c, TRUE);
break;
case MENU_OP_SHADE:
case MENU_OP_UNSHADE:
clientToggleShaded (c);
break;
case MENU_OP_STICK:
case MENU_OP_UNSTICK:
clientToggleSticky (c, TRUE);
break;
case MENU_OP_WORKSPACES:
clientSetWorkspace (c, GPOINTER_TO_INT (item_data), TRUE);
break;
case MENU_OP_DELETE:
clientClose (c);
break;
case MENU_OP_CONTEXT_HELP:
clientEnterContextMenuState (c);
break;
case MENU_OP_ABOVE:
Olivier Fourdan
committed
clientToggleLayerAbove (c);
break;
case MENU_OP_NORMAL:
Olivier Fourdan
committed
clientSetLayerNormal (c);
break;
case MENU_OP_BELOW:
clientToggleLayerBelow (c);
break;
case MENU_OP_FULLSCREEN:
case MENU_OP_UNFULLSCREEN:
clientToggleFullscreen (c);
break;
default:
break;
else
gdk_beep ();
}
menu_free (menu);
void
initMenuEventWin (void)
{
}
Olivier Fourdan
committed
static void
show_window_menu (Client *c, gint px, gint py, guint button, guint32 timestamp)
ScreenInfo *screen_info;
DisplayInfo *display_info;
Olivier Fourdan
committed
Menu *menu;
MenuOp ops;
MenuOp insensitive;
Olivier Fourdan
committed
gint x, y;
Olivier Fourdan
committed
TRACE ("entering show_window_menu");
Olivier Fourdan
committed
if ((button != Button1) && (button != Button3))
{
return;
}
if (!c || !FLAG_TEST_ALL (c->xfwm_flags, XFWM_FLAG_HAS_MENU | XFWM_FLAG_VISIBLE))
Olivier Fourdan
committed
return;
}
Olivier Fourdan
committed
screen_info = c->screen_info;
display_info = screen_info->display_info;
is_transient = clientIsValidTransientOrModal (c);
Olivier Fourdan
committed
Olivier Fourdan
committed
x = px;
y = py;
c->button_status[MENU_BUTTON] = BUTTON_STATE_PRESSED;
Olivier Fourdan
committed
y = (gdouble) c->y;
Olivier Fourdan
committed
ops = MENU_OP_DELETE | MENU_OP_MINIMIZE_ALL | MENU_OP_WORKSPACES | MENU_OP_MOVE | MENU_OP_RESIZE;
Olivier Fourdan
committed
insensitive = 0;
Olivier Fourdan
committed
if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
{
ops |= MENU_OP_UNMAXIMIZE;
}
else
{
ops |= MENU_OP_MAXIMIZE;
}
Olivier Fourdan
committed
if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE))
{
insensitive |= MENU_OP_MOVE;
}
Olivier Fourdan
committed
if (FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED))
{
ops |= MENU_OP_UNMINIMIZE;
}
else
{
ops |= MENU_OP_MINIMIZE;
}
Olivier Fourdan
committed
if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
{
ops |= MENU_OP_UNSHADE;
}
else
{
ops |= MENU_OP_SHADE;
}
Olivier Fourdan
committed
if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY))
{
ops |= MENU_OP_UNSTICK;
}
else
{
ops |= MENU_OP_STICK;
}
Olivier Fourdan
committed
if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_CLOSE))
Olivier Fourdan
committed
{
Olivier Fourdan
committed
insensitive |= MENU_OP_DELETE;
}
if (is_transient || !FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_STICK))
Olivier Fourdan
committed
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
{
insensitive |= MENU_OP_STICK | MENU_OP_UNSTICK;
}
if (!CLIENT_CAN_HIDE_WINDOW (c))
{
insensitive |= MENU_OP_MINIMIZE;
}
if (!CLIENT_CAN_MAXIMIZE_WINDOW (c))
{
insensitive |= MENU_OP_MAXIMIZE;
}
if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE))
{
insensitive |= MENU_OP_MOVE;
}
if (!FLAG_TEST_ALL (c->xfwm_flags, XFWM_FLAG_HAS_RESIZE | XFWM_FLAG_IS_RESIZABLE) ||
FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED))
{
insensitive |= MENU_OP_RESIZE;
}
if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
{
insensitive |= MENU_OP_SHADE | MENU_OP_MOVE | MENU_OP_RESIZE | MENU_OP_MAXIMIZE | MENU_OP_UNMAXIMIZE;
}
if (FLAG_TEST(c->flags, CLIENT_FLAG_FULLSCREEN))
{
ops |= MENU_OP_UNFULLSCREEN;
}
else
{
ops |= MENU_OP_FULLSCREEN;
}
if (is_transient || (c->type != WINDOW_NORMAL))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_FULLSCREEN | MENU_OP_UNFULLSCREEN;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
if (FLAG_TEST(c->flags, CLIENT_FLAG_ABOVE))
{
Olivier Fourdan
committed
ops |= MENU_OP_NORMAL | MENU_OP_BELOW;
}
else if (FLAG_TEST(c->flags, CLIENT_FLAG_BELOW))
{
ops |= MENU_OP_NORMAL | MENU_OP_ABOVE;
Olivier Fourdan
committed
}
else
{
Olivier Fourdan
committed
ops |= MENU_OP_ABOVE | MENU_OP_BELOW;
}
if (is_transient || FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
Olivier Fourdan
committed
{
insensitive |= MENU_OP_NORMAL | MENU_OP_ABOVE | MENU_OP_BELOW;
}
/* KDE extension */
clientGetWMProtocols(c);
if (FLAG_TEST (c->wm_flags, WM_FLAG_CONTEXT_HELP))
{
ops |= MENU_OP_CONTEXT_HELP;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
|| !FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_STICK)
|| FLAG_TEST (c->flags, CLIENT_FLAG_STICKY))
{
insensitive |= MENU_OP_WORKSPACES;
Olivier Fourdan
committed
}
Olivier Fourdan
committed
{
g_signal_handler_disconnect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)), screen_info->button_handler_id);
Olivier Fourdan
committed
}
screen_info->button_handler_id = g_signal_connect (GTK_OBJECT (myScreenGetGtkWidget (screen_info)),
"button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) NULL);
Olivier Fourdan
committed
/*
Since all button press/release events are catched by the windows frames, there is some
side effect with GTK menu. When a menu is opened, any click on the window frame is not
detected as a click outside the menu, and the menu doesn't close.
To avoid this (painless but annoying) behavior, we just setup a no event window that
"hides" the events to regular windows.
That might look tricky, but it's very efficient and save plenty of lines of complicated
Don't forget to delete that window once the menu is closed, though, or we'll get in
xfwmWindowTemp (screen_info,
&menu_event_window, 0, 0,
screen_info->width,
screen_info->height,
Olivier Fourdan
committed
NoEventMask,
FALSE);
menu = menu_default (screen_info->gscr, c->window, ops, insensitive, menu_callback,
c->win_workspace, screen_info->workspace_count,
screen_info->workspace_names, screen_info->workspace_names_items,
display_info->xfilter, screen_info);
if (!menu_popup (menu, x, y, button, timestamp))
TRACE ("Cannot open menu");
gdk_beep ();
c->button_status[MENU_BUTTON] = BUTTON_STATE_NORMAL;
menu_free (menu);
Olivier Fourdan
committed
}
Olivier Fourdan
committed
}
static gboolean
show_popup_cb (GtkWidget * widget, GdkEventButton * ev, gpointer data)
{
TRACE ("entering show_popup_cb");
show_window_menu ((Client *) data, (gint) ev->x_root, (gint) ev->y_root, ev->button, ev->time);
Olivier Fourdan
committed
return (TRUE);
static gboolean
set_reload (GObject * obj, GdkEvent * ev, gpointer data)
Olivier Fourdan
committed
DisplayInfo *display_info;
TRACE ("setting reload flag so all prefs will be reread at next event loop");
Olivier Fourdan
committed
display_info = (DisplayInfo *) data;
display_info->reload = TRUE;
static gboolean
double_click_time_cb (GObject * obj, GdkEvent * ev, gpointer data)
Olivier Fourdan
committed
g_value_init (&tmp_val, G_TYPE_INT);
if (gdk_setting_get ("gtk-double-click-time", &tmp_val))
display_info->double_click_time = abs (g_value_get_int (&tmp_val));
}
return (TRUE);
}
static gboolean
double_click_distance_cb (GObject * obj, GdkEvent * ev, gpointer data)
{
DisplayInfo *display_info;
GValue tmp_val = { 0, };
display_info = (DisplayInfo *) data;
g_return_val_if_fail (display_info, TRUE);
g_value_init (&tmp_val, G_TYPE_INT);
if (gdk_setting_get ("gtk-double-click-distance", &tmp_val))
{
display_info->double_click_distance = abs (g_value_get_int (&tmp_val));
}
return (TRUE);
}
static void
cursor_theme_cb (GObject * obj, GParamSpec * pspec, gpointer data)
{
DisplayInfo * display_info;
GSList *list;
display_info = (DisplayInfo *) data;
g_return_if_fail (display_info);
myDisplayFreeCursor (display_info);
myDisplayCreateCursor (display_info);
for (list = display_info->screens; list; list = g_slist_next (list))
{
ScreenInfo *screen_info = (ScreenInfo *) list->data;
clientUpdateAllCursor (screen_info);
XDefineCursor (display_info->dpy, screen_info->xroot, display_info->root_cursor);
}
}
static gboolean
client_event_cb (GtkWidget * widget, GdkEventClient * ev, gpointer data)
TRACE ("entering client_event_cb");
Olivier Fourdan
committed
if (!atom_rcfiles)
Olivier Fourdan
committed
{
atom_rcfiles = gdk_atom_intern ("_GTK_READ_RCFILES", FALSE);
Olivier Fourdan
committed
}
if (ev->message_type == atom_rcfiles)
Olivier Fourdan
committed
{
set_reload (G_OBJECT (widget), (GdkEvent *) ev, data);
Olivier Fourdan
committed
}
return (FALSE);
static gboolean
refresh_font_cb (GObject * obj, GdkEvent * ev, gpointer data)
DisplayInfo * display_info;
GSList *list;
display_info = (DisplayInfo *) data;
g_return_val_if_fail (display_info, TRUE);
for (list = display_info->screens; list; list = g_slist_next (list))
{
ScreenInfo *screen_info = (ScreenInfo *) list->data;
myScreenUpdateFontHeight (screen_info);
clientUpdateAllFrames (screen_info, UPDATE_FRAME);
}
return (TRUE);
}
/*
* The size-changed signal is emitted when the pixel width or height
* of a screen changes.
*/
Olivier Fourdan
committed
static void
size_changed_cb(GdkScreen *gscreen, gpointer data)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
Olivier Fourdan
committed
gboolean size_changed;
Olivier Fourdan
committed
TRACE ("entering size_changed_cb");
screen_info = (ScreenInfo *) data;
g_return_if_fail (screen_info);
Olivier Fourdan
committed
display_info = screen_info->display_info;
Olivier Fourdan
committed
Olivier Fourdan
committed
if (gdk_screen_get_n_monitors (screen_info->gscr) == 0)
{
/*
* Recent Xorg drivers disable the output when the lid
* is closed, leaving no active monitor, in that case simply
* ignore the event to avoid messing with windows' positions.
Olivier Fourdan
committed
*/
return;
}
Olivier Fourdan
committed
size_changed = myScreenComputeSize (screen_info);
if (size_changed)
{
myScreenInvalidateMonitorCache (screen_info);
setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
screen_info->width, screen_info->height, screen_info->margins);
placeSidewalks (screen_info, screen_info->params->wrap_workspaces);
clientScreenResize (screen_info, FALSE);
Olivier Fourdan
committed
compositorUpdateScreenSize (screen_info);
}
Olivier Fourdan
committed
}
/*
* The monitors-changed signal is emitted when the number, size or
* position of the monitors attached to the screen change.
*/
Olivier Fourdan
committed
static void
monitors_changed_cb(GdkScreen *gscreen, gpointer data)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
gint previous_num_monitors;
gboolean size_changed;
Olivier Fourdan
committed
TRACE ("entering monitors_changed_cb");
screen_info = (ScreenInfo *) data;
g_return_if_fail (screen_info);
display_info = screen_info->display_info;
if (gdk_screen_get_n_monitors (screen_info->gscr) == 0)
{
/*
* Recent Xorg drivers disable the output when the lid
* is closed, leaving no active monitor, in that case simply
* ignore the event to avoid messing with windows' positions.
*/
return;
}
Olivier Fourdan
committed
/*
* We have added/removed a monitor or even changed the layout,
* the cache for monitor position we use in our screen structure
* is not valid anymore and potentially refers to a monitor that
* was just removed, so invalidate it.
Olivier Fourdan
committed
*/
previous_num_monitors = screen_info->num_monitors;
myScreenInvalidateMonitorCache (screen_info);
myScreenRebuildMonitorIndex (screen_info);
size_changed = myScreenComputeSize (screen_info);
if (size_changed || (screen_info->num_monitors != previous_num_monitors))
{
setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
screen_info->width, screen_info->height, screen_info->margins);
placeSidewalks (screen_info, screen_info->params->wrap_workspaces);
clientScreenResize (screen_info, (screen_info->num_monitors < previous_num_monitors));
}
if (size_changed)
{
compositorUpdateScreenSize (screen_info);
}
Olivier Fourdan
committed
}
initPerScreenCallbacks (ScreenInfo *screen_info)
g_return_if_fail (screen_info);
Olivier Fourdan
committed
screen_info->button_handler_id =
g_signal_connect (G_OBJECT (myScreenGetGtkWidget (screen_info)),
"button_press_event", GTK_SIGNAL_FUNC (show_popup_cb), (gpointer) NULL);
g_signal_connect (G_OBJECT (myScreenGetGtkWidget (screen_info)), "client_event",
GTK_SIGNAL_FUNC (client_event_cb), NULL);
g_object_connect (G_OBJECT(screen_info->gscr),
"signal::notify::size-changed",
G_CALLBACK(size_changed_cb), (gpointer) (screen_info),
"signal::notify::monitors-changed",
G_CALLBACK(monitors_changed_cb), (gpointer) (screen_info),
NULL);
}
void
initPerDisplayCallbacks (DisplayInfo *display_info)
{
GtkSettings *settings;
g_return_if_fail (display_info);
Olivier Fourdan
committed
settings = gtk_settings_get_default ();
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
g_object_connect (settings,
"signal::notify::gtk-theme-name",
G_CALLBACK (set_reload), (gpointer) (display_info),
"signal::notify::gtk-font-name",
G_CALLBACK (set_reload), (gpointer) (display_info),
"signal::notify::gtk-double-click-time",
G_CALLBACK (double_click_time_cb), (gpointer) (display_info),
"signal::notify::gtk-double-click-distance",
G_CALLBACK (double_click_distance_cb), (gpointer) (display_info),
"signal::notify::gtk-cursor-theme-name",
G_CALLBACK (cursor_theme_cb), (gpointer) (display_info),
"signal::notify::gtk-cursor-theme-size",
G_CALLBACK (cursor_theme_cb), (gpointer) (display_info),
"signal::notify::gtk-xft-antialias",
G_CALLBACK (refresh_font_cb), (gpointer) (display_info),
"signal::notify::gtk-xft-dpi",
G_CALLBACK (refresh_font_cb), (gpointer) (display_info),
"signal::notify::gtk-xft-hinting",
G_CALLBACK (refresh_font_cb), (gpointer) (display_info),
"signal::notify::gtk-xft-hintstyle",
G_CALLBACK (refresh_font_cb), (gpointer) (display_info),
"signal::notify::gtk-xft-rgba",
G_CALLBACK (refresh_font_cb), (gpointer) (display_info),
NULL);