Pārlūkot izejas kodu

WindowServer: Remove Clock from server.

We have clock applet.
Hüseyin ASLITÜRK 5 gadi atpakaļ
vecāks
revīzija
e50deb55d3

+ 4 - 0
Base/etc/SystemServer.ini

@@ -24,6 +24,10 @@ Priority=high
 KeepAlive=1
 KeepAlive=1
 User=anon
 User=anon
 
 
+[Clock.MenuApplet]
+KeepAlive=1
+User=anon
+
 [CPUGraph.MenuApplet]
 [CPUGraph.MenuApplet]
 KeepAlive=1
 KeepAlive=1
 User=anon
 User=anon

+ 2 - 33
Servers/WindowServer/WSMenuManager.cpp

@@ -1,25 +1,14 @@
-#include <LibCore/CTimer.h>
 #include <LibDraw/Font.h>
 #include <LibDraw/Font.h>
 #include <LibDraw/Painter.h>
 #include <LibDraw/Painter.h>
 #include <WindowServer/WSMenuManager.h>
 #include <WindowServer/WSMenuManager.h>
 #include <WindowServer/WSScreen.h>
 #include <WindowServer/WSScreen.h>
 #include <WindowServer/WSWindowManager.h>
 #include <WindowServer/WSWindowManager.h>
-#include <time.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
 WSMenuManager::WSMenuManager()
 WSMenuManager::WSMenuManager()
 {
 {
     m_username = getlogin();
     m_username = getlogin();
     m_needs_window_resize = true;
     m_needs_window_resize = true;
-
-    m_timer = CTimer::construct(300, [this] {
-        static time_t last_update_time;
-        time_t now = time(nullptr);
-        if (now != last_update_time) {
-            tick_clock();
-            last_update_time = now;
-        }
-    });
 }
 }
 
 
 WSMenuManager::~WSMenuManager()
 WSMenuManager::~WSMenuManager()
@@ -57,15 +46,7 @@ void WSMenuManager::draw()
             menubar_rect.height()
             menubar_rect.height()
         };
         };
 
 
-        int time_width = Font::default_font().width("2222-22-22 22:22:22");
-        m_time_rect = {
-            m_username_rect.left() - menubar_menu_margin() / 2 - time_width,
-            menubar_rect.y(),
-            time_width,
-            menubar_rect.height()
-        };
-
-        int right_edge_x = m_time_rect.left() - 4;
+        int right_edge_x = m_username_rect.left() - 4;
         for (auto& existing_applet : m_applets) {
         for (auto& existing_applet : m_applets) {
             if (!existing_applet)
             if (!existing_applet)
                 continue;
                 continue;
@@ -106,18 +87,6 @@ void WSMenuManager::draw()
 
 
     painter.draw_text(m_username_rect, m_username, Font::default_bold_font(), TextAlignment::CenterRight, palette.window_text());
     painter.draw_text(m_username_rect, m_username, Font::default_bold_font(), TextAlignment::CenterRight, palette.window_text());
 
 
-    time_t now = time(nullptr);
-    auto* tm = localtime(&now);
-    auto time_text = String::format("%4u-%02u-%02u %02u:%02u:%02u",
-        tm->tm_year + 1900,
-        tm->tm_mon + 1,
-        tm->tm_mday,
-        tm->tm_hour,
-        tm->tm_min,
-        tm->tm_sec);
-
-    painter.draw_text(m_time_rect, time_text, wm.font(), TextAlignment::CenterRight, palette.window_text());
-
     for (auto& applet : m_applets) {
     for (auto& applet : m_applets) {
         if (!applet)
         if (!applet)
             continue;
             continue;
@@ -282,7 +251,7 @@ void WSMenuManager::close_bar()
 
 
 void WSMenuManager::add_applet(WSWindow& applet)
 void WSMenuManager::add_applet(WSWindow& applet)
 {
 {
-    int right_edge_x = m_time_rect.left() - 4;
+    int right_edge_x = m_username_rect.left() - 4;
     for (auto& existing_applet : m_applets) {
     for (auto& existing_applet : m_applets) {
         if (existing_applet)
         if (existing_applet)
             right_edge_x = existing_applet->rect_in_menubar().x() - 4;
             right_edge_x = existing_applet->rect_in_menubar().x() - 4;

+ 0 - 3
Servers/WindowServer/WSMenuManager.h

@@ -2,7 +2,6 @@
 
 
 #include "WSMenu.h"
 #include "WSMenu.h"
 #include <LibCore/CObject.h>
 #include <LibCore/CObject.h>
-#include <LibCore/CTimer.h>
 #include <WindowServer/WSWindow.h>
 #include <WindowServer/WSWindow.h>
 
 
 class AClientConnection;
 class AClientConnection;
@@ -53,7 +52,6 @@ private:
 
 
     RefPtr<WSWindow> m_window;
     RefPtr<WSWindow> m_window;
     String m_username;
     String m_username;
-    RefPtr<CTimer> m_timer;
 
 
     WeakPtr<WSMenu> m_current_menu;
     WeakPtr<WSMenu> m_current_menu;
     Vector<WeakPtr<WSMenu>> m_open_menu_stack;
     Vector<WeakPtr<WSMenu>> m_open_menu_stack;
@@ -61,7 +59,6 @@ private:
     Vector<WeakPtr<WSWindow>> m_applets;
     Vector<WeakPtr<WSWindow>> m_applets;
 
 
     Rect m_username_rect;
     Rect m_username_rect;
-    Rect m_time_rect;
 
 
     bool m_needs_window_resize { false };
     bool m_needs_window_resize { false };
     bool m_bar_open { false };
     bool m_bar_open { false };