#include "debug.h"
#include "openbox.h"
+#include "mainloop.h"
#include "dock.h"
#include "xerror.h"
#include "prop.h"
#include "startup.h"
#include "grab.h"
-#include "timer.h"
#include "config.h"
#include "screen.h"
#include "client.h"
#include "frame.h"
#include "focus.h"
#include "popup.h"
-#include "dispatch.h"
#include "extensions.h"
#include "render/render.h"
guint screen_num_desktops;
guint screen_num_monitors;
guint screen_desktop;
+guint screen_last_desktop;
Size screen_physical_size;
gboolean screen_showing_desktop;
DesktopLayout screen_desktop_layout;
#ifdef USE_LIBSN
static SnMonitorContext *sn_context;
static int sn_busy_cnt;
-static ObTimer *sn_timer;
static void sn_event_func(SnMonitorEvent *event, void *data);
#endif
wm_sn = g_strdup_printf("WM_S%d", ob_screen);
wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE);
+ g_free(wm_sn);
current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
if (current_wm_sn_owner) {
}
- ob_debug("Managing screen %d\n", ob_screen);
-
set_root_cursor();
/* set the OPENBOX_PID hint */
window, screen_support_win);
/* set the _NET_SUPPORTED_ATOMS hint */
- num_support = 61;
+ num_support = 50;
i = 0;
supported = g_new(guint32, num_support);
supported[i++] = prop_atoms.net_current_desktop;
supported[i++] = prop_atoms.net_wm_state_below;
supported[i++] = prop_atoms.net_moveresize_window;
supported[i++] = prop_atoms.net_wm_moveresize;
- supported[i++] = prop_atoms.net_wm_moveresize_size_topleft;
- supported[i++] = prop_atoms.net_wm_moveresize_size_top;
- supported[i++] = prop_atoms.net_wm_moveresize_size_topright;
- supported[i++] = prop_atoms.net_wm_moveresize_size_right;
- supported[i++] = prop_atoms.net_wm_moveresize_size_bottomright;
- supported[i++] = prop_atoms.net_wm_moveresize_size_bottom;
- supported[i++] = prop_atoms.net_wm_moveresize_size_bottomleft;
- supported[i++] = prop_atoms.net_wm_moveresize_size_left;
- supported[i++] = prop_atoms.net_wm_moveresize_move;
- supported[i++] = prop_atoms.net_wm_moveresize_size_keyboard;
- supported[i++] = prop_atoms.net_wm_moveresize_move_keyboard;
g_assert(i == num_support);
/*
supported[] = prop_atoms.net_wm_action_stick;
/* change our struts/area to match (after moving windows) */
screen_update_areas();
- dispatch_ob(Event_Ob_NumDesktops, num, old);
-
/* change our desktop if we're on one that no longer exists! */
if (screen_desktop >= screen_num_desktops)
screen_set_desktop(num - 1);
if (old == num) return;
+ screen_last_desktop = old;
+
ob_debug("Moving to desktop %d\n", num+1);
/* show windows before hiding the rest to lessen the enter/leave events */
#ifdef DEBUG_FOCUS
ob_debug("/switch fallback\n");
#endif
-
- dispatch_ob(Event_Ob_Desktop, num, old);
}
static void get_row_col(guint d, guint *r, guint *c)
}
guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
- gboolean done, gboolean cancel)
+ gboolean dialog, gboolean done, gboolean cancel)
{
static gboolean first = TRUE;
static gboolean lin;
if (cancel) {
d = origd;
goto done_cycle;
- } else if (done) {
- screen_set_desktop(d);
+ } else if (done && dialog) {
goto done_cycle;
}
if (first) {
d = translate_row_col(r, c);
}
- popup_cycle(d, TRUE);
- return d;
+ if (dialog) {
+ popup_cycle(d, TRUE);
+ return d;
+ }
done_cycle:
first = TRUE;
popup_cycle(0, FALSE);
- return d = screen_desktop;
+ return d;
}
void screen_update_layout()
show = !!show; /* make it boolean */
PROP_SET32(RootWindow(ob_display, ob_screen),
net_showing_desktop, cardinal, show);
-
- dispatch_ob(Event_Ob_ShowDesktop, show, 0);
}
void screen_install_colormap(ObClient *client, gboolean install)
}
#ifdef USE_LIBSN
-static void sn_timeout(ObTimer *t, void *data)
+static gboolean sn_timeout(gpointer data)
{
- timer_stop(sn_timer);
- sn_timer = NULL;
sn_busy_cnt = 0;
set_root_cursor();
+
+ return FALSE; /* don't repeat */
}
static void sn_event_func(SnMonitorEvent *ev, void *data)
switch (sn_monitor_event_get_type(ev)) {
case SN_MONITOR_EVENT_INITIATED:
++sn_busy_cnt;
- if (sn_timer)
- timer_stop(sn_timer);
+ ob_main_loop_timeout_remove(ob_main_loop, sn_timeout);
/* 30 second timeout for apps to start */
- sn_timer = timer_start(30 * 1000000, sn_timeout, NULL);
+ ob_main_loop_timeout_add(ob_main_loop, 30 * G_USEC_PER_SEC,
+ sn_timeout, NULL, NULL);
break;
case SN_MONITOR_EVENT_CHANGED:
break;
case SN_MONITOR_EVENT_COMPLETED:
if (sn_busy_cnt) --sn_busy_cnt;
- if (sn_timer) {
- timer_stop(sn_timer);
- sn_timer = NULL;
- }
+ ob_main_loop_timeout_remove(ob_main_loop, sn_timeout);
break;
case SN_MONITOR_EVENT_CANCELED:
if (sn_busy_cnt) --sn_busy_cnt;
- if (sn_timer) {
- timer_stop(sn_timer);
- sn_timer = NULL;
- }
+ ob_main_loop_timeout_remove(ob_main_loop, sn_timeout);
};
if (sn_busy_cnt != cnt)