@@ -783,7 +783,7 @@ protected void updateNativeTitleBarHeightAndHitTestSpots() {
783783 List <Rectangle > hitTestSpots = new ArrayList <>();
784784 Rectangle appIconBounds = null ;
785785
786- if ( iconLabel .isVisible () ) {
786+ if ( ! showIconBesideTitle && iconLabel .isVisible () ) {
787787 // compute real icon size (without insets; 1px larger for easier hitting)
788788 Point location = SwingUtilities .convertPoint ( iconLabel , 0 , 0 , window );
789789 Insets iconInsets = iconLabel .getInsets ();
@@ -810,6 +810,38 @@ protected void updateNativeTitleBarHeightAndHitTestSpots() {
810810 hitTestSpots .add ( iconBounds );
811811 else
812812 appIconBounds = iconBounds ;
813+ } else if ( showIconBesideTitle && titleLabel .getIcon () != null && titleLabel .getUI () instanceof FlatTitleLabelUI ) {
814+ FlatTitleLabelUI ui = (FlatTitleLabelUI ) titleLabel .getUI ();
815+
816+ // compute real icon bounds
817+ Insets insets = titleLabel .getInsets ();
818+ Rectangle viewR = new Rectangle ( insets .left , insets .top ,
819+ titleLabel .getWidth () - insets .left - insets .right ,
820+ titleLabel .getHeight () - insets .top - insets .bottom );
821+ Rectangle iconR = new Rectangle ();
822+ Rectangle textR = new Rectangle ();
823+ ui .layoutCL ( titleLabel , titleLabel .getFontMetrics ( titleLabel .getFont () ),
824+ titleLabel .getText (), titleLabel .getIcon (),
825+ viewR , iconR , textR );
826+
827+ // Windows shows the window system menu only in the upper-left corner
828+ if ( iconR .x == 0 ) {
829+ // convert icon location to window coordinates
830+ Point location = SwingUtilities .convertPoint ( titleLabel , 0 , 0 , window );
831+ iconR .x += location .x ;
832+ iconR .y += location .y ;
833+
834+ // make icon bounds 1px larger for easier hitting
835+ iconR .x -= 1 ;
836+ iconR .y -= 1 ;
837+ iconR .width += 2 ;
838+ iconR .height += 2 ;
839+
840+ if ( hasJBRCustomDecoration () )
841+ hitTestSpots .add ( iconR );
842+ else
843+ appIconBounds = iconR ;
844+ }
813845 }
814846
815847 Rectangle r = getNativeHitTestSpot ( buttonPanel );
0 commit comments