static void ActivateWindow(guiserver_window* w) { if (activeWindow != NULL) { if (Message::send(activeWindow->ThreadID, MSG_GUISERVER_DEACTIVATE, activeWindow->Handle) != M_OK) { monapi_warn("can't activate window(%x), ignored.", w); if (w != NULL) { DisposeWindow(w->Handle); } return; } } if (w != NULL) { if (Message::send(w->ThreadID, MSG_GUISERVER_ACTIVATED, w->Handle) != M_OK) { DisposeWindow(w->Handle); monapi_warn("can't activate window(%x), ignored. message failed", w); return; } } activeWindow = w; if (w == NULL) return; windows.remove(w); windows.add(w); if (w->Protocol == 0) DrawWindow(w); }
int __mlibc_filelist_remove_by_element(void *p, FILE* f) { HList<FILE*>* list; if( p == NULL ) p = __mlibc_filelist_initializer(p); list = (HList<FILE*>*)p; if( !list->hasElement(f) ) return 0; list->remove(f); return 1; }
void unRegisterClient(uint32_t id) { clients_.remove(id); }
bool WindowHandler(MessageInfo* msg) { switch (msg->header) { // ウィンドウ生成要求 case MSG_GUISERVER_CREATEWINDOW: { guiserver_window* w = CreateWindow(); w->ThreadID = msg->from; Message::reply(msg, w->Handle); break; } // ウィンドウ破棄要求 case MSG_GUISERVER_DISPOSEWINDOW: DisposeWindow(msg->arg1); Message::reply(msg); break; // ウィンドウ描画要求 case MSG_GUISERVER_DRAWWINDOW: if (msg->arg2 != 0 && msg->arg3 != 0) { // 部分描画 DrawWindow(GetWindowPointer(msg->arg1), GET_X_DWORD(msg->arg2), GET_Y_DWORD(msg->arg2), GET_X_DWORD(msg->arg3), GET_Y_DWORD(msg->arg3), true); } else { DrawWindow(GetWindowPointer(msg->arg1), true); } Message::reply(msg); break; // ウィンドウ移動要求 case MSG_GUISERVER_MOVEWINDOW: MoveWindow(GetWindowPointer(msg->arg1), (int)msg->arg2, (int)msg->arg3); Message::reply(msg); break; // ウィンドウ最前面移動要求 case MSG_GUISERVER_WINDOWTOFRONTMOST: { guiserver_window* w = GetWindowPointer(msg->arg1); windows.remove(w); windows.add(w); if (msg->arg2 != 0) DrawWindow(w); Message::reply(msg); break; } // アクティブ化要求 case MSG_GUISERVER_ACTIVATEWINDOW: ActivateWindow(GetWindowPointer(msg->arg1)); Message::reply(msg); break; // ウィンドウ列挙要求 case MSG_GUISERVER_ENUMWINDOWS: { int size = windows.size(); int max_count = MESSAGE_INFO_MAX_STR_LENGTH / sizeof(uint32_t); // msg.str = 128 bytes int max_loop_count; if (size > max_count) { max_loop_count = max_count; printf("windows size over %d/%d %s:%d\n", max_count, size, __FILE__, __LINE__); } else { max_loop_count = size; } int i; char str[128]; for (i = 0; i < max_loop_count; i++) { guiserver_window* w = windows[i]; *((uint32_t*)(&str[i * sizeof(uint32_t)])) = w->Handle; } Message::reply(msg, max_loop_count, NULL, str); break; } // タイトル情報 case MSG_GUISERVER_GETTITLE: { guiserver_window* w = GetWindowPointer(msg->arg1); Message::reply(msg, NULL, NULL, w->name); break; } // マウス情報 case MSG_MOUSE_INFO: ProcessMouseInfo(msg); break; // キー情報 case MSG_KEY_VIRTUAL_CODE: if (msg->arg1 == MonAPI::Keys::Tab && msg->arg2 & KEY_MODIFIER_ALT) { RotateActiveWindow(); break; } ProcessKeyInfo(msg); break; // キャプチャー要求 case MSG_GUISERVER_MOUSECAPTURE: { guiserver_window* w = GetWindowPointer(msg->arg1); if (w != NULL) { if (msg->arg2 == 0) { captures.remove(w); } else { captures.add(w); } } Message::reply(msg); break; } // 移動領域作成要求 case MSG_GUISERVER_CREATEOVERLAP: { Overlap* ov = new Overlap( (int)msg->arg1, (int)msg->arg2, GET_X_DWORD(msg->arg3), GET_Y_DWORD(msg->arg3)); overlaps.add(ov); Message::reply(msg, (uint32_t)ov); break; } // 移動領域削除要求 case MSG_GUISERVER_DISPOSEOVERLAP: { Overlap* ov = (Overlap*)msg->arg1; overlaps.remove(ov); delete ov; Message::reply(msg); break; } // 移動領域移動要求 case MSG_GUISERVER_MOVEOVERLAP: ((Overlap*)msg->arg1)->Move( GET_X_DWORD(msg->arg2), GET_Y_DWORD(msg->arg2), GET_X_DWORD(msg->arg3), GET_Y_DWORD(msg->arg3)); Message::reply(msg); break; // 拡張効果要求 case MSG_GUISERVER_EXPANSIONEFFECT: ExpansionEffect( GET_X_DWORD(msg->arg1), GET_Y_DWORD(msg->arg1), GET_X_DWORD(msg->arg2), GET_Y_DWORD(msg->arg2), GET_X_DWORD(msg->arg3), GET_Y_DWORD(msg->arg3)); Message::reply(msg); break; // 縮小効果要求 case MSG_GUISERVER_REDUCTIONEFFECT: ReductionEffect( GET_X_DWORD(msg->arg1), GET_Y_DWORD(msg->arg1), GET_X_DWORD(msg->arg2), GET_Y_DWORD(msg->arg2), GET_X_DWORD(msg->arg3), GET_Y_DWORD(msg->arg3)); Message::reply(msg); break; default: return false; } return true; }