?? client.c
字號:
BOOL remove_layer (MG_Layer* layer){#ifdef _DEBUG printf ("Remove a layer: %s\n", layer->name);#endif if (layer->prev) layer->prev->next = layer->next; if (layer->next) layer->next->prev = layer->prev; if (layer == mgLayers) { mgLayers = layer->next; } // Notify that a layer will be deleted. if (OnChangeLayer) OnChangeLayer (LCO_DEL_LAYER, layer, NULL); EmptyClipRgn (layer->spare_rects); free (layer->spare_rects); free (layer); if (mgTopmostLayer != layer) return FALSE; // set new topmost layer mgTopmostLayer = mgLayers; CHANGE_TOPMOST_LAYER (mgTopmostLayer); if (mgTopmostLayer) { MG_Client* client; MSG msg = {HWND_DESKTOP, MSG_PAINT, 0, 0, __mg_timer_counter};#ifdef _DEBUG printf ("New topmost layer: %s\n", mgTopmostLayer->name);#endif client = mgTopmostLayer->cli_head; while (client) { my_send2client (&msg, client); client->last_live_time = __mg_timer_counter; client = client->next; } if (mgTopmostLayer->cli_active) { MSG msg = {HWND_DESKTOP, MSG_SETFOCUS, 0, 0, __mg_timer_counter}; my_send2client (&msg, mgTopmostLayer->cli_active); } } // Notify that a new topmost layer have been set. if (OnChangeLayer) OnChangeLayer (LCO_TOPMOST_CHANGED, mgTopmostLayer, NULL);#ifdef _DEBUG printf ("layer removed\n");#endif return TRUE;}void set_active_client (MG_Client* client){ MG_Layer* layer; if (client) layer = client->layer; else layer = mgTopmostLayer; if (layer == NULL || layer->cli_active == client) return; if (layer->cli_active) { MSG msg = {HWND_DESKTOP, MSG_SETFOCUS, 0, 0, __mg_timer_counter}; my_send2client (&msg, layer->cli_active); } // Notify that active client changed. if (OnChangeLayer) OnChangeLayer (LCO_ACTIVE_CHANGED, layer, client); layer->cli_active = client;}void client_join_layer (int cli, const JOINLAYERINFO* info, JOINEDCLIENTINFO* joined_info){ PCLIPRECT spare, max = NULL; RECT tmp; unsigned int max_area = 0, area; MG_Layer* layer = (MG_Layer*)(joined_info->layer_handle); MG_Client* new_client = mgClients + cli;#ifdef _DEBUG printf ("Join a client (%s) to layer %s\n", info->client_name, layer->name);#endif strcpy (new_client->name, info->client_name); SetRectEmpty (&joined_info->desktop_rc); spare = layer->spare_rects->head; while (spare) { if (IntersectRect (&tmp, &info->desktop_rc, &spare->rc)) { area = (RECTW (tmp) * RECTH (tmp)); if (area > max_area) { max_area = area; max = spare; } } spare = spare->next; } if (max) { IntersectRect (&joined_info->desktop_rc, &info->desktop_rc, &max->rc); SubtractClipRect (layer->spare_rects, &joined_info->desktop_rc); new_client->layer = layer; // Notify that a new client joined to this layer. if (OnChangeLayer) OnChangeLayer (LCO_JOIN_CLIENT, layer, new_client); } else { new_client->layer = NULL; if (layer->cli_head == NULL) remove_layer (layer); return; } new_client->prev = NULL; new_client->next = layer->cli_head; if (layer->cli_head) layer->cli_head->prev = new_client; layer->cli_head = new_client; set_active_client (new_client); // set rect of new client new_client->rc = joined_info->desktop_rc;#ifdef _DEBUG printf ("Rect of client (%s): (%d, %d, %d, %d)\n", new_client->name, new_client->rc.left, new_client->rc.top, new_client->rc.right, new_client->rc.bottom);#endif if (layer == mgTopmostLayer) { // tell desktop to exclude this client from background SendMessage (HWND_DESKTOP, MSG_NEWCLIENT, (WPARAM)cli, (LPARAM)(&new_client->rc)); }}BOOL is_valid_layer (MG_Layer* layer){ MG_Layer* myLayer; myLayer = mgLayers; while (myLayer) { if (layer == myLayer) return TRUE; myLayer = myLayer->next; } return FALSE;}/* send message to client(s) */int GUIAPI Send2Client (MSG* msg, int cli){ int i, n; MG_Client* client; if (cli >= 0 && cli < mgClientSize && mgClients [cli].fd != -1) { return my_send2client (msg, mgClients + cli); } else if (cli == CLIENT_ACTIVE) { /* send to active client */ if (mgTopmostLayer && mgTopmostLayer->cli_active) { return my_send2client (msg, mgTopmostLayer->cli_active); } } else if (cli == CLIENTS_TOPMOST) { /* send to topmost clients */ if (mgTopmostLayer) { client = mgTopmostLayer->cli_head; while (client) { if ((n = my_send2client (msg, client)) < 0) return n; client = client->next; } } } else if (cli == CLIENTS_EXCEPT_TOPMOST) { /* send to all clients except topmost client */ client = mgClients; for (i = 0; i < mgClientSize; i++, client++) { if (client->layer != mgTopmostLayer) { if ((n = my_send2client (msg, client)) < 0) return n; } } } else if (cli == CLIENTS_ALL) { /* send to all clients */ client = mgClients; for (i = 0; i < mgClientSize; i++, client++) { if ((n = my_send2client (msg, client)) < 0) return n; } } else return SOCKERR_INVARG; return SOCKERR_OK;}BOOL GUIAPI Send2TopMostClients (int iMsg, WPARAM wParam, LPARAM lParam){ MSG msg = {HWND_DESKTOP, iMsg, wParam, lParam, __mg_timer_counter}; if (send2client (&msg, CLIENTS_TOPMOST) < 0) return FALSE; return TRUE;}BOOL GUIAPI Send2ActiveClient (int iMsg, WPARAM wParam, LPARAM lParam){ MSG msg = {HWND_DESKTOP, iMsg, wParam, lParam, __mg_timer_counter}; if (send2client (&msg, CLIENT_ACTIVE) < 0) return FALSE; return TRUE;}void GUIAPI UpdateTopmostLayer (const RECT* dirty_rc){ MSG msg = {HWND_DESKTOP, MSG_PAINT, 0, 0, __mg_timer_counter}; if (dirty_rc) { RECT eff_rc; IntersectRect (&eff_rc, dirty_rc, &g_rcScr); msg.wParam = MAKELONG (eff_rc.left, eff_rc.top); msg.lParam = MAKELONG (eff_rc.right, eff_rc.bottom); } send2client (&msg, CLIENTS_TOPMOST);}static int onlyme_count = 0;BOOL GUIAPI OnlyMeCanDraw (void){ MG_Client* client; if (onlyme_count ++) return TRUE; CHANGE_TOPMOST_LAYER (NULL); if (mgTopmostLayer == NULL || (client = mgTopmostLayer->cli_head) == NULL) return FALSE; return TRUE;}BOOL GUIAPI ClientCanDrawNowEx (BOOL bRepaint, const RECT* invrc){ MG_Client* client; MSG msg = {HWND_DESKTOP, MSG_PAINT, 0, 0, __mg_timer_counter}; if (--onlyme_count) return TRUE; if (bRepaint && invrc) { msg.wParam = MAKELONG (invrc->left, invrc->top); msg.lParam = MAKELONG (invrc->right, invrc->bottom); } CHANGE_TOPMOST_LAYER (mgTopmostLayer); if (mgTopmostLayer == NULL || (client = mgTopmostLayer->cli_head) == NULL) return FALSE; while (client) { if (bRepaint) { my_send2client (&msg, client); } client = client->next; } return TRUE;}BOOL GUIAPI SetTopMostLayer (MG_Layer* layer){ MG_Client* client; MSG msg = {HWND_DESKTOP, MSG_PAINT, 0, 0, __mg_timer_counter}; if (layer == mgTopmostLayer) return FALSE; mgTopmostLayer = layer; CHANGE_TOPMOST_LAYER (layer); client = layer->cli_head; while (client) { my_send2client (&msg, client); client->last_live_time = __mg_timer_counter; client = client->next; } if (layer->cli_active) { MSG msg = {HWND_DESKTOP, MSG_SETFOCUS, 0, 0, __mg_timer_counter}; my_send2client (&msg, layer->cli_active); } SendMessage (HWND_DESKTOP, MSG_TOPMOSTCHANGED, 0, 0); PostMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); // Notify that a new topmost layer have been set. if (OnChangeLayer) OnChangeLayer (LCO_TOPMOST_CHANGED, mgTopmostLayer, NULL); return TRUE;}BOOL GUIAPI SetTopMostClient (int cli){ if (cli < 0 || cli >= mgClientSize || mgClients [cli].fd == -1) return FALSE; return SetTopMostLayer (mgClients [cli].layer);}int GUIAPI GetClientByPID (int pid){ int i; for (i = 0; i < mgClientSize; i++) { if (mgClients[i].pid == pid) { if (mgClients[i].fd == -1) return -1; return i; } } return -1;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -