英文:
CygWin How to create a Window with GNU C++ that can be move without a X-Server Window Manager
问题
-
CygWin for Windows comes with a X-Server port for Windows
-
Windows 版本的 CygWin 自带 X-Server 端口
-
How can I create a "moveable" Window, with the X-Server functions that are available when you (me) programming with the GNU C++ Compiler
-
我如何使用 GNU C++ 编译器编程来创建一个可移动的窗口,使用 X-Server 的函数?
-
I have already programming with Qt5 but I would do this with built-in Functions from the X-Server without the use of a Window Manager
-
我已经使用 Qt5 进行了编程,但我想使用 X-Server 的内置函数来实现这个,而不使用窗口管理器
Thanks for reading, and Helping Feedback
感谢阅读和提供反馈
-
I already able to create a Window with Qt5 Framework but this Framework need a huge amount of space because the big libraries that come with
-
我已经能够使用 Qt5 框架创建窗口,但这个框架需要大量的空间,因为它附带了大型库
-
I expecting a small Example without using any Framework, only the X-Server Functions that are available for Cygwin X-Server
-
我希望得到一个小示例,不使用任何框架,只使用 Cygwin X-Server 可用的 X-Server 函数
英文:
like the Subject of the Topic said:
- CygWin for Windows comes with a X-Server port for Windows
- How can I create a "moveable" Window, with the X-Server
functions that are available when you (me) programming with
the GNU C++ Compiler - I have already programming with Qt5 but I would do this
with built-in Functions from the X-Server without the useing
of a Window Manager
Thanks for reading, and Helping Feedback
- I already able to create a Window with Qt5 Framework
but this Framework need a huge amount of space because the
big libraries that come with - I expecting a small Example without using any Framework,
only the X-Server Functions that are available for Cygwin
X-Server
答案1
得分: 1
以下是您要求的代码部分的中文翻译:
跟随 [YouTube]:
Future Tech Labs - X11 Tutorials - 1 - Creating a Simple Window 教程,并创建了以下(虚拟)示例。
main00.c:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main()
{
Display *pd = NULL;
if ((pd = XOpenDisplay((char*)NULL)) == NULL) {
printf("XOpenDisplay 错误\n");
return -1;
}
int scr = DefaultScreen(pd);
Window win = XCreateSimpleWindow(pd, RootWindow(pd, scr),
100, 100, 320, 200, 15, BlackPixel(pd, scr), WhitePixel(pd, scr));
XSetStandardProperties(pd, win, "Cygwin X q075977479", "q075977479", None, NULL, 0, NULL);
XMapWindow(pd, win);
XEvent ev;
while (XNextEvent(pd, &ev) == 0) {
}
XUnmapWindow(pd, win);
XDestroyWindow(pd, win);
XCloseDisplay(pd);
printf("\n完成。\n\n");
return 0;
}
输出:
> ```lang-bash
> [cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackExchange/StackOverflow/q075977479]> ~/sopr.sh
> ### 设置较短的提示以更好地适应粘贴到 StackOverflow(或其他)页面时 ###
>
> [064位提示]> uname -a
> CYGWIN_NT-10.0-19045 cfati-5510-0 3.4.6-1.x86_64 2023-02-14 13:23 UTC x86_64 Cygwin
> [064位提示]> ls
> main00.c
> [064位提示]> gcc main00.c -o main00.exe -lX11
> [064位提示]> ls
> main00.c main00.exe
> [064位提示]> DISPLAY=:0 ./main00.exe
> ```
和窗口:
还可能希望查看:
-
[X]: Xlib - C 语言 X 接口 - X API
-
[Cygwin]: 第 3 章. 使用 Cygwin/X - Cygwin 特定信息
英文:
Followed the [YouTube]:
Future Tech Labs - X11 Tutorials - 1 - Creating a Simple Window tutorial, and came up with the following (dummy) example.
main00.c:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main()
{
Display *pd = NULL;
if ((pd = XOpenDisplay((char*)NULL)) == NULL) {
printf("XOpenDisplay error\n");
return -1;
}
int scr = DefaultScreen(pd);
Window win = XCreateSimpleWindow(pd, RootWindow(pd, scr),
100, 100, 320, 200, 15, BlackPixel(pd, scr), WhitePixel(pd, scr));
XSetStandardProperties(pd, win, "Cygwin X q075977479", "q075977479", None, NULL, 0, NULL);
XMapWindow(pd, win);
XEvent ev;
while (XNextEvent(pd, &ev) == 0) {
}
XUnmapWindow(pd, win);
XDestroyWindow(pd, win);
XCloseDisplay(pd);
printf("\nDone.\n\n");
return 0;
}
Output:
> lang-bash
> [cfati@cfati-5510-0:/cygdrive/e/Work/Dev/StackExchange/StackOverflow/q075977479]> ~/sopr.sh
> ### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
>
> [064bit prompt]> uname -a
> CYGWIN_NT-10.0-19045 cfati-5510-0 3.4.6-1.x86_64 2023-02-14 13:23 UTC x86_64 Cygwin
> [064bit prompt]> ls
> main00.c
> [064bit prompt]> gcc main00.c -o main00.exe -lX11
> [064bit prompt]> ls
> main00.c main00.exe
> [064bit prompt]> DISPLAY=:0 ./main00.exe
>
And the window:
Might also want to check:
-
[Cygwin]: Chapter 3. Using Cygwin/X - Cygwin specifics
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论