Commit 0ab0a9e8 authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

Disable hardware layers when software ARGB cursor is used



The modern desktops may use ARGB cursors. As the current
sunxi display controller support code can't handle this
type of cursor yet, the X server fallbacks to a software
cursor which is not visible under layers and ruining user
experience.

This patch adds empty implementations for "UseHWCursorARGB"
and "LoadCursorARGB" functions which just return error for
now (so that the X server still fallbacks to software cursor).
However we also introduce callback functions responsible for
notifying the DRI2 code about enabling/disabling the use of
hardware cursor. So that now hardware overlays are disabled
when switching to software cursor and re-enabled again when
switching back to hardware cursor.
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 8507947e
...@@ -59,8 +59,24 @@ static void SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) ...@@ -59,8 +59,24 @@ static void SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
static void LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits) static void LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits)
{ {
SunxiDispHardwareCursor *private = SUNXI_DISP_HWC(pScrn);
sunxi_disp_t *disp = SUNXI_DISP(pScrn); sunxi_disp_t *disp = SUNXI_DISP(pScrn);
sunxi_hw_cursor_load_pixeldata(disp, bits); sunxi_hw_cursor_load_pixeldata(disp, bits);
if (private->EnableHWCursor)
(*private->EnableHWCursor) (pScrn);
}
static Bool UseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiDispHardwareCursor *private = SUNXI_DISP_HWC(pScrn);
if (private->DisableHWCursor)
(*private->DisableHWCursor) (pScrn);
return FALSE;
}
static void LoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs)
{
} }
SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen) SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen)
...@@ -88,6 +104,9 @@ SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen) ...@@ -88,6 +104,9 @@ SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen)
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
HARDWARE_CURSOR_ARGB; HARDWARE_CURSOR_ARGB;
InfoPtr->UseHWCursorARGB = UseHWCursorARGB;
InfoPtr->LoadCursorARGB = LoadCursorARGB;
if (!xf86InitCursor(pScreen, InfoPtr)) { if (!xf86InitCursor(pScreen, InfoPtr)) {
ErrorF("SunxiDispHardwareCursor_Init: xf86InitCursor(pScreen, InfoPtr) failed\n"); ErrorF("SunxiDispHardwareCursor_Init: xf86InitCursor(pScreen, InfoPtr) failed\n");
xf86DestroyCursorInfoRec(InfoPtr); xf86DestroyCursorInfoRec(InfoPtr);
......
...@@ -26,8 +26,13 @@ ...@@ -26,8 +26,13 @@
#include "xf86Cursor.h" #include "xf86Cursor.h"
typedef void (*EnableHWCursorProcPtr)(ScrnInfoPtr pScrn);
typedef void (*DisableHWCursorProcPtr)(ScrnInfoPtr pScrn);
typedef struct { typedef struct {
xf86CursorInfoPtr hwcursor; xf86CursorInfoPtr hwcursor;
EnableHWCursorProcPtr EnableHWCursor;
DisableHWCursorProcPtr DisableHWCursor;
} SunxiDispHardwareCursor; } SunxiDispHardwareCursor;
SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen); SunxiDispHardwareCursor *SunxiDispHardwareCursor_Init(ScreenPtr pScreen);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "fbdev_priv.h" #include "fbdev_priv.h"
#include "sunxi_disp.h" #include "sunxi_disp.h"
#include "sunxi_disp_hwcursor.h"
#include "sunxi_disp_ioctl.h" #include "sunxi_disp_ioctl.h"
#include "sunxi_mali_ump_dri2.h" #include "sunxi_mali_ump_dri2.h"
...@@ -446,6 +447,16 @@ static void UpdateOverlay(ScreenPtr pScreen) ...@@ -446,6 +447,16 @@ static void UpdateOverlay(ScreenPtr pScreen)
if (!self->pOverlayWin || !disp) if (!self->pOverlayWin || !disp)
return; return;
/* Disable overlays if the hardware cursor is not in use */
if (!self->bHardwareCursorIsInUse) {
if (self->bOverlayWinEnabled) {
DebugMsg("Disabling overlay (no hardware cursor)\n");
sunxi_layer_hide(disp);
self->bOverlayWinEnabled = FALSE;
}
return;
}
/* If the window is not mapped, make sure that the overlay is disabled */ /* If the window is not mapped, make sure that the overlay is disabled */
if (!self->pOverlayWin->mapped) if (!self->pOverlayWin->mapped)
{ {
...@@ -599,12 +610,45 @@ DestroyPixmap(PixmapPtr pPixmap) ...@@ -599,12 +610,45 @@ DestroyPixmap(PixmapPtr pPixmap)
return result; return result;
} }
static void EnableHWCursor(ScrnInfoPtr pScrn)
{
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
self->bHardwareCursorIsInUse = TRUE;
UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]);
DebugMsg("EnableHWCursor\n");
if (self->EnableHWCursor) {
hwc->EnableHWCursor = self->EnableHWCursor;
(*hwc->EnableHWCursor) (pScrn);
self->EnableHWCursor = hwc->EnableHWCursor;
hwc->EnableHWCursor = EnableHWCursor;
}
}
static void DisableHWCursor(ScrnInfoPtr pScrn)
{
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
self->bHardwareCursorIsInUse = FALSE;
UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]);
DebugMsg("DisableHWCursor\n");
if (self->DisableHWCursor) {
hwc->DisableHWCursor = self->DisableHWCursor;
(*hwc->DisableHWCursor) (pScrn);
self->DisableHWCursor = hwc->DisableHWCursor;
hwc->DisableHWCursor = DisableHWCursor;
}
}
SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay) SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
{ {
int drm_fd; int drm_fd;
DRI2InfoRec info; DRI2InfoRec info;
ump_secure_id ump_id1, ump_id2, ump_id_fb; ump_secure_id ump_id1, ump_id2, ump_id_fb;
sunxi_disp_t *disp = SUNXI_DISP(xf86Screens[pScreen->myNum]); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
sunxi_disp_t *disp = SUNXI_DISP(pScrn);
ump_id1 = ump_id2 = ump_id_fb = UMP_INVALID_SECURE_ID; ump_id1 = ump_id2 = ump_id_fb = UMP_INVALID_SECURE_ID;
if (disp && bUseOverlay) { if (disp && bUseOverlay) {
...@@ -663,6 +707,7 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay) ...@@ -663,6 +707,7 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
return NULL; return NULL;
} }
else { else {
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
SunxiMaliDRI2 *private = calloc(1, sizeof(SunxiMaliDRI2)); SunxiMaliDRI2 *private = calloc(1, sizeof(SunxiMaliDRI2));
/* Wrap the current DestroyWindow function */ /* Wrap the current DestroyWindow function */
...@@ -678,6 +723,14 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay) ...@@ -678,6 +723,14 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
private->DestroyPixmap = pScreen->DestroyPixmap; private->DestroyPixmap = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = DestroyPixmap; pScreen->DestroyPixmap = DestroyPixmap;
/* Wrap hardware cursor callback functions */
if (hwc) {
private->EnableHWCursor = hwc->EnableHWCursor;
hwc->EnableHWCursor = EnableHWCursor;
private->DisableHWCursor = hwc->DisableHWCursor;
hwc->DisableHWCursor = DisableHWCursor;
}
private->ump_fb_secure_id = ump_id_fb; private->ump_fb_secure_id = ump_id_fb;
private->drm_fd = drm_fd; private->drm_fd = drm_fd;
return private; return private;
...@@ -688,6 +741,7 @@ void SunxiMaliDRI2_Close(ScreenPtr pScreen) ...@@ -688,6 +741,7 @@ void SunxiMaliDRI2_Close(ScreenPtr pScreen)
{ {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
/* Unwrap functions */ /* Unwrap functions */
pScreen->DestroyWindow = private->DestroyWindow; pScreen->DestroyWindow = private->DestroyWindow;
...@@ -695,6 +749,11 @@ void SunxiMaliDRI2_Close(ScreenPtr pScreen) ...@@ -695,6 +749,11 @@ void SunxiMaliDRI2_Close(ScreenPtr pScreen)
pScreen->GetImage = private->GetImage; pScreen->GetImage = private->GetImage;
pScreen->DestroyPixmap = private->DestroyPixmap; pScreen->DestroyPixmap = private->DestroyPixmap;
if (hwc) {
hwc->EnableHWCursor = private->EnableHWCursor;
hwc->DisableHWCursor = private->DisableHWCursor;
}
drmClose(private->drm_fd); drmClose(private->drm_fd);
DRI2CloseScreen(pScreen); DRI2CloseScreen(pScreen);
} }
...@@ -57,6 +57,10 @@ typedef struct { ...@@ -57,6 +57,10 @@ typedef struct {
Bool bOverlayWinOverlapped; Bool bOverlayWinOverlapped;
Bool bWalkingAboveOverlayWin; Bool bWalkingAboveOverlayWin;
Bool bHardwareCursorIsInUse;
EnableHWCursorProcPtr EnableHWCursor;
DisableHWCursorProcPtr DisableHWCursor;
DestroyWindowProcPtr DestroyWindow; DestroyWindowProcPtr DestroyWindow;
PostValidateTreeProcPtr PostValidateTree; PostValidateTreeProcPtr PostValidateTree;
GetImageProcPtr GetImage; GetImageProcPtr GetImage;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment