diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7d9ebc0..3592045 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -838,9 +838,44 @@
     protected void onFinishBindingItems() {
     }
 
+    QSBScroller mQsbScroller = new QSBScroller() {
+        int scrollY = 0;
+
+        @Override
+        public void setScrollY(int scroll) {
+            scrollY = scroll;
+
+            if (mWorkspace.isOnOrMovingToCustomContent()) {
+                mSearchDropTargetBar.setTranslationY(- scrollY);
+            }
+        }
+    };
+
+    public void resetQSBScroll() {
+        mSearchDropTargetBar.animate().translationY(0).start();
+    }
+
+    public interface CustomContentCallbacks {
+        // Custom content is completely shown
+        public void onShow();
+
+        // Custom content is completely hidden
+        public void onHide();
+    }
+
+    public interface QSBScroller {
+        public void setScrollY(int scrollY);
+    }
+
     // Add a fullscreen unpadded view to the workspace to the left all other screens.
-    public void addCustomContentToLeft(View customContent) {
-        mWorkspace.addCustomContentToLeft(customContent);
+    public QSBScroller addCustomContentToLeft(View customContent) {
+        return addCustomContentToLeft(customContent, null);
+    }
+
+    public QSBScroller addCustomContentToLeft(View customContent,
+            CustomContentCallbacks callbacks) {
+        mWorkspace.addCustomContentToLeft(customContent, callbacks);
+        return mQsbScroller;
     }
 
     // The custom content needs to offset its content to account for the QSB
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index b8ef6b1..edf3721 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -56,6 +56,7 @@
 import android.widget.TextView;
 
 import com.android.launcher3.FolderIcon.FolderRingAnimator;
+import com.android.launcher3.Launcher.CustomContentCallbacks;
 import com.android.launcher3.LauncherSettings.Favorites;
 
 import java.net.URISyntaxException;
@@ -98,8 +99,6 @@
     boolean mDrawBackground = true;
     private float mBackgroundAlpha = 0;
 
-    private float mWallpaperScrollRatio = 1.0f;
-
     private LayoutTransition mLayoutTransition;
     private final WallpaperManager mWallpaperManager;
     private IBinder mWindowToken;
@@ -129,6 +128,9 @@
     static Rect mLandscapeCellLayoutMetrics = null;
     static Rect mPortraitCellLayoutMetrics = null;
 
+    CustomContentCallbacks mCustomContentCallbacks;
+    boolean mCustomContentShowing;
+
     /**
      * The CellLayout that is currently being dragged over
      */
@@ -526,7 +528,7 @@
         return screenId;
     }
 
-    public void addCustomContentToLeft(View customContent) {
+    public void addCustomContentToLeft(View customContent, CustomContentCallbacks callbacks) {
         CellLayout customScreen = (CellLayout)
                 mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
 
@@ -541,17 +543,13 @@
         Rect p = new Rect();
         AppWidgetHostView.getDefaultPaddingForWidget(mLauncher, mLauncher.getComponentName(), p);
 
-        // For now we force top padding on the entire custom content screen. The intention
-        // is for the hosted content to get this offset and account for it so that upon scrolling
-        // it can use the entire space.
-        customContent.setPadding(p.left, mLauncher.getTopOffsetForCustomContent(),
-                p.right, p.bottom);
-
         mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
         mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);
 
         addFullScreenPage(customScreen);
 
+        mCustomContentCallbacks = callbacks;
+
         // Ensure that the current page and default page are maintained.
         mDefaultPage++;
         setCurrentPage(getCurrentPage() + 1);
@@ -937,6 +935,19 @@
     protected void notifyPageSwitchListener() {
         super.notifyPageSwitchListener();
         Launcher.setScreen(mCurrentPage);
+
+        if (hasCustomContent() && mCurrentPage == 0) {
+            mCustomContentShowing = true;
+            if (mCustomContentCallbacks != null) {
+                mCustomContentCallbacks.onShow();
+            }
+        } else if (hasCustomContent() && mCustomContentShowing) {
+            mCustomContentShowing = false;
+            if (mCustomContentCallbacks != null) {
+                mCustomContentCallbacks.onHide();
+                mLauncher.resetQSBScroll();
+            }
+        }
     };
 
     // As a ratio of screen height, the total distance we want the parallax effect to span
@@ -966,11 +977,6 @@
         return x * aspectRatio + y;
     }
 
-    // The range of scroll values for Workspace
-    private int getScrollRange() {
-        return getChildOffset(getChildCount() - 1) - getChildOffset(0);
-    }
-
     protected void setWallpaperDimension() {
         Point minDims = new Point();
         Point maxDims = new Point();
@@ -995,33 +1001,6 @@
         }.start();
     }
 
-    private float wallpaperOffsetForCurrentScroll() {
-        // Set wallpaper offset steps (1 / (number of screens - 1))
-        mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 1.0f);
-
-        int scrollRange = getScrollRange();
-
-        float adjustedScrollX = Math.max(0, Math.min(getScrollX(), mMaxScrollX));
-        adjustedScrollX *= mWallpaperScrollRatio;
-
-        float scrollProgress =
-            adjustedScrollX / (float) scrollRange;
-
-        if (LauncherAppState.getInstance().isScreenLarge() && mIsStaticWallpaper) {
-            // The wallpaper travel width is how far, from left to right, the wallpaper will move
-            // at this orientation. On tablets in portrait mode we don't move all the way to the
-            // edges of the wallpaper, or otherwise the parallax effect would be too strong.
-            int wallpaperTravelWidth = Math.min(mWallpaperTravelWidth, mWallpaperWidth);
-
-            float offsetInDips = wallpaperTravelWidth * scrollProgress +
-                (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it
-            float offset = offsetInDips / (float) mWallpaperWidth;
-            return offset;
-        } else {
-            return scrollProgress;
-        }
-    }
-
     private void syncWallpaperOffsetWithScroll() {
         final boolean enableWallpaperEffects = isHardwareAccelerated();
         if (enableWallpaperEffects) {
@@ -1317,6 +1296,10 @@
         return (mScreenOrder.size() > 0 && mScreenOrder.get(0) == CUSTOM_CONTENT_SCREEN_ID);
     }
 
+    public boolean isOnOrMovingToCustomContent() {
+        return hasCustomContent() && getNextPage() == 0;
+    }
+
     private void updateStateForCustomContent(int screenCenter) {
         if (hasCustomContent()) {
             CellLayout customContent = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
