开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 27

MicroOS/MiniGUI

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (9)
标签 (1)
master
rel-3-2
drm
dev-3-4
complex-scripts
tmp-3-2-2
dev-3-2-2
rel-3-0
64b
ver-4-0-0
master
分支 (9)
标签 (1)
master
rel-3-2
drm
dev-3-4
complex-scripts
tmp-3-2-2
dev-3-2-2
rel-3-0
64b
ver-4-0-0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (9)
标签 (1)
master
rel-3-2
drm
dev-3-4
complex-scripts
tmp-3-2-2
dev-3-2-2
rel-3-0
64b
ver-4-0-0
MiniGUI
/
src
/
server
/
server.c
MiniGUI
/
src
/
server
/
server.c
server.c 13.78 KB
一键复制 编辑 原始数据 按行查看 历史
Vincent Wei 提交于 2019年07月15日 14:17 +08:00 . prepend excpetion list statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
///////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/en/about/licensing-policy/>.
*/
/*
** server.c: routines for server.
**
** Current maintainer: Wei Yongming.
**
** Create date: 2000年12月20日
**
** NOTE: The idea comes from sample code in APUE.
*/
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/times.h>
#include <sys/poll.h>
#include "common.h"
#include "minigui.h"
#include "gdi.h"
#include "window.h"
#include "cliprect.h"
#include "internals.h"
#include "gal.h"
#include "ial.h"
#include "cursor.h"
#include "event.h"
#include "menu.h"
#include "ourhdr.h"
#include "sockio.h"
#include "client.h"
#include "server.h"
#include "sharedres.h"
#include "drawsemop.h"
#include "license.h"
extern DWORD __mg_timer_counter;
ON_NEW_DEL_CLIENT OnNewDelClient = NULL;
static SRVEVTHOOK srv_evt_hook = NULL;
SRVEVTHOOK GUIAPI SetServerEventHook (SRVEVTHOOK SrvEvtHook)
{
SRVEVTHOOK old_hook = srv_evt_hook;
if (!mgIsServer)
return NULL;
srv_evt_hook = SrvEvtHook;
return old_hook;
}
static void ParseEvent (PMSGQUEUE msg_que, int event)
{
LWEVENT lwe;
PMOUSEEVENT me;
PKEYEVENT ke;
MSG Msg;
ke = &(lwe.data.ke);
me = &(lwe.data.me);
me->x = 0; me->y = 0;
Msg.hwnd = HWND_DESKTOP;
Msg.wParam = 0;
Msg.lParam = 0;
ke->status = 0L;
me->status = 0L;
lwe.status = 0L;
if (!kernel_GetLWEvent (event, &lwe))
return;
Msg.time = __mg_timer_counter;
if (lwe.type == LWETYPE_TIMEOUT) {
Msg.message = MSG_TIMEOUT;
Msg.wParam = (WPARAM)lwe.count;
Msg.lParam = 0;
/*
* No need to send TIME_OUT message to the client
* Send2Client (&Msg, CLIENT_ACTIVE);
*/
kernel_QueueMessage (msg_que, &Msg);
}
else if (lwe.type == LWETYPE_KEY) {
Msg.wParam = ke->scancode;
Msg.lParam = ke->status;
if (ke->event == KE_KEYDOWN){
Msg.message = MSG_KEYDOWN;
}
else if (ke->event == KE_KEYUP) {
Msg.message = MSG_KEYUP;
}
else if (ke->event == KE_KEYLONGPRESS) {
Msg.message = MSG_KEYLONGPRESS;
}
else if (ke->event == KE_KEYALWAYSPRESS) {
Msg.message = MSG_KEYALWAYSPRESS;
}
if (__mg_do_drag_drop_window (Msg.message, 0, 0))
return;
if (!(srv_evt_hook && srv_evt_hook (&Msg))) {
kernel_QueueMessage (msg_que, &Msg);
}
}
else if (lwe.type == LWETYPE_MOUSE) {
static int down_client = -1;
static int down_by;
int cur_client = __mg_get_znode_at_point (__mg_zorder_info,
me->x, me->y, NULL);
Msg.wParam = me->status;
switch (me->event) {
case ME_MOVED:
Msg.message = MSG_MOUSEMOVE;
break;
case ME_LEFTDOWN:
Msg.message = MSG_LBUTTONDOWN;
break;
case ME_RIGHTDOWN:
Msg.message = MSG_RBUTTONDOWN;
break;
case ME_LEFTUP:
Msg.message = MSG_LBUTTONUP;
break;
case ME_LEFTDBLCLICK:
Msg.message = MSG_LBUTTONDBLCLK;
break;
case ME_RIGHTUP:
Msg.message = MSG_RBUTTONUP;
break;
case ME_RIGHTDBLCLICK:
Msg.message = MSG_RBUTTONDBLCLK;
break;
}
if (__mg_do_drag_drop_window (Msg.message, me->x, me->y)) {
down_client = -1;
return;
}
switch (Msg.message) {
case MSG_LBUTTONDOWN:
case MSG_RBUTTONDOWN:
if (cur_client >= 0 && down_client == -1) {
down_client = cur_client;
down_by = Msg.message;
}
break;
}
if (cur_client == -1)
SetDefaultCursor (GetSystemCursor (IDC_ARROW));
Msg.lParam = MAKELONG (me->x, me->y);
if (__mg_handle_mouse_hook (Msg.message,
Msg.wParam, Msg.lParam) == HOOK_STOP)
return;
if (!(srv_evt_hook && srv_evt_hook (&Msg))) {
int target_client = cur_client;
if (down_client < 0) {
if (!__mg_capture_wnd && me->event == ME_MOVED) {
int cli = __mg_handle_normal_mouse_move (__mg_zorder_info,
me->x, me->y);
if (cli > 0)
target_client = cli;
}
}
else
target_client = down_client;
if (target_client > 0) {
Msg.hwnd = 0;
#ifdef _MG_CONFIG_FAST_MOUSEMOVE
if (Msg.message == MSG_MOUSEMOVE) {
lock_mousemove_sem();
{
if (SHAREDRES_MOUSEMOVECLIENT > 0 && SHAREDRES_MOUSEMOVECLIENT != target_client) {
printf("drop a mouse move message, old_client=%d, target_client=%d\n", SHAREDRES_MOUSEMOVECLIENT, target_client);
}
}
SHAREDRES_MOUSEMOVECLIENT = target_client;
++ SHAREDRES_MOUSEMOVESERIAL;
unlock_mousemove_sem();
}
else
#endif
{
Send2Client (&Msg, target_client);
}
}
else
kernel_QueueMessage (msg_que, &Msg);
}
if (Msg.message == MSG_LBUTTONUP && down_by == MSG_LBUTTONDOWN) {
down_client = -1;
}
if (Msg.message == MSG_RBUTTONUP && down_by == MSG_RBUTTONDOWN) {
down_client = -1;
}
}
}
static int listenfd;
static int maxi;
BOOL GUIAPI ServerStartup (int nr_globals,
int def_nr_topmosts, int def_nr_normals)
{
if (!mgIsServer)
return FALSE;
if (nr_globals <= 0) nr_globals = DEF_NR_GLOBALS;
if (def_nr_topmosts <= 0) def_nr_topmosts = DEF_NR_TOPMOSTS;
if (def_nr_normals <= 0) def_nr_normals = DEF_NR_NORMALS;
nr_globals = (nr_globals + 7) & ~0x07;
def_nr_topmosts = (def_nr_topmosts + 7) & ~0x07;
def_nr_normals = (def_nr_normals + 7) & ~0x07;
SHAREDRES_NR_GLOBALS = nr_globals;
SHAREDRES_DEF_NR_TOPMOSTS = def_nr_topmosts;
SHAREDRES_DEF_NR_NORMALS = def_nr_normals;
if (__mg_init_layers () == -1)
return FALSE;
SHAREDRES_NR_LAYSERS = 1;
mgTopmostLayer = mgLayers;
SHAREDRES_TOPMOST_LAYER = (GHANDLE)mgTopmostLayer;
/* reserve the first client slot for the server */
__mg_client_id = __mg_client_add (0, getpid (), 0);
mgClients [0].layer = mgTopmostLayer;
/* obtain fd to listen for client requests on */
if ( (listenfd = serv_listen (CS_PATH)) < 0)
goto fail;
FD_ZERO (&mg_rfdset);
FD_SET (listenfd, &mg_rfdset);
mg_maxfd = listenfd;
maxi = -1;
mg_InitTimer ();
__mg_start_server_desktop ();
screensaver_create();
return TRUE;
fail:
__mg_cleanup_layers ();
return FALSE;
}
void server_ServerCleanup (void)
{
__mg_cleanup_layers ();
mg_UninstallIntervalTimer ();
unlink (CS_PATH);
}
BOOL server_IdleHandler4Server (PMSGQUEUE msg_queue)
{
int i, n, clifd, nread;
pid_t pid;
uid_t uid;
struct timeval sel_timeout = {0, 0};
fd_set rset, wset, eset;
fd_set* wsetptr = NULL;
fd_set* esetptr = NULL;
EXTRA_INPUT_EVENT extra; // Since 4.0.0; for extra input events
if (__mg_timer_counter != SHAREDRES_TIMER_COUNTER) {
__mg_timer_counter = SHAREDRES_TIMER_COUNTER;
SetDesktopTimerFlag ();
}
rset = mg_rfdset; /* rset gets modified each time around */
if (mg_wfdset) {
wset = *mg_wfdset;
wsetptr = &wset;
}
if (mg_efdset) {
eset = *mg_efdset;
esetptr = &eset;
}
#ifdef _MGHAVE_CURSOR
/* if the cursor has been hide by GDI function of clients
* this call will show the cursor
*/
kernel_ReShowCursor ();
#endif
extra.params_mask = 0;
if ((n = IAL_WaitEvent (mg_maxfd, &rset, wsetptr, esetptr,
msg_queue?NULL:(&sel_timeout), &extra)) < 0) {
/* It is time to check event again. */
if (errno == EINTR) {
if (msg_queue)
ParseEvent (msg_queue, 0);
return FALSE;
}
#ifdef _DEBUG
err_msg ("select error on server");
#endif
}
if (FD_ISSET (listenfd, &rset)) {
/* accept new client request */
if ( (clifd = serv_accept (listenfd, &pid, &uid)) < 0) {
#ifdef _DEBUG
err_msg ("serv_accept error: %d", clifd);
#endif
return TRUE;
}
if ((i = __mg_client_add (clifd, pid, uid)) == -1) {
/* can not accept this client */
close (clifd);
return TRUE;
}
if (OnNewDelClient) OnNewDelClient (LCO_NEW_CLIENT, i);
FD_SET (clifd, &mg_rfdset);
if (clifd > mg_maxfd)
mg_maxfd = clifd; /* max fd for select() */
if (i > maxi)
maxi = i; /* max index in client[] array */
#ifdef _DEBUG
err_msg ("new connection: uid %d, fd %d", uid, clifd);
#endif
return TRUE;
}
for (i = 0; i <= maxi; i++) { /* go through client[] array */
if ( (clifd = mgClients [i].fd) < 0)
continue;
if (FD_ISSET (clifd, &rset)) {
int req_id;
/* read request id from client */
if ( (nread = sock_read (clifd, &req_id, sizeof (int)))
== SOCKERR_IO) {
#ifdef _DEBUG
err_msg ("server: read error on fd %d", clifd);
#endif
if (OnNewDelClient) OnNewDelClient (LCO_DEL_CLIENT, i);
__mg_remove_client (i, clifd);
}
else if (nread == SOCKERR_CLOSED) {
if (OnNewDelClient) OnNewDelClient (LCO_DEL_CLIENT, i);
__mg_remove_client (i, clifd);
} else /* process client's rquest */
__mg_handle_request (clifd, req_id, i);
}
}
if (msg_queue == NULL)
return (n > 0);
/* handle intput event (mouse/touch-screen or keyboard) */
if (n & IAL_MOUSEEVENT) ParseEvent (msg_queue, IAL_MOUSEEVENT);
if (n & IAL_KEYEVENT) ParseEvent (msg_queue, IAL_KEYEVENT);
if (n & IAL_EVENT_EXTRA) {
MSG msg;
msg.hwnd = HWND_DESKTOP;
msg.message = extra.event;
msg.wParam = extra.wparam;
msg.lParam = extra.lparam;
msg.time = __mg_timer_counter;
if (extra.params_mask) {
// packed multiple sub events
int i, n = 0;
for (i = 0; i < NR_PACKED_SUB_EVENTS; i++) {
if (extra.params_mask & (1 << i)) {
msg.wParam = extra.wparams[i];
msg.lParam = extra.lparams[i];
kernel_QueueMessage (msg_queue, &msg);
n++;
}
}
if (n > 0) {
msg.message = MSG_EXIN_END_CHANGES;
msg.wParam = n;
msg.lParam = 0;
kernel_QueueMessage (msg_queue, &msg);
}
}
else {
kernel_QueueMessage (msg_queue, &msg);
}
}
else if (n == 0)
ParseEvent (msg_queue, 0);
/* go through registered listen fds */
for (i = 0; i < MAX_NR_LISTEN_FD; i++) {
MSG Msg;
Msg.message = MSG_FDEVENT;
if (mg_listen_fds [i].fd) {
fd_set* temp = NULL;
int type = mg_listen_fds [i].type;
switch (type) {
case POLLIN:
temp = &rset;
break;
case POLLOUT:
temp = wsetptr;
break;
case POLLERR:
temp = esetptr;
break;
}
if (temp && FD_ISSET (mg_listen_fds [i].fd, temp)) {
Msg.hwnd = (HWND)mg_listen_fds [i].hwnd;
Msg.wParam = MAKELONG (mg_listen_fds [i].fd, type);
Msg.lParam = (LPARAM)mg_listen_fds [i].context;
kernel_QueueMessage (msg_queue, &Msg);
}
}
}
return TRUE;
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

MiniGUI 是一个自由软件项目。其目标是提供一个快速、稳定、跨操作系统的图形用户界面(GUI)支持系统,尤其是基于 Linux/uClinux、eCos 以及其他传统 RTOS(如 VxWorks、ThreadX、uC/OS-II、Nucleus 等)的实时嵌入式操作系统。
暂无标签
GPL-3.0
使用 GPL-3.0 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/MicroOS/MiniGUI.git
git@gitee.com:MicroOS/MiniGUI.git
MicroOS
MiniGUI
MiniGUI
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /