Showing posts with label compiz fusion. Show all posts
Showing posts with label compiz fusion. Show all posts

Wednesday, October 6, 2010

Gnome Decent Dual Monitor Wallpaper Span

Tired of trying to use compiz to have wallpaper span both screens, only to find your desktop icons disappear?

A few months ago I embarked on a relentless search through mountains of RGBA patches, custom versions of nautilus, and failed attempts at allowing desktop icons to pierce through compiz's iron curtain.

Finally created a decent method of having wallpaper span dual monitors in Gnome by overriding Gnome's "Spanned" desktop setting (I don't think it works right anyway) with a "Zoomed" dual monitor setting.  I first tried this by scaling the image directly, but it looked like crap so I figure Zoom would be better to use.  The result is not perfect, but definitely better than waiting 15 years for the Gnome team to come up with a plausible solution.

The steps I took were for Arch Linux, but you can apply them equally well to any distribution, as long as you know how to make packages from source.

After reading through this bug, I realized I should be modifying the desktop settings directly.

I checked my Gnome version through pacman, and proceeded to download the PKGBUILD straight from the Arch SVN.  After receiving the source code, I ran "makepkg" once to ensure the source would compile properly, then proceeded to comment out the following lines in the PKGBUILD file:

#source=(http://ftp.gnome.org/pub/gnome/sources/${pkgname}/2.32/${pkgname}-${pkgver}.tar.bz2)
#sha256sums=('blahblah')

To ensure that the source code would not be downloaded again & overwrite my modifications.

Next, I proceeded to open the "src/gnome-desktop-2.32.0/libgnome-desktop/gnome-bg.c" file, and commented out the following line, simply copying the Gnome "Zoom" option's code to the "Span" section of the case statement:

#if 0
    g_print ("original_width: %d %d\n",
         gdk_pixbuf_get_width (pixbuf),
         gdk_pixbuf_get_height (pixbuf));
#endif
   
    switch (placement) {
    case GNOME_BG_PLACEMENT_SPANNED:
                // new = pixbuf_scale_to_fit (pixbuf, width, height);
        new = pixbuf_scale_to_min (pixbuf, width, height);
        break;
    case GNOME_BG_PLACEMENT_ZOOMED:
        new = pixbuf_scale_to_min (pixbuf, width, height);
        break;
       
    case GNOME_BG_PLACEMENT_FILL_SCREEN:
        new = gdk_pixbuf_scale_simple (pixbuf, width, height,
                           GDK_INTERP_BILINEAR);
        break;
       
    case GNOME_BG_PLACEMENT_SCALED:
        new = pixbuf_scale_to_fit (pixbuf, width, height);
        break;
       
    case GNOME_BG_PLACEMENT_CENTERED:
    case GNOME_BG_PLACEMENT_TILED:
    default:
        new = pixbuf_clip_to_fit (pixbuf, width, height);
        break;
    } 
Finally, in the next section continaing the "GNOME_BG_PLACEMENT_SPANNED" (around 20 lines down from the previous section), I made the following modification to the code--commenting out what is commented in blue, and replaced with the code in red:

    scaled = get_scaled_pixbuf (placement, pixbuf, dest_width, dest_height, &x, &y, &w, &h);

    switch (placement) {
    case GNOME_BG_PLACEMENT_TILED:
        pixbuf_tile (scaled, dest);
        break;
    case GNOME_BG_PLACEMENT_ZOOMED:
    case GNOME_BG_PLACEMENT_CENTERED:
    case GNOME_BG_PLACEMENT_FILL_SCREEN:
    case GNOME_BG_PLACEMENT_SCALED:
        pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
        break;
    case GNOME_BG_PLACEMENT_SPANNED:
        // pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
        pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
        break;
    default:
        g_assert_not_reached ();
        break;
    }
   
    g_object_unref (scaled);

From here, I saved the source,  ran "makepkg -f" again, installed the package, and restarted Gnome.  Not perfect, but they are nice ;)

Sunday, August 30, 2009

Compiz Fusion + Xfce 4.6 + Slackware 12.2 + NVIDIA

This one should be relatively easy for people, but I'd just like to document the steps taken anyway--I had a bit of a time getting Compiz to start properly in Xfce.  Please note these are not best practices & are simply the steps to get compiz working for me.

First of all, navigate your browser over to: http://www.slackbuilds.org & run a search for "compiz," under version 12.2.  Your first result will be the "compiz-bcop" slackbuild.  Select it, which will show you a quick description of the package, and the suggested build order of all compiz packages:


Suggested build order:
1. compiz-bcop
2. libcompizconfig
3. compizconfig-backend-kconfig (optional)
4. compizconfig-backend-gconf (optional)
5. compizconfig-python
6. ccsm
7. simple-ccsm (optional)
8. compiz-fusion-plugins-main
9. compiz-fusion-plugins-extra (optional)
10. compiz-fusion-plugins-unsupported (optional)
11. emerald (optional)
12. emerald-themes (optional)
13. fusion-icon (optional)

