Skip to content

Commit ab45a79

Browse files
committed
Clean Code
1 parent d2de8e5 commit ab45a79

File tree

7 files changed

+48
-38
lines changed

7 files changed

+48
-38
lines changed

SeWzc.X11Sharp/Enums.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ public enum QueryBestSizeClass
777777
{
778778
/*
779779
/* QueryBestSize Class * /
780-
780+
781781
#define CursorShape 0 /* largest size that can be displayed * /
782782
#define TileShape 1 /* size tiled fastest * /
783783
#define StippleShape 2 /* size stippled fastest * /
@@ -792,7 +792,7 @@ public enum RectanglesOrdering
792792
{
793793
/*
794794
/* SetClipRectangles ordering * /
795-
795+
796796
#define Unsorted 0
797797
#define YSorted 1
798798
#define YXSorted 2
@@ -981,6 +981,7 @@ public enum CoordMode
981981
/// 相对于原点。
982982
/// </summary>
983983
Origin,
984+
984985
/// <summary>
985986
/// 相对于上一个点。
986987
/// </summary>
@@ -1000,10 +1001,12 @@ public enum PolygonShape
10001001
/// 复杂多边形。
10011002
/// </summary>
10021003
Complex = 0,
1004+
10031005
/// <summary>
10041006
/// 非凸多边形。
10051007
/// </summary>
10061008
Nonconvex = 1,
1009+
10071010
/// <summary>
10081011
/// 凸多边形。
10091012
/// </summary>
@@ -1024,10 +1027,12 @@ public enum ImageFormat
10241027
/// XY 格式的位图。
10251028
/// </summary>
10261029
XYBitmap = 0,
1030+
10271031
/// <summary>
10281032
/// XY 格式的像素图。
10291033
/// </summary>
10301034
XYPixmap = 1,
1035+
10311036
/// <summary>
10321037
/// Z 格式的像素图。
10331038
/// </summary>
@@ -1043,17 +1048,19 @@ public enum FocusRevert
10431048
#define RevertToPointerRoot (int)PointerRoot
10441049
#define RevertToParent 2
10451050
*/
1046-
1051+
10471052
/// <summary>
10481053
/// 丢弃焦点。
10491054
/// </summary>
10501055
None = 0,
1056+
10511057
/// <summary>
1052-
/// 回退到 <see cref="PointerRoot"/>。
1058+
/// 回退到 <see cref="PointerRoot" />。
10531059
/// </summary>
10541060
PointerRoot = 1,
1061+
10551062
/// <summary>
1056-
/// 回退到最近的可见祖先。回退之后值变成 <see cref="None "/>。
1063+
/// 回退到最近的可见祖先。回退之后值变成 <see cref="None " />。
10571064
/// </summary>
10581065
Parent = 2,
10591066
}
@@ -1071,6 +1078,7 @@ public enum SetMode
10711078
/// 将窗口添加到保存集中。
10721079
/// </summary>
10731080
Insert,
1081+
10741082
/// <summary>
10751083
/// 从保存集中删除窗口。
10761084
/// </summary>

