Patch for deskguide for dragging tasks onto desk guide
- From: Robert Wittams <robert wittams ic ac uk>
- To: gnome-devel-list gnome org
- Subject: Patch for deskguide for dragging tasks onto desk guide
- Date: Wed, 10 May 2000 11:39:05 +0100
Hi,
I sent this patch to Tim Janik (desk guide maintainer) a few days ago ,
I thought some other people might like to look at it. It makes it
possible to
drag tasks out of the deskguide and drop them on the desktop or back
into
the same deskguide...
which is nice!
Its a feature a bit like the one out of the enlightenment pager.
doesn't do scaled down images of the windows though!
issues:-
-size of window when dragged out - this is currently 20%
of the real area of the window. this might look a bit funny on
very small deskguides, eg those in a foobar, so maybe it should be
2 * the size of the task in the deskguide or something.
Could be a preference.
-At the moment, when dragging the task around, it is really
iconified.
It should probably be hidden instead. But this hint didn't seem to
work in sawmill. The only effect this has AFAIK is that tasklist
will
dim the icon and put it in brackets.
-It sometimes flickers when making the window. Probably add in some
while(gtk_events_pending) gtk_events_iterate or something.
-It should probably use the same window each time rather than
making a new one.
-Can't drag back into a different desk guide. This would be really
hard to
fix I think, and not many people have two deskguides, do they?
And maybe it is just plain evil. Anyway, give it a try.
Robert Wittams
Index: applets/desk-guide/gwmdesktop.c
===================================================================
RCS file: /cvs/gnome/gnome-core/applets/desk-guide/gwmdesktop.c,v
retrieving revision 1.12
diff -u -r1.12 gwmdesktop.c
--- applets/desk-guide/gwmdesktop.c 2000/05/01 01:51:45 1.12
+++ applets/desk-guide/gwmdesktop.c 2000/05/08 20:59:16
@@ -22,6 +22,9 @@
#include <gtk/gtkprivate.h>
+/* this is the amount to divide the size of a real window when drawing the drag window. */
+#define DRAG_WINDOW_SCALE 5
+
/* --- area bitmap --- */
#define xbm_area_width 4
#define xbm_area_height 4
@@ -221,6 +224,12 @@
desktop->task_list = NULL;
desktop->grab_task = NULL;
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
+
if (desktop->tooltips)
{
gtk_object_unref (GTK_OBJECT (desktop->tooltips));
@@ -428,6 +437,14 @@
g_list_free (desktop->task_list);
desktop->task_list = NULL;
desktop->grab_task = NULL;
+
+
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
+
for (node = desk->client_list; node; node = node->next)
{
GwmhTask *task = node->data;
@@ -502,6 +519,11 @@
{
desktop->task_list = g_list_append (desktop->task_list, task);
desktop->grab_task = NULL;
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
gtk_widget_queue_draw (widget);
}
}
@@ -513,6 +535,11 @@
{
desktop->task_list = g_list_append (desktop->task_list, task);
desktop->grab_task = NULL;
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
}
gtk_widget_queue_draw (widget);
}
@@ -521,6 +548,11 @@
{
desktop->task_list = g_list_remove (desktop->task_list, task);
desktop->grab_task = NULL;
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
gtk_widget_queue_draw (widget);
}
}
@@ -530,6 +562,11 @@
{
desktop->task_list = g_list_remove (desktop->task_list, task);
desktop->grab_task = NULL;
+ if (desktop->drag_window)
+ {
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ }
gtk_widget_queue_draw (widget);
}
}
@@ -551,6 +588,12 @@
gint y = event->y;
GList *node;
+ /* We don't want to respond to spurious button presses
+ if we are dragging a window around. */
+ if (desktop->drag_window){
+ return TRUE;
+ }
+
desktop->grab_task = NULL;
if (x < xthick || x >= width - xthick ||
@@ -635,33 +678,91 @@
GwmDesktop *desktop = GWM_DESKTOP (widget);
GwmhTask *task;
gint x = event->x, y = event->y;
+ GtkWidget* window;
- x = CLAMP (x, -5, widget->allocation.width + 4);
- y = CLAMP (y, -5, widget->allocation.height + 4);
- task = desktop->grab_task;
-
- if (task && !GWMH_TASK_UPDATE_QUEUED (task))
- {
- gdk_window_move (task->gdkwindow,
- desktop->x_comp +
- desktop->x_spixels * (x - desktop->x_origin),
- desktop->y_comp +
- desktop->y_spixels * (y - desktop->y_origin));
- gdk_flush ();
+ /* it is not worth writing a whole other widget just
+ for the drag window, so we draw into a pop up
+ window - like a tooltip.
+ */
+ if ( desktop->grab_task &&
+ (x < -5 || x > widget->allocation.width + 4 ||
+ y < -5 || y > widget->allocation.height + 4)
+ ){
+ task = desktop->grab_task;
+ if (!desktop->drag_window){
+
+ window = gtk_window_new(GTK_WINDOW_POPUP);
+
+ /* We could have the window full sized,
+ or the size of the task boxes in the desk_guide.
+ I chose this size because it seemed to be a
+ nice compromise. */
+
+ gtk_window_set_default_size(GTK_WINDOW(window),
+ task->frame_width / DRAG_WINDOW_SCALE,
+ task->frame_height / DRAG_WINDOW_SCALE);
+ gtk_window_set_position(GTK_WINDOW(window),
+ GTK_WIN_POS_MOUSE);
+ gtk_widget_set_app_paintable(window, TRUE);
+ gtk_widget_queue_draw(GTK_WIDGET(desktop));
+ gtk_widget_show(window);
+ gwmh_task_iconify(task);
+ desktop->drag_window = GTK_WINDOW(window);
+ }else{
+ gtk_window_reposition(desktop->drag_window,
+ (gint)event->x_root - task->frame_width /
+ (2*DRAG_WINDOW_SCALE),
+ (gint)event->y_root - task->frame_width /
+ (2*DRAG_WINDOW_SCALE));
+ }
+ }else{
+
+
+ if(desktop->drag_window){
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ gwmh_task_deiconify(desktop->grab_task);
+ }
+
+ task = desktop->grab_task;
+
+
+
+ if (task && !GWMH_TASK_UPDATE_QUEUED (task))
+ {
+
+ gdk_window_move (task->gdkwindow,
+ desktop->x_comp +
+ desktop->x_spixels * (x - desktop->x_origin),
+ desktop->y_comp +
+ desktop->y_spixels * (y - desktop->y_origin));
+ gdk_flush ();
+ }
}
-
+
return TRUE;
}
-
-static gboolean
+
+ static gboolean
gwm_desktop_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GwmDesktop *desktop = GWM_DESKTOP (widget);
-
- desktop->grab_task = NULL;
-
+ GwmhTask *task;
+ if(event->button == 2){
+ if(desktop->drag_window){
+ task = desktop->grab_task;
+ gtk_widget_destroy(GTK_WIDGET(desktop->drag_window));
+ desktop->drag_window = NULL;
+ gdk_window_move(task->gdkwindow,
+ event->x_root - task->frame_width / 2,
+ event->y_root - task->frame_height / 2);
+
+ gwmh_task_deiconify(desktop->grab_task);
+ }
+ desktop->grab_task = NULL;
+ }
return TRUE;
}
@@ -709,6 +810,7 @@
gint x, y;
gboolean current = desk->current_desktop == index;
GList *node;
+
#if 0
g_print ("REDRAW DESKTOP %d\n", index);
@@ -718,6 +820,22 @@
desktop->y_spixels = sheight / area_height;
gdk_flush ();
+
+ /* draw onto the drag_window
+ maybe this can have a pixbuf scaled shot of the window on it
+ some day - though this could be a bit heavy weight.
+ */
+ if (desktop->drag_window){
+ GwmhTask *task = desktop->grab_task;
+ gtk_draw_box (style, GTK_WIDGET(desktop->drag_window)->window,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_ETCHED_IN,
+ 1,
+ 1,
+ task->frame_width / DRAG_WINDOW_SCALE - 2,
+ task->frame_height / DRAG_WINDOW_SCALE - 2);
+ }
+
/* clear out */
gtk_draw_box (style,
Index: applets/desk-guide/gwmdesktop.h
===================================================================
RCS file: /cvs/gnome/gnome-core/applets/desk-guide/gwmdesktop.h,v
retrieving revision 1.4
diff -u -r1.4 gwmdesktop.h
--- applets/desk-guide/gwmdesktop.h 1999/09/23 19:38:47 1.4
+++ applets/desk-guide/gwmdesktop.h 2000/05/08 20:59:16
@@ -62,6 +62,7 @@
gint16 x_comp;
gint16 y_comp;
GwmhTask *grab_task;
+ GtkWindow *drag_window;
};
struct _GwmDesktopClass
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]