Now, download it.  If you're unfamiliar with SlackBuilds, they're actually quite simple:
  1. Find which SlackBuild you'd like to download.  In this case, it's the "compiz-bcop" SlackBuild.  Please note that SlackBuilds do not contain the application's source, this is a separate download.
  2. Download "compiz-bcop.tar.gz," "compiz-bcop-0.7.8.tar.gz," (or other appropriate version) and optionally, the "compiz-bcop.tar.gz.asc" file.
  3. (Optional) If you chose to download the .asc file, you can verify the integrity of your SlackBuild by using the command gpg --verify compiz-bcop.tar.gz.asc
  4. Extract the SlackBuild with tar -zxvf compiz-bcop.tar.gz
  5. Move the source file, "compiz-bcop-0.7.8.tar.gz" into the newly extracted compiz-bcop directory, and extract this file too: tar -zxvf compiz-bcop-0.7.8.tar.gz
  6. Now all that's left to do is to run a quick root command of: su -c "./compiz-bcop.SlackBuild" or sudo ./compiz-bcop.SlackBuild
  7. You'll get some verbose build & other messages, which ultimately lead to a package created somewhere on your hard drive (in my case, which I believe is the default, the package created is /tmp/compiz-bcop-0.7.8-i486-1_SBo.tgz).
  8. Run a quick su -c "installpkg /tmp/compiz-bcop-0.7.8-i486-1_SBo.tgz" or sudo installpkg /tmp/compiz-bcop-0.7.8-i486-1_SBo.tgz to install the package.
Work your way down the suggested build order list, installing each SlackBuild respectively (see above).  In this case, we will install all the optional packages.  NOTE: I did have an issue downloading #12. emerald-themes (optional), which I chose to skip over.  You can find & install these themes if you'd like.

Now, being my guide is for NVIDIA video cards, I'm unable to give much direction on other cards.  To set up your card, head over to the Compiz Fusion Wiki: http://wiki.compiz-fusion.org/Hardware/NVIDIA and follow the steps for your appropriate driver version.

My /etc/X11/xorg.conf file's "Screen" section ended up look as such to get my extremely outdated GeForce MX 440 working:

# Allows GLX to work with composite.
Option         "AllowGLXWithComposite" "True"

# Improves performance, enabled by default on driver versions >=1.0-9746
Option         "RenderAccel" "True"
  
# Always force Hsync & Vsync regardless of the mode.
Option         "UseFBDev" "True"   

# I believe this was necessary to get window borders working as well.  Please correct me if wrong.
Option         "AddARGBVisuals" "True"

# Improves performance. Currently incompatible with SLI and MultiGPU modes. As of nvidia driver version 100.14.09, it has been enabled by default.
 Option         "DamageEvents" "True"

# Use the following option with caution as it may not work on all systems.
Option         "UseEvents" "False"  

# Use the following option with caution as it may not work on all systems, especially with 6 series GeForce cards (it is known to cause freezes with compiz) but give it a try because it helps performance. It can also break Xinerama.
Option         "BackingStore" "True"

# Necessary to make window borders visible with nvidia driver versions prior to 100.xx.
Option         "AddARGBGLXVisuals" "True"

NOTE: This will more than likely be different for your card, but these options work well with GeForce MX 440's :).

The next step will be to configure nvidia-settings to load your configuration at Xfce's start.  To do this, I wrote a very simple bash script:

#! /bin/bash
# Simple script to load NVIDIA settings on Xfce start.
nvidia-settings --load-config-only

Save this to ~/.init_nvidia, make make the file executable with the command: chmod +x ~/.init_nvidia and add it to your Xfce Settings->Sessions & Startup->Application Autostart tab.

Next time your restart your Xfce session, your NVIDIA settings will be loaded by default.

The next step is where I got tricked up, and want to document for anyone else who might be having issues.  I attempted running the command compiz --replace to replace xfwm4 with compiz, but it seemed as if the two were litterally fighting over managing my windows, getting stuck in an endless loop of switching back & forth between themselves.  After tinkering with this issue for hours, I found the simplest solution to RTFM.  I found the solution on (ha) Arch Linux's Wiki (http://wiki.archlinux.org/index.php/Compiz --using fusion icon, method 2).  The steps are very simple, but only work for the current user:

Edit ~/.config/xfce4-session/xfce4-session.rc and add the following to the bottom of the file:
    [Failsafe Session]
    Client0_Command=fusion-icon


    Comment out Client0_Command=xfwm4 if it exists.

    This should cause compiz to be loaded instead of xfwm4,
    though this didn't seem to work properly without a few extra steps.

    To prevent the default session from being overwritten add or change
    the [General] section to:
         
    [General]
    AutoSave=false
    SaveOnExit=false


    Now save the file.

    Back in Xfce Settings->Sessions and Startup->Application Autostart->Add a startup entry for the command fusion-icon

    Close Xfce & remove all current sessions with rm -rf ~/.cache/sessions
      Once Xfce comes up, your windows should no longer be managed by xfwm4, but (hopefully) instead, by compiz.

      Have fun :).