Added special setActive() and setInactive() functions.

They handle both focus and highlight, which seems logical.

This fixes most annoying bugs with desktop switching.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/8/head
Mavridis Philippe 3 years ago
parent cc13befa92
commit b5e39bb95f
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -109,48 +109,53 @@ void KomposeDesktopWidget::initFonts()
// return (double)deskRect.width() / (double)deskRect.height();
// }
void KomposeDesktopWidget::setInactive()
{
if( hasFocus() )
clearFocus();
highlight = false;
repaint();
}
void KomposeDesktopWidget::setActive()
{
if( !hasFocus() )
setFocus();
highlight = true;
repaint();
}
void KomposeDesktopWidget::leaveEvent ( TQEvent * )
{
// Unset highlight if cursor moves out of our rect
unsetCursor();
// Mark desktop as inactive if cursor moves out of our rect
// but not if it enters a child widget
TQRect deskRect;
deskRect.setTopLeft(mapToGlobal( TQPoint(0,0) ));
deskRect.setWidth(width());
deskRect.setHeight(height());
if ( !deskRect.contains( TQCursor::pos() ) )
highlight = false;
unsetCursor();
repaint();
setInactive();
}
void KomposeDesktopWidget::enterEvent ( TQEvent * )
{
setFocus();
setCursor( KCursor::handCursor() );
highlight = true;
repaint();
setActive();
}
void KomposeDesktopWidget::focusInEvent ( TQFocusEvent * )
{
highlight = true;
repaint();
setActive();
}
void KomposeDesktopWidget::focusOutEvent ( TQFocusEvent * )
{
// Unset highlight if cursor moves out of our rect
// but not if it enters a child widget
TQRect deskRect;
deskRect.setTopLeft(mapToGlobal( TQPoint(0,0) ));
deskRect.setWidth(width());
deskRect.setHeight(height());
if ( !deskRect.contains( TQCursor::pos() ) )
highlight = false;
repaint();
setInactive();
}
void KomposeDesktopWidget::mouseReleaseEvent ( TQMouseEvent * e )

@ -36,6 +36,9 @@ public:
~KomposeDesktopWidget();
void setInactive();
void setActive();
// int getHeightForWidth( int w ) const;
// int getWidthForHeight( int h ) const;
// double getAspectRatio();

Loading…
Cancel
Save