Changeset 7112
- Timestamp:
- Nov 15, 2008, 4:38:31 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/main.c
r7106 r7112 109 109 struct cbdata 110 110 { 111 gboolean minimized;112 gboolean closing;111 unsigned int isIconified : 1; 112 unsigned int isClosing : 1; 113 113 guint timer; 114 guint idle_hide_mainwindow_tag;115 114 gpointer icon; 116 115 GtkWindow * wind; … … 264 263 pref_int_set( PREF_KEY_MAIN_WINDOW_WIDTH, w ); 265 264 pref_int_set( PREF_KEY_MAIN_WINDOW_HEIGHT, h ); 266 }267 }268 269 static void270 windowStateChanged( GtkWidget * widget UNUSED,271 GdkEventWindowState * event,272 gpointer gdata )273 {274 if( event->changed_mask & GDK_WINDOW_STATE_ICONIFIED )275 {276 struct cbdata * cbdata = gdata;277 cbdata->minimized =278 ( event->new_window_state &279 GDK_WINDOW_STATE_ICONIFIED ) ? 1 : 0;280 265 } 281 266 } … … 487 472 /* create main window now to be a parent to any error dialogs */ 488 473 win = GTK_WINDOW( tr_window_new( myUIManager, cbdata->core ) ); 489 g_signal_connect( win, "window-state-event",490 G_CALLBACK( windowStateChanged ), cbdata );491 474 g_signal_connect( win, "size-allocate", 492 475 G_CALLBACK( onMainWindowSizeAllocated ), cbdata ); … … 604 587 struct cbdata * cbdata, 605 588 gboolean forcepause, 606 gboolean minimized )589 gboolean isIconified ) 607 590 { 608 591 const pref_flag_t start = … … 611 594 612 595 /* fill out cbdata */ 613 cbdata->wind = NULL;614 cbdata->icon = NULL;615 cbdata->msgwin = NULL;616 cbdata->prefs = NULL;617 cbdata->timer = 0;618 cbdata-> closing = FALSE;619 cbdata->errqueue = NULL;620 cbdata->dupqueue = NULL;621 cbdata-> minimized = minimized;622 623 if( minimized )596 cbdata->wind = NULL; 597 cbdata->icon = NULL; 598 cbdata->msgwin = NULL; 599 cbdata->prefs = NULL; 600 cbdata->timer = 0; 601 cbdata->isClosing = 0; 602 cbdata->errqueue = NULL; 603 cbdata->dupqueue = NULL; 604 cbdata->isIconified = isIconified; 605 606 if( isIconified ) 624 607 pref_flag_set( PREF_KEY_SHOW_TRAY_ICON, TRUE ); 625 608 … … 657 640 658 641 /* either show the window or iconify it */ 659 if( ! minimized )642 if( !isIconified ) 660 643 gtk_widget_show( GTK_WIDGET( wind ) ); 661 644 else … … 667 650 } 668 651 669 /** 670 * hideMainWindow, and the timeout hack in toggleMainWindow, 671 * are loosely cribbed from Colin Walters' rb-shell.c in Rhythmbox 672 */ 673 static gboolean 674 idle_hide_mainwindow( gpointer window ) 675 { 676 gtk_widget_hide( window ); 677 return FALSE; 678 } 679 680 static void 681 hideMainWindow( struct cbdata * cbdata ) 682 { 683 #if defined( STATUS_ICON_SUPPORTED ) && defined( GDK_WINDOWING_X11 ) 684 GdkRectangle bounds; 685 gulong data[4]; 686 Display * dpy; 687 GdkWindow * gdk_window; 688 689 gtk_status_icon_get_geometry( GTK_STATUS_ICON( 690 cbdata->icon ), NULL, &bounds, NULL ); 691 gdk_window = GTK_WIDGET ( cbdata->wind )->window; 692 dpy = gdk_x11_drawable_get_xdisplay ( gdk_window ); 693 694 data[0] = bounds.x; 695 data[1] = bounds.y; 696 data[2] = bounds.width; 697 data[3] = bounds.height; 698 699 XChangeProperty ( dpy, 700 GDK_WINDOW_XID ( gdk_window ), 701 gdk_x11_get_xatom_by_name_for_display ( 702 gdk_drawable_get_display ( gdk_window ), 703 "_NET_WM_ICON_GEOMETRY" ), 704 XA_CARDINAL, 32, PropModeReplace, 705 (guchar*)&data, 4 ); 706 707 gtk_window_set_skip_taskbar_hint( cbdata->wind, TRUE ); 652 static void 653 tr_window_present( GtkWindow * window ) 654 { 655 #if GTK_CHECK_VERSION( 2, 8, 0 ) 656 gtk_window_present_with_time( window, gtk_get_current_event_time( ) ); 657 #else 658 gtk_window_present( window ); 708 659 #endif 709 gtk_window_iconify( cbdata->wind );710 }711 712 static void713 clearTag( guint * tag )714 {715 if( *tag )716 g_source_remove( *tag );717 *tag = 0;718 660 } 719 661 720 662 static void 721 663 toggleMainWindow( struct cbdata * cbdata, 722 gboolean present )664 gboolean doPresent ) 723 665 { 724 666 GtkWindow * window = GTK_WINDOW( cbdata->wind ); 725 const int hide = !cbdata->minimized; 726 static int x = 0, y = 0; 727 728 if( ( !present ) && hide ) 667 const int doShow = cbdata->isIconified; 668 static int x = 0; 669 static int y = 0; 670 671 if( doShow || doPresent ) 672 { 673 cbdata->isIconified = 0; 674 gtk_window_set_skip_taskbar_hint( window, FALSE ); 675 gtk_window_move( window, x, y ); 676 gtk_widget_show( GTK_WIDGET( window ) ); 677 tr_window_present( window ); 678 } 679 else 729 680 { 730 681 gtk_window_get_position( window, &x, &y ); 731 clearTag( &cbdata->idle_hide_mainwindow_tag ); 732 hideMainWindow( cbdata ); 733 cbdata->idle_hide_mainwindow_tag = g_timeout_add( 734 100, idle_hide_mainwindow, window ); 735 } 736 else 737 { 738 gtk_window_set_skip_taskbar_hint( window, FALSE ); 739 if( x != 0 && y != 0 ) 740 gtk_window_move( window, x, y ); 741 gtk_widget_show( GTK_WIDGET( window ) ); 742 gtk_window_deiconify( window ); 743 #if GTK_CHECK_VERSION( 2, 8, 0 ) 744 gtk_window_present_with_time( window, gtk_get_current_event_time( ) ); 745 #else 746 gtk_window_present( window ); 747 #endif 682 gtk_window_set_skip_taskbar_hint( window, TRUE ); 683 gtk_widget_hide( GTK_WIDGET( window ) ); 684 cbdata->isIconified = 1; 748 685 } 749 686 } … … 1239 1176 { 1240 1177 struct cbdata *data = gdata; 1241 const gboolean done = data-> closing || global_sigcount;1178 const gboolean done = data->isClosing || global_sigcount; 1242 1179 1243 1180 if( !done )
Note: See TracChangeset
for help on using the changeset viewer.