OSDN Git Service

kcontrol: remove unused KRandRSystemTray::configChanged() method
authorIvailo Monev <xakepa10@gmail.com>
Fri, 4 Aug 2023 09:35:10 +0000 (12:35 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 4 Aug 2023 09:35:12 +0000 (12:35 +0300)
not only unused but next to useless - it is about a configuration change
and the common way for that to happen is doing it from the randr KCM
which is a "I know what I am doing, I don't need popup for that" kind of
situtation

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kcontrol/randr/CMakeLists.txt
kcontrol/randr/krandrpassivepopup.cpp [deleted file]
kcontrol/randr/krandrpassivepopup.h [deleted file]
kcontrol/randr/krandrtray.cpp
kcontrol/randr/krandrtray.h
kcontrol/randr/randrscreen.cpp

index a0c7f43..9642c43 100644 (file)
@@ -48,7 +48,6 @@ set(krandrtray_SRCS
     main.cpp
     krandrtray.cpp
     krandrapp.cpp
-    krandrpassivepopup.cpp
 )
 
 add_executable(krandrtray ${krandrtray_SRCS})
diff --git a/kcontrol/randr/krandrpassivepopup.cpp b/kcontrol/randr/krandrpassivepopup.cpp
deleted file mode 100644 (file)
index 2158fbc..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/* 
- * Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
- *
- *  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 2 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, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#include "krandrpassivepopup.h"
-
-#include <kapplication.h>
-#include <QtGui/qx11info_x11.h>
-#include <QPixmap>
-#include <QEvent>
-
-// this class is just like KPassivePopup, but it keeps track of the widget
-// it's supposed to be positioned next to, and adjust its position if that
-// widgets moves (needed because after a resolution switch Kicker will
-// reposition itself, causing normal KPassivePopup to stay at weird places)
-
-KRandrPassivePopup::KRandrPassivePopup(QWidget *parent, Qt::WFlags f)
-    : KPassivePopup(parent, f)
-{
-    update_timer.setSingleShot( true );
-    connect( &update_timer, SIGNAL(timeout()), SLOT(slotPositionSelf()));
-}
-    
-KRandrPassivePopup* KRandrPassivePopup::message(const QString &caption, const QString &text,
-                                                const QPixmap &icon, QWidget *parent, int timeout)
-{
-    KRandrPassivePopup *pop = new KRandrPassivePopup(parent);
-    pop->setAutoDelete(true);
-    pop->setView(caption, text, icon);
-    pop->setTimeout(timeout);
-    pop->show();
-    pop->startWatchingWidget(parent);
-    return pop;
-}
-
-void KRandrPassivePopup::startWatchingWidget(QWidget* widget_P)
-{
-    static Atom wm_state = XInternAtom(QX11Info::display() , "WM_STATE", False);
-    Window win = widget_P->winId();
-    bool x11_events = false;
-    for(;;) {
-        Window root, parent;
-        Window* children;
-        unsigned int nchildren;
-        XQueryTree(QX11Info::display(), win, &root, &parent, &children, &nchildren);
-        if (children != NULL) {
-            XFree(children);
-        }
-        if (win == root) { // huh?
-            break;
-        }
-        win = parent;
-        
-        QWidget* widget = QWidget::find(win);
-        if (widget != NULL) {
-            widget->installEventFilter(this);
-            watched_widgets.append(widget);
-        } else {
-            XWindowAttributes attrs;
-            XGetWindowAttributes(QX11Info::display(), win, &attrs);
-            XSelectInput(QX11Info::display(), win, attrs.your_event_mask | StructureNotifyMask);
-            watched_windows.append(win);
-            x11_events = true;
-        }
-        Atom type;
-        int format;
-        unsigned long nitems, after;
-        unsigned char* data;
-        if (XGetWindowProperty( QX11Info::display(), win, wm_state, 0, 0, False, AnyPropertyType,
-            &type, &format, &nitems, &after, &data) == Success) {
-            if (data != NULL) {
-                XFree( data );
-            }
-            if (type != None) {
-                // toplevel window
-                break;
-            }
-        }
-    }
-    if (x11_events) {
-        kapp->installX11EventFilter(this);
-    }
-}
-
-bool KRandrPassivePopup::eventFilter(QObject* o, QEvent* e)
-{
-    if (e->type() == QEvent::Move && o->isWidgetType()
-        && watched_widgets.contains( static_cast< QWidget* >( o ))) {
-        QTimer::singleShot(0, this, SLOT(slotPositionSelf()));
-    }
-    return false;
-}
-
-bool KRandrPassivePopup::x11Event(XEvent* e)
-{
-    if (e->type == ConfigureNotify && watched_windows.contains(e->xconfigure.window)) {
-        if (!update_timer.isActive()) {
-            update_timer.start(10);
-        }
-        return false;
-    }
-    return KPassivePopup::x11Event(e);
-}
-        
-void KRandrPassivePopup::slotPositionSelf()
-{
-    positionSelf();
-}
-    
-#include "moc_krandrpassivepopup.cpp"
diff --git a/kcontrol/randr/krandrpassivepopup.h b/kcontrol/randr/krandrpassivepopup.h
deleted file mode 100644 (file)
index 0bd8b3d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* 
- * Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
- *
- *  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 2 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, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#ifndef __RANDRPASSIVEPOPUP_H__
-#define __RANDRPASSIVEPOPUP_H__
-
-#include <kpassivepopup.h>
-#include <QTimer>
-#include <QPixmap>
-#include <QEvent>
-
-#include <X11/Xlib.h>
-#include <fixx11h.h>
-
-class KRandrPassivePopup
-    : public KPassivePopup
-{
-    Q_OBJECT
-public:
-    static KRandrPassivePopup *message(const QString &caption, const QString &text,
-                                       const QPixmap &icon, QWidget *parent, int timeout = -1 );
-
-protected:
-    virtual bool eventFilter( QObject* o, QEvent* e );
-    virtual bool x11Event(XEvent* e);
-
-private Q_SLOTS:
-    void slotPositionSelf();
-
-private:
-    KRandrPassivePopup(QWidget *parent = 0, Qt::WFlags f = 0);
-    void startWatchingWidget(QWidget* w);
-    QList< QWidget* > watched_widgets;
-    QList< Window > watched_windows;
-    QTimer update_timer;
-};
-
-#endif // __RANDRPASSIVEPOPUP_H__
index aa9ca71..1551655 100644 (file)
@@ -20,7 +20,6 @@
 #include <config-X11.h>
 
 #include "krandrtray.h"
-#include "krandrpassivepopup.h"
 #include "moc_krandrtray.cpp"
 #include "randrscreen.h"
 #include "randroutput.h"
@@ -221,26 +220,6 @@ void KRandRSystemTray::updateToolTip()
     setToolTip(icon, title, subTitle);
 }
 
-void KRandRSystemTray::configChanged()
-{
-    m_display->refresh();
-    updateToolTip();
-    static bool first = true;
-
-    if (!first) {
-        // TODO: display config changed message
-        QString message = "Screen config changed";
-
-        KRandrPassivePopup::message(
-            i18n("Screen configuration has changed"),
-            message, SmallIcon("view-fullscreen"),
-            associatedWidget()
-        );
-    }
-
-    first = false;
-}
-
 void KRandRSystemTray::populateMenu(KMenu* menu)
 {
     QAction *action;
index 07de0b9..6dfdf93 100644 (file)
@@ -39,7 +39,6 @@ public:
     explicit KRandRSystemTray(RandRDisplay *dpy, QWidget* parent = 0);
     ~KRandRSystemTray();
 
-    void configChanged();
     void activate(const QPoint &pos);
 
 protected Q_SLOTS:
index d9bdcc0..4dc5474 100644 (file)
@@ -118,7 +118,7 @@ void RandRScreen::loadSettings(bool notify)
 
     for (int i = 0; i < m_resources->ncrtc; ++i) {
         if (m_crtcs.contains(m_resources->crtcs[i])) {
-                m_crtcs[m_resources->crtcs[i]]->loadSettings(notify);
+            m_crtcs[m_resources->crtcs[i]]->loadSettings(notify);
         } else {
             kDebug() << "Creating CRTC object for XID" << m_resources->crtcs[i];
             RandRCrtc *c = new RandRCrtc(this, m_resources->crtcs[i]);