SeWzc.X11Sharp/Exceptions/X11ErrorException.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// X11 错误封装的异常。
55
/// </summary>
6-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Using_the_Default_Error_Handlers"/>
6+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Using_the_Default_Error_Handlers" />
77
public class X11ErrorException : Exception
88
{
99
internal X11ErrorException(ErrorCode errorCode)
@@ -21,101 +21,101 @@ internal X11ErrorException(ErrorCode errorCode)
2121
/// <summary>
2222
/// 表示 X11 错误代码 BadRequest 的异常。
2323
/// </summary>
24-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadRequest"/>
24+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadRequest" />
2525
public class BadRequestException() : X11ErrorException(ErrorCode.BadRequest);
2626

2727
/// <summary>
2828
/// 表示 X11 错误代码 BadValue 的异常。
2929
/// </summary>
30-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadValue"/>
30+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadValue" />
3131
public class BadValueException() : X11ErrorException(ErrorCode.BadValue);
3232

3333
/// <summary>
3434
/// 表示 X11 错误代码 BadWindow 的异常。
3535
/// </summary>
36-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadWindow"/>
36+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadWindow" />
3737
public class BadWindowException() : X11ErrorException(ErrorCode.BadWindow);
3838

3939
/// <summary>
4040
/// 表示 X11 错误代码 BadPixmap 的异常。
4141
/// </summary>
42-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadPixmap"/>
42+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadPixmap" />
4343
public class BadPixmapException() : X11ErrorException(ErrorCode.BadPixmap);
4444

4545
/// <summary>
4646
/// 表示 X11 错误代码 BadAtom 的异常。
4747
/// </summary>
48-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAtom"/>
48+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAtom" />
4949
public class BadAtomException() : X11ErrorException(ErrorCode.BadAtom);
5050

5151
/// <summary>
5252
/// 表示 X11 错误代码 BadCursor 的异常。
5353
/// </summary>
54-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadCursor"/>
54+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadCursor" />
5555
public class BadCursorException() : X11ErrorException(ErrorCode.BadCursor);
5656

5757
/// <summary>
5858
/// 表示 X11 错误代码 BadFont 的异常。
5959
/// </summary>
60-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadFont"/>
60+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadFont" />
6161
public class BadFontException() : X11ErrorException(ErrorCode.BadFont);
6262

6363
/// <summary>
6464
/// 表示 X11 错误代码 BadMatch 的异常。
6565
/// </summary>
66-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadMatch"/>
66+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadMatch" />
6767
public class BadMatchException() : X11ErrorException(ErrorCode.BadMatch);
6868

6969
/// <summary>
7070
/// 表示 X11 错误代码 BadDrawable 的异常。
7171
/// </summary>
72-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadDrawable"/>
72+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadDrawable" />
7373
public class BadDrawableException() : X11ErrorException(ErrorCode.BadDrawable);
7474

7575
/// <summary>
7676
/// 表示 X11 错误代码 BadAccess 的异常。
7777
/// </summary>
78-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAccess"/>
78+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAccess" />
7979
public class BadAccessException() : X11ErrorException(ErrorCode.BadAccess);
8080

8181
/// <summary>
8282
/// 表示 X11 错误代码 BadAlloc 的异常。
8383
/// </summary>
84-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAlloc"/>
84+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadAlloc" />
8585
public class BadAllocException() : X11ErrorException(ErrorCode.BadAlloc);
8686

8787
/// <summary>
8888
/// 表示 X11 错误代码 BadColor 的异常。
8989
/// </summary>
90-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadColor"/>
90+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadColor" />
9191
public class BadColorException() : X11ErrorException(ErrorCode.BadColor);
9292

9393
/// <summary>
9494
/// 表示 X11 错误代码 BadGC 的异常。
9595
/// </summary>
96-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadGC"/>
96+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadGC" />
9797
public class BadGCException() : X11ErrorException(ErrorCode.BadGC);
9898

9999
/// <summary>
100100
/// 表示 X11 错误代码 BadIDChoice 的异常。
101101
/// </summary>
102-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadIDChoice"/>
102+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadIDChoice" />
103103
public class BadIDChoiceException() : X11ErrorException(ErrorCode.BadIDChoice);
104104

105105
/// <summary>
106106
/// 表示 X11 错误代码 BadName 的异常。
107107
/// </summary>
108-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadName"/>
108+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadName" />
109109
public class BadNameException() : X11ErrorException(ErrorCode.BadName);
110110

111111
/// <summary>
112112
/// 表示 X11 错误代码 BadLength 的异常。
113113
/// </summary>
114-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadLength"/>
114+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadLength" />
115115
public class BadLengthException() : X11ErrorException(ErrorCode.BadLength);
116116

117117
/// <summary>
118118
/// 表示 X11 错误代码 BadImplementation 的异常。
119119
/// </summary>
120-
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadImplementation"/>
120+
/// <seealso href="https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#BadImplementation" />
121121
public class BadImplementationException() : X11ErrorException(ErrorCode.BadImplementation);

SeWzc.X11Sharp/Structs/Time.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public readonly record struct Time(ULong Value)
1010
/// 表示当前时间。注意,这里只是 x11 定义的特殊值,实际里面的值并不是当前时间。
1111
/// </summary>
1212
public static Time CurrentTime => new(0u);
13-
13+
1414
/// <summary>
1515
/// 强制转换为 ULong。
1616
/// </summary>

SeWzc.X11Sharp/X11Image.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ internal X11Image(XImage* image)
124124

125125
if (XLib.XInitImage(image))
126126
return new X11Image(image);
127-
Marshal.FreeHGlobal((IntPtr)image);
127+
Marshal.FreeHGlobal((nint)image);
128128
return null;
129129
}
130130

