~mike82/window-picker-applet/fixes

« back to all changes in this revision

Viewing changes to src/task-list.c

  • Committer: Michael
  • Date: 2009-01-13 10:41:42 UTC
  • Revision ID: mike@rsy.com-20090113104142-4nvte0zjeddy7k86
Set the minimize hints (icon geometry) of windows so that the window manager can render the correct minimization and maximization animations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
};
54
54
static const gint n_drop_types = G_N_ELEMENTS(drop_types);
55
55
 
 
56
static void
 
57
set_minimize_hints (TaskList *list)
 
58
{
 
59
  TaskListPrivate *priv;
 
60
  GHashTableIter it;
 
61
  WnckWindow *window;
 
62
  GtkWidget *button, *parent;
 
63
  gint x, y, x1, y1;
 
64
 
 
65
  g_return_if_fail (TASK_IS_LIST (list));
 
66
  priv = list->priv;
 
67
 
 
68
  /* Iterate through the known windows */
 
69
  g_hash_table_iter_init (&it, priv->win_table);
 
70
  while (g_hash_table_iter_next (&it, (gpointer*)&window, (gpointer*)&button))
 
71
  {
 
72
    /* Skip problems */
 
73
    if (!WNCK_IS_WINDOW (window)) continue;
 
74
    if (!GTK_IS_WIDGET (button)) continue;
 
75
 
 
76
    /* Skip invisible windows */
 
77
    if (!GTK_WIDGET_VISIBLE (button)) continue;
 
78
 
 
79
    x = y = 0;
 
80
 
 
81
    /* Recursively compute the button's coordinates */
 
82
    for (parent = button; parent; parent = parent->parent)
 
83
    {
 
84
      if (parent->parent)
 
85
      {
 
86
        x += parent->allocation.x;
 
87
        y += parent->allocation.y;
 
88
      }
 
89
      else
 
90
      {
 
91
        x1 = y1 = 0;
 
92
        gdk_window_get_origin (parent->window, &x1, &y1);
 
93
        x += x1; y += y1;
 
94
        break;
 
95
      }
 
96
    }
 
97
 
 
98
    /* Set the minimize hint for the window */
 
99
    wnck_window_set_icon_geometry (window, x, y,
 
100
                                   button->allocation.width,
 
101
                                   button->allocation.height);
 
102
  }
 
103
}
 
104
 
56
105
/*
57
106
 * Show all windows code 
58
107
 */
83
132
  }
84
133
  g_list_free (children);
85
134
 
 
135
  /* Re-set minimize hints */
 
136
  set_minimize_hints (list);
 
137
 
86
138
  return FALSE;
87
139
}
88
140
 
290
342
 
291
343
  /* Check if the button should be hidden */
292
344
  if (wnck_window_is_skip_tasklist (window)
293
 
      || current
 
345
      || (current
294
346
      && !wnck_window_is_on_workspace (window, current)
295
 
      && !priv->show_all_windows)
 
347
      && !priv->show_all_windows))
296
348
    gtk_widget_hide (button);
297
349
  else
298
350
  {
311
363
  /* Update the button's state */
312
364
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
313
365
    wnck_screen_get_active_window (priv->screen) == window);
 
366
 
 
367
  /* Re-set minimize hints */
 
368
  set_minimize_hints (list);
314
369
}
315
370
 
316
371
 
372
427
  /* Do an initial state change to avoid code duplication here */
373
428
  on_state_changed (window, 0xFFFFFFFF, wnck_window_get_state (window), list);
374
429
 
375
 
  /* Activate the window if it's button is visible (why??) */
 
430
  /* Show the window if it's button is visible (why??) */
376
431
  if (GTK_WIDGET_VISIBLE (button))
377
432
    wnck_window_activate (window, GDK_CURRENT_TIME);
378
433
}
394
449
    gtk_widget_destroy (button);
395
450
 
396
451
  g_hash_table_remove (priv->win_table, window);
 
452
 
 
453
  /* Set minimize hints */
 
454
  set_minimize_hints (list);
397
455
}
398
456
 
399
457
static void