AboutWindow::AboutWindow(const Rect & r) :Window(r, "AboutAlbert", MSG_ABOUTWND_TITLE, // WND_NO_CLOSE_BUT | WND_NO_ZOOM_BUT | WND_NO_DEPTH_BUT | // WND_NO_BORDER | WND_NO_TITLE | WND_NOT_RESIZABLE, CURRENT_DESKTOP) { os::Resources cRes(get_image_id()); os::ResStream* pcStream = cRes.GetResourceStream("Calculator.png"); if(pcStream == NULL) throw(os::errno_exception("Can't find resource Calculator.png!")); m_pcImage = new BitmapImage( pcStream ); BitmapView* imv = new BitmapView( m_pcImage->GetBounds(), "bitmap", m_pcImage ); AddChild(imv); Rect frame = m_pcImage->GetBounds(); Desktop desktop; Point offset(desktop.GetResolution()); offset.x = offset.x/2 - frame.Width()/2; offset.y = offset.y/2 - frame.Height()/2; SetFrame(frame + offset); delete pcStream; }
/** * Removes a child from the given client. */ void ClientModel::remove_child(Window child, bool focus_parent) { if (!is_child(child)) return; Window parent = m_parents[child]; m_children[parent]->erase(child); m_parents.erase(child); if (m_focused == child) { if (focus_parent) focus(parent); else unfocus(); } Desktop *desktop = find_desktop(parent); if (desktop->is_user_desktop()) { UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(desktop); user_desktop->focus_cycle.remove(child, false); } else if (desktop->is_all_desktop()) dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.remove(child, false); m_changes.push(new ChildRemoveChange(parent, child)); }
void WindowArea::_MoveToSAT(SATWindow* triggerWindow) { SATWindow* topWindow = TopWindow(); // if there is no window in the group we are done if (topWindow == NULL) return; BRect frameSAT(LeftVar()->Value() - kMakePositiveOffset, TopVar()->Value() - kMakePositiveOffset, RightVar()->Value() - kMakePositiveOffset, BottomVar()->Value() - kMakePositiveOffset); topWindow->AdjustSizeLimits(frameSAT); BRect frame = topWindow->CompleteWindowFrame(); float deltaToX = round(frameSAT.left - frame.left); float deltaToY = round(frameSAT.top - frame.top); frame.OffsetBy(deltaToX, deltaToY); float deltaByX = round(frameSAT.right - frame.right); float deltaByY = round(frameSAT.bottom - frame.bottom); int32 workspace = triggerWindow->GetWindow()->CurrentWorkspace(); Desktop* desktop = triggerWindow->GetWindow()->Desktop(); desktop->MoveWindowBy(topWindow->GetWindow(), deltaToX, deltaToY, workspace); // Update frame to the new position desktop->ResizeWindowBy(topWindow->GetWindow(), deltaByX, deltaByY); UpdateSizeConstaints(frameSAT); }
/*! \brief Creates a desktop object for an authorized user */ Desktop* AppServer::_CreateDesktop(uid_t userID, const char* targetScreen) { BAutolock locker(fDesktopLock); Desktop* desktop = NULL; try { desktop = new Desktop(userID, targetScreen); status_t status = desktop->Init(); if (status == B_OK) { if (!desktop->Run()) status = B_ERROR; } if (status == B_OK && !fDesktops.AddItem(desktop)) status = B_NO_MEMORY; if (status != B_OK) { syslog(LOG_ERR, "Cannot initialize Desktop object: %s\n", strerror(status)); delete desktop; return NULL; } } catch (...) { // there is obviously no memory left return NULL; } return desktop; }
/* * Update Message in Message Window */ void updateMessageText( const std::string text ) { //Dialog Test Component* root = getGameView(); if(!root) { //happens while in menu. std::cerr << "Root not found.\n"; return; } while( root->getParent() ) root = root->getParent(); Desktop* desktop = dynamic_cast<Desktop*> (root); if(!desktop) { std::cerr << "Root not a desktop!?!\n"; return; } try { //test if message Windows is open Component* messageTextComponent = 0; messageTextComponent = root->findComponent( "messageText" ); if(messageTextComponent == 0) { messageTextComponent = loadGUIFile("gui/messagearea.xml"); assert(messageTextComponent != 0); desktop->addChildComponent(messageTextComponent); } Paragraph* messageText = getParagraph(*messageTextComponent, "messageText"); messageText->setText( text ); } catch(std::exception& e) { std::cerr << "Couldn't display message '" << text << "': " << e.what() << "\n"; return; } }
static void arrange_icons_cb(Fl_Widget*, void *d) { E_RETURN_IF_FAIL(d != NULL); Desktop *self = (Desktop*)d; self->arrange_icons(); self->redraw(); }
DesktopManager::~DesktopManager(void) { Settings settings; int index; delete m_bkDisplayMode; index = 0; vector<Desktop*>::const_iterator it; for(it = m_desks.begin(); it != m_desks.end(); it ++) { Desktop * desk; desk = *it; desk->SetIndex(index); desk->Save(); delete desk; index ++; } m_desks.clear(); if (m_hPreviewWindowFont) DeleteObject(m_hPreviewWindowFont); settings.SaveSetting(Settings::ColumnNumber, (unsigned long)m_nbColumn); settings.SaveSetting(Settings::DesktopNameOSD, m_useOSD); settings.SaveSetting(Settings::DisplayMode, (int)m_displayMode); settings.SaveSetting(Settings::PreviewWindowFont, &m_lfPreviewWindowFontInfo); settings.SaveSetting(Settings::PreviewWindowFontColor, m_crPreviewWindowFontColor); }
int main(){ int opcion; cout << "Seleccione equipo a construir: \n 1.Desktop \n 2.Laptop \n 3.Netbook \n 4.Tablet" << endl; cin >> opcion; /*cout << "Seleccion de componentes" << endl; cout << "Ensamblado de " << equipo << endl; cout << "Instalacion y configuracion de software" << endl; cout << "Empaquetando " << equipo << " en producto final" << endl;*/ switch (opcion) { case 1: Desktop* des = new Desktop("a0291", "MacOS 'El Capitan'", "NVIDIA 980", 3); des->crear(); break; case 2: Laptop* lap = new Laptop("a0291", "MacOS 'El Capitan'", "NVIDIA 980", 3); lap->crear(); break; case 3: Netbook* net = new Netbook("a0291", "MacOS 'El Capitan'", "NVIDIA 980", 3); net->crear(); break; case 4: Tablet* tab = new Tablet("a0291", "MacOS 'El Capitan'", "NVIDIA 980", 3); tab->crear(); break; default: cout << "Error: try again"; break; } return 0; }
unsigned char *ath_init_driver(unsigned char *param, unsigned char *display) { Desktop *d; ath_links_app = new LinksApplication(); if (!ath_links_app) { return stracpy((unsigned char *)"Unable to allocate Application object.\n"); } ath_lock = new Locker("links_sem", false, false); if (!ath_lock || ath_lock->Lock()) { delete ath_links_app; return stracpy((unsigned char *)"Could not create lock.\n"); } if (c_pipe(msg_pipe)) { delete ath_lock; ath_lock = NULL; delete ath_links_app; return stracpy((unsigned char *)"Could not create pipe.\n"); } fcntl(rpipe, F_SETFL, O_NONBLOCK); fcntl(wpipe, F_SETFL, O_NONBLOCK); set_handlers(rpipe, ath_get_event, NULL, NULL, NULL); ath_app_thread_id = spawn_thread("links_app", ath_app_thread, 0, 0, NULL); resume_thread(ath_app_thread_id); if ((d = new Desktop)) { ath_cs_desktop = d->GetColorSpace(); ath_x_size = d->GetResolution().x; ath_y_size = d->GetResolution().y; delete d; } else { ath_cs_desktop = CS_NO_COLOR_SPACE; ath_x_size = 640; ath_y_size = 480; } ath_win_y_size = ath_y_size * 9 / 10; ath_win_x_size = ath_win_y_size; /* fprintf(stderr, "%d %d\n", ath_x_size, ath_y_size); fprintf(stderr, "%d %d\n", ath_win_x_size, ath_win_y_size); */ ath_win_y_pos = (ath_y_size - ath_win_y_size) / 2; ath_win_x_pos = ath_x_size - ath_win_x_size - ath_win_y_pos; if (/*ath_cs_desktop == CS_RGB32 ||*/ ath_cs_desktop == CS_RGB24 || ath_cs_desktop == CS_RGB16 || ath_cs_desktop == CS_RGB15) ath_cs_bmp = ath_cs_desktop; else if (ath_cs_desktop == CS_RGB32 || ath_cs_desktop == CS_RGBA32) ath_cs_bmp = CS_RGB24; else ath_cs_bmp = CS_RGB15; switch (ath_cs_bmp) { case CS_RGB24: atheos_driver.depth = 0xc3; break; case CS_RGB16: atheos_driver.depth = 0x82; break; case CS_RGB15: atheos_driver.depth = 0x7a; break; default: internal((unsigned char *)"unknown depth"); } return NULL; }
LRESULT VirtualDimension::OnRightButtonDown(HWND hWnd, UINT /*message*/, WPARAM wParam, LPARAM lParam) { HMENU hMenu = NULL, hBaseMenu; POINT pt; HRESULT res; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); //Stop the hide timer, to ensure the window does not get hidden KillTimer(m_autoHideTimerId); //Get the context menu Desktop * desk = deskMan->GetDesktopFromPoint(pt.x, pt.y); Window * window = NULL; if ((!m_shrinked) && ((wParam & MK_CONTROL) == 0) && (desk != NULL)) { window = desk->GetWindowFromPoint(pt.x, pt.y); if (window) hMenu = window->BuildMenu(); else hMenu = desk->BuildMenu(); } //If no window on desktop, or no menu for the window, display system menu if (hMenu == NULL || GetMenuItemCount(hMenu) == 0) { hBaseMenu = hMenu; //destroy the newly created menu, even if we don't use it hMenu = m_pSysMenu; } else hBaseMenu = hMenu; assert(hMenu != NULL); //And show the menu ClientToScreen(hWnd, &pt); res = TrackPopupMenu(hMenu, TPM_RETURNCMD|TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL); //Process the resulting message if (hMenu == m_pSysMenu) PostMessage(hWnd, WM_SYSCOMMAND, res, 0); else if (res >= WM_USER) { if (window != NULL) window->OnMenuItemSelected(hMenu, res); else desk->OnMenuItemSelected(hMenu, res); } else PostMessage(hWnd, WM_COMMAND, res, 0); DestroyMenu(hBaseMenu); return 0; }
Workspace::Workspace(Desktop& desktop, int32 index) : fWorkspace(desktop.WorkspaceAt(index)), fDesktop(desktop), fCurrentWorkspace(index == desktop.CurrentWorkspace()) { ASSERT_MULTI_LOCKED(desktop.WindowLocker()); RewindWindows(); }
static void desktop_message_handler(int action, Window xid, void *data) { Desktop *d = (Desktop*)data; switch(action) { case NETWM_CHANGED_CURRENT_WORKAREA: d->update_workarea(); break; } }
static void folder_create_cb(Fl_Widget*, void *d) { E_RETURN_IF_FAIL(d != NULL); const char *n = input(_("Create a new folder with the name")); if(!n) return; Desktop *self = (Desktop*)d; self->create_folder(n); }
void Window::closeButtonClicked(Button* ) { Desktop* desktop = dynamic_cast<Desktop*> (getParent()); assert(desktop != 0); if(!desktop) return; desktop->remove(this); }
Desktop * DesktopManager::GetDesktop(INT_PTR index) const { vector<Desktop*>::const_iterator it; for(it = m_desks.begin(); it != m_desks.end(); it++) { Desktop * desk = *it; if (desk->GetIndex() == index) return desk; } return NULL; }
/** * Removes a client. * * Note that this method will put out a ChangeFocus event, but that event will * have a nonexistent 'prev_focus' field (pointing to the client that is * destroyed). Other than that event, however, no other notification will be * delivered that this window was removed. */ void ClientModel::remove_client(Window client) { if (!is_client(client)) return; // Unregister the client from any categories it may be a member of, but // keep a copy of each of the categories so we can pass it on to notify // that the window was destroyed (don't copy the size/location though, // since they will most likely be invalid, and of no use anyway) Desktop *desktop = find_desktop(client); Layer layer = find_layer(client); if (desktop->is_user_desktop()) { UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(desktop); user_desktop->focus_cycle.remove(client, true); sync_focus_to_cycle(); } else if (desktop->is_all_desktop()) { dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.remove(client, true); sync_focus_to_cycle(); } // Make sure to remove the child before removing any other parent state - the // child removal procedure depends upon knowing the parent's desktop std::set<Window> children(*m_children[client]); for (std::set<Window>::iterator child = children.begin(); child != children.end(); child++) { remove_child(*child, false); } m_desktops.remove_member(client); m_layers.remove_member(client); m_location.erase(client); m_size.erase(client); m_cps_mode.erase(client); m_screen.erase(client); m_autofocus.erase(client); m_pack_corners.erase(client); m_pack_priority.erase(client); delete m_children[client]; m_children.erase(client); m_changes.push(new DestroyChange(client, desktop, layer)); }
void RecentApplicationsModel::remove(QString filename) { // Remove all occurances of a given desktop entry QList<Desktop *> tmp; while (!m_recents.isEmpty()) { Desktop *d = m_recents.takeLast(); if (d->filename() == filename) d->deleteLater(); else tmp << d; } m_recents = tmp; saveRecents(); }
int main() { //Creator* cliente = new ComputerCreator(); //ComputerCreator* cliente = ComputerCreator::getInstance(); //Computer* miProducto = cliente->createProduct("Tablet"); Desktop De; Laptop La; Computer* co = De.clone(); co->create(); Computer* com = La.clone(); com->create(); return 0; }
UiComponent::UiComponent(Desktop& desktop) : desktop(desktop) { window = sfg::Window::Create(); desktop.Add(window); initialized = false; disabled = false; }
status_t VirtualScreen::SetConfiguration(Desktop& desktop, ScreenConfigurations& configurations, uint32* _changedScreens) { // Remember previous screen modes typedef std::map<Screen*, display_mode> ScreenModeMap; ScreenModeMap previousModes; bool previousModesFailed = false; if (_changedScreens != NULL) { *_changedScreens = 0; try { for (int32 i = 0; i < fScreenList.CountItems(); i++) { Screen* screen = fScreenList.ItemAt(i)->screen; display_mode mode; screen->GetMode(mode); previousModes.insert(std::make_pair(screen, mode)); } } catch (...) { previousModesFailed = true; *_changedScreens = ~0L; } } _Reset(); ScreenList list; status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0, desktop.TargetScreen(), false, list); if (status != B_OK) { // TODO: we would try again here with force == true return status; } for (int32 i = 0; i < list.CountItems(); i++) { Screen* screen = list.ItemAt(i); AddScreen(screen, configurations); if (!previousModesFailed && _changedScreens != NULL) { // Figure out which screens have changed their mode display_mode mode; screen->GetMode(mode); ScreenModeMap::const_iterator found = previousModes.find(screen); if (found != previousModes.end() && memcmp(&mode, &found->second, sizeof(display_mode))) *_changedScreens |= 1 << i; } } UpdateFrame(); return B_OK; }
LRESULT VirtualDimension::OnLeftButtonDblClk(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM lParam) { POINT pt; Window * window; Desktop * desk; if (m_shrinked) return 0; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); desk = deskMan->GetDesktopFromPoint(pt.x, pt.y); if ( (desk) && ((window = desk->GetWindowFromPoint(pt.x, pt.y)) != NULL) ) window->Activate(); return 0; }
/*! \brief Finds the desktop object that belongs to a certain user */ Desktop* AppServer::_FindDesktop(uid_t userID, const char* targetScreen) { BAutolock locker(fDesktopLock); for (int32 i = 0; i < fDesktops.CountItems(); i++) { Desktop* desktop = fDesktops.ItemAt(i); if (desktop->UserID() == userID && ((desktop->TargetScreen() == NULL && targetScreen == NULL) || (desktop->TargetScreen() != NULL && targetScreen != NULL && strcmp(desktop->TargetScreen(), targetScreen) == 0))) { return desktop; } } return NULL; }
void AppServer::MessageReceived(BMessage* message) { switch (message->what) { case AS_GET_DESKTOP: { Desktop* desktop = NULL; int32 userID = message->GetInt32("user", 0); int32 version = message->GetInt32("version", 0); const char* targetScreen = message->GetString("target"); if (version != AS_PROTOCOL_VERSION) { syslog(LOG_ERR, "Application for user %" B_PRId32 " does not " "support the current server protocol.\n", userID); } else { desktop = _FindDesktop(userID, targetScreen); if (desktop == NULL) { // we need to create a new desktop object for this user // TODO: test if the user exists on the system // TODO: maybe have a separate AS_START_DESKTOP_SESSION for // authorizing the user desktop = _CreateDesktop(userID, targetScreen); } } BMessage reply; if (desktop != NULL) reply.AddInt32("port", desktop->MessagePort()); else reply.what = (uint32)B_ERROR; message->SendReply(&reply); break; } default: // We don't allow application scripting STRACE(("AppServer received unexpected code %" B_PRId32 "\n", message->what)); break; } }
int main(int argc, char *argv[]) { /* 设置随机数种子 */ qsrand(time(NULL)); /* 打印当前时间 */ QDateTime abc; qDebug() << abc.currentDateTime().toString(); /* 启动线程调度循环 */ QApplication a(argc, argv); /* 显示桌面 */ Desktop d; d.show(); return a.exec(); }
/** * Handles an existing client that was unmapped, and is now being re-mapped. */ void ClientModel::remap_client(Window client) { if (!is_client(client)) return; std::vector<Window> children; get_children_of(client, children); Desktop *desktop = find_desktop(client); if (desktop->is_user_desktop()) { UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(desktop); user_desktop->focus_cycle.add(client); for (std::vector<Window>::iterator child = children.begin(); child != children.end(); child++) { user_desktop->focus_cycle.add(*child); } focus(client); } else if (desktop->is_all_desktop()) { AllDesktops *all_desktop = dynamic_cast<AllDesktops*>(ALL_DESKTOPS); all_desktop->focus_cycle.add(client); for (std::vector<Window>::iterator child = children.begin(); child != children.end(); child++) { all_desktop->focus_cycle.add(*child); } focus(client); } // The event processor also needs to know that it should update the current // layering, since the window could have been raised since it was remapped Layer current_layer = m_layers.get_category_of(client); m_changes.push(new ChangeLayer(client, current_layer)); }
void RecentApplicationsModel::append(QString filename) { QList<Desktop *> tmp; while (!m_recents.isEmpty()) { Desktop *d = m_recents.takeLast(); if (d->filename() == filename) { delete d; } else { tmp << d; } } m_recents = tmp; m_recents.prepend(new Desktop(filename)); saveRecents(); }
bool AppServer::QuitRequested() { #if TEST_MODE while (fDesktops.CountItems() > 0) { Desktop *desktop = fDesktops.RemoveItemAt(0); thread_id thread = desktop->Thread(); desktop->PostMessage(B_QUIT_REQUESTED); // we just wait for the desktop to kill itself status_t status; wait_for_thread(thread, &status); } return BServer::QuitRequested(); #else return false; #endif }
void StackAndTile::_ActivateWindow(SATWindow* satWindow) { if (satWindow == NULL) return; SATGroup* group = satWindow->GetGroup(); if (group == NULL) return; Desktop* desktop = satWindow->GetWindow()->Desktop(); if (desktop == NULL) return; WindowArea* area = satWindow->GetWindowArea(); if (area == NULL) return; area->MoveToTopLayer(satWindow); // save the active window of the current group SATWindow* frontWindow = GetSATWindow(fDesktop->FocusWindow()); SATGroup* currentGroup = _GetSATGroup(frontWindow); if (currentGroup != NULL && currentGroup != group && frontWindow != NULL) currentGroup->SetActiveWindow(frontWindow); else group->SetActiveWindow(satWindow); const WindowAreaList& areas = group->GetAreaList(); int32 areasCount = areas.CountItems(); for (int32 i = 0; i < areasCount; i++) { WindowArea* currentArea = areas.ItemAt(i); if (currentArea == area) continue; desktop->ActivateWindow(currentArea->TopWindow()->GetWindow()); } desktop->ActivateWindow(satWindow->GetWindow()); }
void Window::event(const Event& event) { switch(event.type) { case Event::MOUSEBUTTONDOWN: if(event.inside && title().inside(event.mousepos)) { dragging = true; dragOffset = event.mousepos - title().getPos(); } break; case Event::MOUSEBUTTONUP: if(dragging) { dragging = false; } break; case Event::MOUSEMOTION: { if(!dragging) break; Desktop* desktop = dynamic_cast<Desktop*> (getParent()); assert(desktop != 0); if(!desktop) return; // try to move window... Vector2 newpos = desktop->getPos(this) + event.mousepos - dragOffset; desktop->move(this, newpos); break; } default: break; } // distribute event to child components... Component::event(event); }
bool World::runDesktop(Desktop &myDesktop) { if (screen_ == nullptr) return false; // Go into main game loop quitter = false; sf::Clock deltaTime; sf::Time framePeriod = sf::milliseconds(sf::Int32(1000.0f / 30.f)); while (screen_->isOpen() && !quitter) { //Process sf::events sf::Event event; while (screen_->pollEvent(event)) { if (event.type == sf::Event::Closed) { screen_->close(); } else if (event.type == sf::Event::KeyPressed) { //Close if ((event.key.code == sf::Keyboard::Period) && (event.key.alt)) { quitDesktop(); } } //Input phase myDesktop.registerInput(event); } sf::Time elapsed = deltaTime.getElapsedTime(); while (elapsed > framePeriod) { screen_->clear(sf::Color::Black); sf::Time dt = deltaTime.restart(); myDesktop.update(dt); elapsed -= framePeriod; } myDesktop.refresh(); screen_->draw(myDesktop); screen_->display(); } return false; }