SeWzc.X11Sharp/X11Lib.GC.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static void CopyArea(this X11DisplayGC gc, X11Drawable src, X11Drawable d
4242
public static void CopyPlane(this X11DisplayGC gc, X11Drawable src, X11Drawable dst, Point srcLocation, Size areaSize, Point dstLocation,
4343
uint bitPlane)
4444
{
45-
XLib.XCopyPlane(gc.Display, src, dst, gc, srcLocation.X, srcLocation.Y, areaSize.Width, areaSize.Height, dstLocation.X, dstLocation.Y, bitPlane).ThrowIfError();
45+
XLib.XCopyPlane(gc.Display, src, dst, gc, srcLocation.X, srcLocation.Y, areaSize.Width, areaSize.Height, dstLocation.X, dstLocation.Y, bitPlane)
46+
.ThrowIfError();
4647
}
4748

4849
/// <summary>
@@ -199,6 +200,7 @@ public static unsafe void FillPolygon(this X11DisplayGC gc, X11Drawable drawable
199200
/// <param name="size">图像大小。</param>
200201
public static unsafe void PutImage(this X11DisplayGC gc, X11Drawable drawable, X11Image image, Point srcLocation, Point dstLocation, Size size)
201202
{
202-
XLib.XPutImage(gc.Display, drawable, gc, image.XImage, srcLocation.X, srcLocation.Y, dstLocation.X, dstLocation.Y, size.Width, size.Height).ThrowIfError();
203+
XLib.XPutImage(gc.Display, drawable, gc, image.XImage, srcLocation.X, srcLocation.Y, dstLocation.X, dstLocation.Y, size.Width, size.Height)
204+
.ThrowIfError();
203205
}
204206
}

SeWzc.X11Sharp/Xids/X11GContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SeWzc.X11Sharp;
66
/// X11 图形上下文。
77
/// </summary>
88
/// <remarks>
9-
/// 与 <see cref="X11GC"/> 的区别是,该类是资源 ID 的包装,<see cref="X11GC"/> 用于提供函数调用操作。
9+
/// 与 <see cref="X11GC" /> 的区别是,该类是资源 ID 的包装,<see cref="X11GC" /> 用于提供函数调用操作。
1010
/// </remarks>
1111
public readonly partial record struct X11GContext : IXid
1212
{

SeWzc.X11Sharp/Xids/X11Window.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ namespace SeWzc.X11Sharp;
77
/// </summary>
88
public readonly partial record struct X11Window : IXid, IDrawable
99
{
10-
/// <summary>
11-
/// 空窗口。类似于 null。
12-
/// </summary>
13-
public static X11Window None => new X11Window(0u);
14-
15-
/// <summary>
16-
/// 用于 <see cref="X11Lib.SetInputFocus" /> 的焦点窗口。表示每个键盘事件中,焦点窗口会动态地设定为指针所在屏幕的 root window
17-
/// </summary>
18-
public static X11Window PointerRoot => new X11Window(1u);
19-
2010
/// <summary>
2111
/// 通过 Id 构造 X11Window。
2212
/// </summary>
@@ -35,6 +25,16 @@ public X11Window(nint Id)
3525
this.Id = (ULong)Id;
3626
}
3727

28+
/// <summary>
29+
/// 空窗口。类似于 null。
30+
/// </summary>
31+
public static X11Window None => new(0u);
32+
33+
/// <summary>
34+
/// 用于 <see cref="X11Lib.SetInputFocus" /> 的焦点窗口。表示每个键盘事件中,焦点窗口会动态地设定为指针所在屏幕的 root window
35+
/// </summary>
36+
public static X11Window PointerRoot => new(1u);
37+
3838
/// <summary>
3939
/// 是否是 None 窗口。
4040
/// </summary>

0 commit comments

Comments
 (0)