remove the client_time_heap thing. actually its better to just use the user_time on the currently focused window I think. that will handle panels and things too.
This commit is contained in:
parent
90cd9c6219
commit
d713bdf462
5 changed files with 7 additions and 243 deletions
|
@ -137,8 +137,6 @@ openbox_openbox_SOURCES = \
|
||||||
openbox/action.h \
|
openbox/action.h \
|
||||||
openbox/client.c \
|
openbox/client.c \
|
||||||
openbox/client.h \
|
openbox/client.h \
|
||||||
openbox/client_time_heap.c \
|
|
||||||
openbox/client_time_heap.h \
|
|
||||||
openbox/client_list_menu.c \
|
openbox/client_list_menu.c \
|
||||||
openbox/client_list_menu.h \
|
openbox/client_list_menu.h \
|
||||||
openbox/client_list_combined_menu.c \
|
openbox/client_list_combined_menu.c \
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "client_time_heap.h"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "startupnotify.h"
|
#include "startupnotify.h"
|
||||||
#include "dock.h"
|
#include "dock.h"
|
||||||
|
@ -58,7 +57,6 @@ typedef struct
|
||||||
} Destructor;
|
} Destructor;
|
||||||
|
|
||||||
GList *client_list = NULL;
|
GList *client_list = NULL;
|
||||||
ObClientTimeHeap *client_user_times = NULL;
|
|
||||||
|
|
||||||
static GSList *client_destructors = NULL;
|
static GSList *client_destructors = NULL;
|
||||||
|
|
||||||
|
@ -85,13 +83,11 @@ void client_startup(gboolean reconfig)
|
||||||
{
|
{
|
||||||
if (reconfig) return;
|
if (reconfig) return;
|
||||||
|
|
||||||
client_user_times = client_time_heap_new();
|
|
||||||
client_set_list();
|
client_set_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_shutdown(gboolean reconfig)
|
void client_shutdown(gboolean reconfig)
|
||||||
{
|
{
|
||||||
client_time_heap_free(client_user_times);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_add_destructor(ObClientDestructor func, gpointer data)
|
void client_add_destructor(ObClientDestructor func, gpointer data)
|
||||||
|
@ -406,10 +402,12 @@ void client_manage(Window window)
|
||||||
mouse_grab_for_client(self, TRUE);
|
mouse_grab_for_client(self, TRUE);
|
||||||
|
|
||||||
if (activate) {
|
if (activate) {
|
||||||
|
guint32 last_time = focus_client ?
|
||||||
|
focus_client->user_time : CurrentTime;
|
||||||
|
|
||||||
/* This is focus stealing prevention */
|
/* This is focus stealing prevention */
|
||||||
ob_debug("Want to focus new window 0x%x with time %u (last time %u)\n",
|
ob_debug("Want to focus new window 0x%x with time %u (last time %u)\n",
|
||||||
self->window, self->user_time,
|
self->window, self->user_time, last_time);
|
||||||
client_time_heap_maximum(client_user_times));
|
|
||||||
|
|
||||||
/* If a nothing at all, or a parent was focused, then focus this
|
/* If a nothing at all, or a parent was focused, then focus this
|
||||||
always
|
always
|
||||||
|
@ -418,7 +416,6 @@ void client_manage(Window window)
|
||||||
activate = TRUE;
|
activate = TRUE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
guint32 last_time = client_time_heap_maximum(client_user_times);
|
|
||||||
/* If time stamp is old, don't steal focus */
|
/* If time stamp is old, don't steal focus */
|
||||||
if (self->user_time && last_time &&
|
if (self->user_time && last_time &&
|
||||||
!event_time_after(self->user_time, last_time))
|
!event_time_after(self->user_time, last_time))
|
||||||
|
@ -441,8 +438,7 @@ void client_manage(Window window)
|
||||||
} else {
|
} else {
|
||||||
ob_debug("Focus stealing prevention activated for %s with time %u "
|
ob_debug("Focus stealing prevention activated for %s with time %u "
|
||||||
"(last time %u)\n",
|
"(last time %u)\n",
|
||||||
self->title, self->user_time,
|
self->title, self->user_time, last_time);
|
||||||
client_time_heap_maximum(client_user_times));
|
|
||||||
/* if the client isn't focused, then hilite it so the user
|
/* if the client isn't focused, then hilite it so the user
|
||||||
knows it is there */
|
knows it is there */
|
||||||
client_hilite(self, TRUE);
|
client_hilite(self, TRUE);
|
||||||
|
@ -544,9 +540,6 @@ void client_unmanage(ObClient *self)
|
||||||
/* we dont want events no more */
|
/* we dont want events no more */
|
||||||
XSelectInput(ob_display, self->window, NoEventMask);
|
XSelectInput(ob_display, self->window, NoEventMask);
|
||||||
|
|
||||||
/* remove from the time heap */
|
|
||||||
client_time_heap_remove(client_user_times, self);
|
|
||||||
|
|
||||||
client_list = g_list_remove(client_list, self);
|
client_list = g_list_remove(client_list, self);
|
||||||
stacking_remove(self);
|
stacking_remove(self);
|
||||||
g_hash_table_remove(window_map, &self->window);
|
g_hash_table_remove(window_map, &self->window);
|
||||||
|
@ -1866,7 +1859,6 @@ void client_update_user_time(ObClient *self)
|
||||||
guint32 time;
|
guint32 time;
|
||||||
|
|
||||||
if (PROP_GET32(self->window, net_wm_user_time, cardinal, &time)) {
|
if (PROP_GET32(self->window, net_wm_user_time, cardinal, &time)) {
|
||||||
guint32 otime = self->user_time;
|
|
||||||
/* we set this every time, not just when it grows, because in practice
|
/* we set this every time, not just when it grows, because in practice
|
||||||
sometimes time goes backwards! (ntpdate.. yay....) so.. if it goes
|
sometimes time goes backwards! (ntpdate.. yay....) so.. if it goes
|
||||||
backward we don't want all windows to stop focusing. we'll just
|
backward we don't want all windows to stop focusing. we'll just
|
||||||
|
@ -1874,22 +1866,9 @@ void client_update_user_time(ObClient *self)
|
||||||
would be pretty stupid anyways
|
would be pretty stupid anyways
|
||||||
*/
|
*/
|
||||||
self->user_time = time;
|
self->user_time = time;
|
||||||
/* adjust the time heap - windows with CurrentTime for their user_time
|
|
||||||
are not in the heap */
|
|
||||||
if (time == CurrentTime && otime != CurrentTime)
|
|
||||||
client_time_heap_remove(client_user_times, self);
|
|
||||||
else if (time != CurrentTime && otime == CurrentTime)
|
|
||||||
client_time_heap_add(client_user_times, self);
|
|
||||||
else if (time != CurrentTime && otime != CurrentTime) {
|
|
||||||
if (event_time_after(time, otime))
|
|
||||||
client_time_heap_increase_key(client_user_times, self);
|
|
||||||
else
|
|
||||||
client_time_heap_decrease_key(client_user_times, self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ob_debug("window %s user time %u\n", self->title, time);
|
ob_debug("window %s user time %u\n", self->title, time);
|
||||||
ob_debug("last user time %u\n", client_time_heap_maximum(client_user_times));
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3084,7 +3063,7 @@ static void client_unfocus(ObClient *self)
|
||||||
|
|
||||||
void client_activate(ObClient *self, gboolean here, gboolean user)
|
void client_activate(ObClient *self, gboolean here, gboolean user)
|
||||||
{
|
{
|
||||||
guint32 last_time;
|
guint32 last_time = focus_client ? focus_client->user_time : CurrentTime;
|
||||||
|
|
||||||
/* XXX do some stuff here if user is false to determine if we really want
|
/* XXX do some stuff here if user is false to determine if we really want
|
||||||
to activate it or not (a parent or group member is currently
|
to activate it or not (a parent or group member is currently
|
||||||
|
@ -3092,11 +3071,9 @@ void client_activate(ObClient *self, gboolean here, gboolean user)
|
||||||
*/
|
*/
|
||||||
ob_debug("Want to activate window 0x%x with time %u (last time %u), "
|
ob_debug("Want to activate window 0x%x with time %u (last time %u), "
|
||||||
"source=%s\n",
|
"source=%s\n",
|
||||||
self->window, event_curtime,
|
self->window, event_curtime, last_time,
|
||||||
client_time_heap_maximum(client_user_times),
|
|
||||||
(user ? "user" : "application"));
|
(user ? "user" : "application"));
|
||||||
|
|
||||||
last_time = client_time_heap_maximum(client_user_times);
|
|
||||||
if (!user && event_curtime && last_time &&
|
if (!user && event_curtime && last_time &&
|
||||||
!event_time_after(event_curtime, last_time))
|
!event_time_after(event_curtime, last_time))
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
struct _ObFrame;
|
struct _ObFrame;
|
||||||
struct _ObGroup;
|
struct _ObGroup;
|
||||||
struct _ObSessionState;
|
struct _ObSessionState;
|
||||||
struct _ObClientTimeHeap;
|
|
||||||
|
|
||||||
typedef struct _ObClient ObClient;
|
typedef struct _ObClient ObClient;
|
||||||
typedef struct _ObClientIcon ObClientIcon;
|
typedef struct _ObClientIcon ObClientIcon;
|
||||||
|
@ -301,7 +300,6 @@ struct _ObAppSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GList *client_list;
|
extern GList *client_list;
|
||||||
extern struct _ObClientTimeHeap *client_user_times;
|
|
||||||
|
|
||||||
void client_startup(gboolean reconfig);
|
void client_startup(gboolean reconfig);
|
||||||
void client_shutdown(gboolean reconfig);
|
void client_shutdown(gboolean reconfig);
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
|
||||||
|
|
||||||
client_time_heap.c for the Openbox window manager
|
|
||||||
Copyright (c) 2006 Mikael Magnusson
|
|
||||||
Copyright (c) 2003-2007 Dana Jansens
|
|
||||||
|
|
||||||
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 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "client_time_heap.h"
|
|
||||||
#include "client.h"
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
|
|
||||||
/* Helper functions for the heap */
|
|
||||||
|
|
||||||
#define isroot(n) (n == 0)
|
|
||||||
#define parent(n) ((n-1)/2)
|
|
||||||
#define right(n) ((n+1)*2)
|
|
||||||
#define left(n) (right(n)-1)
|
|
||||||
#define exists(n) (n < h->nodes->len)
|
|
||||||
#define key(n) (((ObClient*)h->nodes->pdata[n])->user_time)
|
|
||||||
|
|
||||||
static inline void swap(ObClientTimeHeap *h, guint a, guint b)
|
|
||||||
{
|
|
||||||
gpointer c;
|
|
||||||
|
|
||||||
g_assert(a < h->nodes->len);
|
|
||||||
g_assert(b < h->nodes->len);
|
|
||||||
|
|
||||||
c = h->nodes->pdata[a];
|
|
||||||
h->nodes->pdata[a] = h->nodes->pdata[b];
|
|
||||||
h->nodes->pdata[b] = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void heapify(ObClientTimeHeap *h, guint n)
|
|
||||||
{
|
|
||||||
g_assert(exists(n));
|
|
||||||
|
|
||||||
/* fix up the heap, move it down below keys it's smaller than */
|
|
||||||
while ((exists(left(n)) && key(n) < key(left(n))) ||
|
|
||||||
(exists(right(n)) && key(n) < key(right(n))))
|
|
||||||
{
|
|
||||||
if (exists(left(n)) && exists(right(n)))
|
|
||||||
if (key(left(n)) > key(right(n))) {
|
|
||||||
swap(h, n, left(n));
|
|
||||||
n = left(n);
|
|
||||||
} else {
|
|
||||||
swap(h, n, right(n));
|
|
||||||
n = right(n);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* its impossible in this structure to have a right child but no
|
|
||||||
left child */
|
|
||||||
swap(h, n, left(n));
|
|
||||||
n = left(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ObClientTimeHeap* client_time_heap_new()
|
|
||||||
{
|
|
||||||
ObClientTimeHeap *h = g_new0(ObClientTimeHeap, 1);
|
|
||||||
h->nodes = g_ptr_array_new();
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
void client_time_heap_free(ObClientTimeHeap *h)
|
|
||||||
{
|
|
||||||
if (h != NULL) {
|
|
||||||
/* all the clients should be removed before the heap is destroyed. */
|
|
||||||
g_assert(h->nodes->len == 0);
|
|
||||||
g_ptr_array_free(h->nodes, TRUE);
|
|
||||||
g_free(h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guint32 client_time_heap_maximum(ObClientTimeHeap *h)
|
|
||||||
{
|
|
||||||
if (h->nodes->len == 0)
|
|
||||||
return CurrentTime;
|
|
||||||
else
|
|
||||||
return key(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void client_time_heap_add(ObClientTimeHeap *h, ObClient *c)
|
|
||||||
{
|
|
||||||
guint n;
|
|
||||||
|
|
||||||
/* insert it as the last leaf */
|
|
||||||
g_ptr_array_add(h->nodes, c);
|
|
||||||
n = h->nodes->len - 1;
|
|
||||||
|
|
||||||
/* move it up to its proper place */
|
|
||||||
while (!isroot(n) && key(n) > key(parent(n))) {
|
|
||||||
swap(h, n, parent(n));
|
|
||||||
n = parent(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void client_time_heap_remove(ObClientTimeHeap *h, ObClient *c)
|
|
||||||
{
|
|
||||||
/* find the client */
|
|
||||||
guint n;
|
|
||||||
for (n = 0; h->nodes->pdata[n] != c && n < h->nodes->len; ++n);
|
|
||||||
|
|
||||||
/* if the client is in the heap */
|
|
||||||
if (n < h->nodes->len) {
|
|
||||||
/* move it to a leaf and delete it from the heap */
|
|
||||||
swap(h, n, h->nodes->len-1);
|
|
||||||
g_ptr_array_remove_index(h->nodes, h->nodes->len-1);
|
|
||||||
|
|
||||||
/* move the swapped leaf down to its proper place if it wasn't just
|
|
||||||
deleted */
|
|
||||||
if (exists(n))
|
|
||||||
heapify(h, n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void client_time_heap_decrease_key(ObClientTimeHeap *h, ObClient *c)
|
|
||||||
{
|
|
||||||
/* find the client */
|
|
||||||
guint n;
|
|
||||||
for (n = 0; h->nodes->pdata[n] != c && n < h->nodes->len; ++n);
|
|
||||||
|
|
||||||
/* if the client is in the heap */
|
|
||||||
if (n < h->nodes->len) {
|
|
||||||
/* move it down to its proper place */
|
|
||||||
heapify(h, n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void client_time_heap_increase_key(ObClientTimeHeap *h, ObClient *c)
|
|
||||||
{
|
|
||||||
/* find the client */
|
|
||||||
guint n;
|
|
||||||
for (n = 0; h->nodes->pdata[n] != c && n < h->nodes->len; ++n);
|
|
||||||
|
|
||||||
/* if the client is in the heap */
|
|
||||||
if (n < h->nodes->len) {
|
|
||||||
/* move it up to its proper place */
|
|
||||||
while (!isroot(n) && key(n) > key(parent(n))) {
|
|
||||||
swap(h, n, parent(n));
|
|
||||||
n = parent(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
|
||||||
|
|
||||||
client_time_heap.h for the Openbox window manager
|
|
||||||
Copyright (c) 2006 Mikael Magnusson
|
|
||||||
Copyright (c) 2003-2007 Dana Jansens
|
|
||||||
|
|
||||||
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 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
See the COPYING file for a copy of the GNU General Public License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __client_time_heap_h
|
|
||||||
#define __client_time_heap_h
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
struct _ObClient *client;
|
|
||||||
|
|
||||||
typedef struct _ObClientTimeHeap ObClientTimeHeap;
|
|
||||||
typedef struct _ObClientTimeHeapNode ObClientTimeHeapNode;
|
|
||||||
|
|
||||||
/*! A min-heap of the clients based on their user_time as the key */
|
|
||||||
struct _ObClientTimeHeap
|
|
||||||
{
|
|
||||||
/* The nodes in the heap */
|
|
||||||
GPtrArray *nodes;
|
|
||||||
};
|
|
||||||
|
|
||||||
ObClientTimeHeap* client_time_heap_new ();
|
|
||||||
void client_time_heap_free (ObClientTimeHeap *h);
|
|
||||||
|
|
||||||
guint32 client_time_heap_maximum (ObClientTimeHeap *h);
|
|
||||||
|
|
||||||
void client_time_heap_add (ObClientTimeHeap *h,
|
|
||||||
struct _ObClient *c);
|
|
||||||
void client_time_heap_remove (ObClientTimeHeap *h,
|
|
||||||
struct _ObClient *c);
|
|
||||||
void client_time_heap_decrease_key (ObClientTimeHeap *h,
|
|
||||||
struct _ObClient *c);
|
|
||||||
void client_time_heap_increase_key (ObClientTimeHeap *h,
|
|
||||||
struct _ObClient *c);
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue