Ticket #5: notification-daemon_xinerama.patch

  • src/daemon.c

    old new  
    560560static gboolean 
    561561get_work_area(GtkWidget *nw, GdkRectangle *rect) 
    562562{ 
    563     Atom workarea = XInternAtom(GDK_DISPLAY(), "_NET_WORKAREA", True); 
    564     Atom type; 
    565     Window win; 
    566     int format; 
    567     gulong num, leftovers; 
    568     gulong max_len = 4 * 32; 
    569     guchar *ret_workarea; 
    570     long *workareas; 
    571     int result; 
    572563    GdkScreen *screen; 
    573     int disp_screen
     564    gint n_monitors
    574565 
    575566    gtk_widget_realize(nw); 
    576567    screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window)); 
    577     disp_screen = GDK_SCREEN_XNUMBER(screen); 
    578  
    579     /* Defaults in case of error */ 
    580     rect->x = 0; 
    581     rect->y = 0; 
    582     rect->width = gdk_screen_get_width(screen); 
    583     rect->height = gdk_screen_get_height(screen); 
     568    n_monitors = gdk_screen_get_n_monitors(screen); 
    584569 
    585     if (workarea == None) 
    586         return FALSE; 
    587  
    588     win = XRootWindow(GDK_DISPLAY(), disp_screen); 
    589     result = XGetWindowProperty(GDK_DISPLAY(), win, workarea, 0, 
    590                                 max_len, False, AnyPropertyType, 
    591                                 &type, &format, &num, &leftovers, 
    592                                 &ret_workarea); 
    593  
    594     if (result != Success || type == None || format == 0 || leftovers || 
    595         num % 4) 
    596     { 
    597         return FALSE; 
     570        /* find the geometry of the right most monitor */ 
     571    gint max_x = 0; 
     572    gint n; 
     573    for (n = 0; n < n_monitors; ++n) 
     574    { 
     575        GdkRectangle n_geom; 
     576        gdk_screen_get_monitor_geometry(screen, n, &n_geom); 
     577        if (n_geom.x + n_geom.width > max_x) 
     578        { 
     579            rect->x = n_geom.x; 
     580            rect->y = n_geom.y; 
     581            rect->width = n_geom.width; 
     582            rect->height = n_geom.height; 
     583            max_x = n_geom.x + n_geom.width; 
     584        } 
    598585    } 
    599  
    600     workareas = (long *)ret_workarea; 
    601     rect->x      = workareas[disp_screen * 4]; 
    602     rect->y      = workareas[disp_screen * 4 + 1]; 
    603     rect->width  = workareas[disp_screen * 4 + 2]; 
    604     rect->height = workareas[disp_screen * 4 + 3]; 
    605  
    606     XFree(ret_workarea); 
    607  
    608586    return TRUE; 
    609587} 
    610588