mirror of
				https://github.com/Ryujinx/Opentk.git
				synced 2025-11-04 06:54:56 +00:00 
			
		
		
		
	[Win] Fixed MouseCursor.Default
It is now possible to switch from a custom cursor back to MouseCursor.Default.
This commit is contained in:
		
							parent
							
								
									4f9a2f78d6
								
							
						
					
					
						commit
						509f356ed4
					
				| 
						 | 
					@ -1202,6 +1202,16 @@ namespace OpenTK.Platform.Windows
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (value != cursor)
 | 
					                if (value != cursor)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool destoryOld = cursor != MouseCursor.Default;
 | 
				
			||||||
 | 
					                    IntPtr oldCursor = IntPtr.Zero;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (value == MouseCursor.Default)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        oldCursor = Functions.SetCursor(Functions.LoadCursor(CursorName.Arrow));
 | 
				
			||||||
 | 
					                        cursor = value;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        var stride = value.Width *
 | 
					                        var stride = value.Width *
 | 
				
			||||||
                            (Bitmap.GetPixelFormatSize(System.Drawing.Imaging.PixelFormat.Format32bppArgb) / 8);
 | 
					                            (Bitmap.GetPixelFormatSize(System.Drawing.Imaging.PixelFormat.Format32bppArgb) / 8);
 | 
				
			||||||
| 
						 | 
					@ -1216,7 +1226,8 @@ namespace OpenTK.Platform.Windows
 | 
				
			||||||
                                    new IntPtr(pixels));
 | 
					                                    new IntPtr(pixels));
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        using (bmp)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
                            var iconInfo = new IconInfo();
 | 
					                            var iconInfo = new IconInfo();
 | 
				
			||||||
                            var bmpIcon = bmp.GetHicon();
 | 
					                            var bmpIcon = bmp.GetHicon();
 | 
				
			||||||
                            var success = Functions.GetIconInfo(bmpIcon, out iconInfo);
 | 
					                            var success = Functions.GetIconInfo(bmpIcon, out iconInfo);
 | 
				
			||||||
| 
						 | 
					@ -1233,21 +1244,21 @@ namespace OpenTK.Platform.Windows
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    // Currently using a custom cursor so destroy it 
 | 
					                                    // Currently using a custom cursor so destroy it 
 | 
				
			||||||
                                    // once replaced
 | 
					                                    // once replaced
 | 
				
			||||||
                            bool destoryOld = cursor != MouseCursor.Default;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    cursor = value;
 | 
					                                    cursor = value;
 | 
				
			||||||
                                    curson_handle = icon;
 | 
					                                    curson_handle = icon;
 | 
				
			||||||
                            var oldCursor = Functions.SetCursor(icon);
 | 
					                                    oldCursor = Functions.SetCursor(icon);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (destoryOld)
 | 
					                    if (destoryOld && oldCursor != IntPtr.Zero)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Functions.DestroyIcon(oldCursor);
 | 
					                        Functions.DestroyIcon(oldCursor);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue