StartupId::StartupId( QWidget* parent, const char* name ) : QWidget( parent, name ), startup_info( KStartupInfo::CleanOnCantDetect ), startup_widget( NULL ), blinking( true ), bouncing( false ) { hide(); // is QWidget only because of x11Event() if( kde_startup_status == StartupPre ) { kde_splash_progress = XInternAtom( qt_xdisplay(), "_KDE_SPLASH_PROGRESS", False ); XWindowAttributes attrs; XGetWindowAttributes( qt_xdisplay(), qt_xrootwin(), &attrs); XSelectInput( qt_xdisplay(), qt_xrootwin(), attrs.your_event_mask | SubstructureNotifyMask); kapp->installX11EventFilter( this ); } connect( &update_timer, SIGNAL( timeout()), SLOT( update_startupid())); connect( &startup_info, SIGNAL( gotNewStartup( const KStartupInfoId&, const KStartupInfoData& )), SLOT( gotNewStartup( const KStartupInfoId&, const KStartupInfoData& ))); connect( &startup_info, SIGNAL( gotStartupChange( const KStartupInfoId&, const KStartupInfoData& )), SLOT( gotStartupChange( const KStartupInfoId&, const KStartupInfoData& ))); connect( &startup_info, SIGNAL( gotRemoveStartup( const KStartupInfoId&, const KStartupInfoData& )), SLOT( gotRemoveStartup( const KStartupInfoId& ))); }
void KWM::unregisterSoundEvent(const QString &event){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KDE_UNREGISTER_SOUND_EVENT", False); XEvent ev; int status; long mask; memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = qt_xrootwin(); ev.xclient.message_type = a; ev.xclient.format = 8; int i; const char* s = event.data(); for (i=0;i<19 && s[i];i++) ev.xclient.data.b[i]=s[i]; mask = SubstructureRedirectMask; status = XSendEvent(qt_xdisplay(), qt_xrootwin(), False, mask, &ev); }
void KWM::sendKWMCommand(const QString &command){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_COMMAND", False); XEvent ev; int status; long mask; memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = qt_xrootwin(); ev.xclient.message_type = a; ev.xclient.format = 8; int i; const char* s = command.data(); for (i=0;i<19 && s[i];i++) ev.xclient.data.b[i]=s[i]; mask = SubstructureRedirectMask; status = XSendEvent(qt_xdisplay(), qt_xrootwin(), False, mask, &ev); }
void KPager::clientPopupActivated( int id ) { switch ( id ) { case MaximizeOp: if ( (m_winfo.state() & NET::Max) == 0 ) { NETWinInfo ni( qt_xdisplay(), m_winfo.win(), qt_xrootwin(), 0); ni.setState( NET::Max, NET::Max ); } else { NETWinInfo ni( qt_xdisplay(), m_winfo.win(), qt_xrootwin(), 0); ni.setState( 0, NET::Max ); } break; case IconifyOp: if ( !m_winfo.isMinimized() ) { KWin::iconifyWindow( m_winfo.win()); } else { KWin::forceActiveWindow( m_winfo.win() ); } break; case StickyOp: if ( m_winfo.onAllDesktops() ) { KWin::setOnAllDesktops(m_winfo.win(), false); } else { KWin::setOnAllDesktops(m_winfo.win(), true); } break; case CloseOp: { NETRootInfo ri( qt_xdisplay(), 0 ); ri.closeWindowRequest( m_winfo.win() ); } break; default: break; } }
bool ThemeEngine::x11Event( XEvent* e ) { if( e->type != ConfigureNotify && e->type != MapNotify ) return false; if( e->type == ConfigureNotify && e->xconfigure.event != qt_xrootwin()) return false; if( e->type == MapNotify && e->xmap.event != qt_xrootwin()) return false; if( d->mSplashWindows.count() == 0 ) return false; // this restacking is written in a way so that // if the stacking positions actually don't change, // all restacking operations will be no-op, // and no ConfigureNotify will be generated, // thus avoiding possible infinite loops XRaiseWindow( qt_xdisplay(), d->mSplashWindows.first()); // raise topmost // and stack others below it Window* stack = new Window[ d->mSplashWindows.count() ]; int count = 0; for( QValueList< Window >::ConstIterator it = d->mSplashWindows.begin(); it != d->mSplashWindows.end(); ++it ) stack[ count++ ] = *it; XRestackWindows( x11Display(), stack, count ); delete[] stack; return false; }
void Gesture::grab_mouse( bool grab_P ) { if( grab_P ) { KXErrorHandler handler; static int mask[] = { 0, Button1MotionMask, Button2MotionMask, Button3MotionMask, Button4MotionMask, Button5MotionMask, ButtonMotionMask, ButtonMotionMask, ButtonMotionMask, ButtonMotionMask }; #define XCapL KKeyNative::modXLock() #define XNumL KKeyNative::modXNumLock() #define XScrL KKeyNative::modXScrollLock() unsigned int mods[ 8 ] = { 0, XCapL, XNumL, XNumL | XCapL, XScrL, XScrL | XCapL, XScrL | XNumL, XScrL | XNumL | XCapL }; #undef XCapL #undef XNumL #undef XScrL for( int i = 0; i < 8; ++i ) XGrabButton( qt_xdisplay(), button, mods[ i ], qt_xrootwin(), False, ButtonPressMask | ButtonReleaseMask | mask[ button ], GrabModeAsync, GrabModeAsync, None, None ); bool err = handler.error( true ); kdDebug( 1217 ) << "Gesture grab:" << err << endl; } else { kdDebug( 1217 ) << "Gesture ungrab" << endl; XUngrabButton( qt_xdisplay(), button, AnyModifier, qt_xrootwin()); } }
bool KGlobalAccel::grabKey( uint keysym, uint mod ) { // Most of this comes from kpanel/main.C // Copyright (C) 1996,97 Matthias Ettrich static int NumLockMask = 0; debug("KGlobalAccel::grabKey"); if (!XKeysymToKeycode(qt_xdisplay(), keysym)) return false; if (!NumLockMask){ XModifierKeymap* xmk = XGetModifierMapping(qt_xdisplay()); int i; for (i=0; i<8; i++){ if (xmk->modifiermap[xmk->max_keypermod * i] == XKeysymToKeycode(qt_xdisplay(), XK_Num_Lock)) NumLockMask = (1<<i); } } grabFailed = false; // We wan't to catch only our own errors XSync(qt_xdisplay(),0); XErrorHandler savedErrorHandler=XSetErrorHandler(XGrabErrorHandler); debug("Will grab key and variants with keyboard locks: %d, %d", keysym, mod); XGrabKey(qt_xdisplay(), XKeysymToKeycode(qt_xdisplay(), keysym), mod, qt_xrootwin(), True, GrabModeAsync, GrabModeSync); XGrabKey(qt_xdisplay(), XKeysymToKeycode(qt_xdisplay(), keysym), mod | LockMask, qt_xrootwin(), True, GrabModeAsync, GrabModeSync); XGrabKey(qt_xdisplay(), XKeysymToKeycode(qt_xdisplay(), keysym), mod | NumLockMask, qt_xrootwin(), True, GrabModeAsync, GrabModeSync); XGrabKey(qt_xdisplay(), XKeysymToKeycode(qt_xdisplay(), keysym), mod | LockMask | NumLockMask, qt_xrootwin(), True, GrabModeAsync, GrabModeSync); XSync(qt_xdisplay(),0); XSetErrorHandler(savedErrorHandler); debug(" grabbed"); if (grabFailed) { // FIXME: ungrab all successfull grabs! //warning("Global grab failed!"); return false; } return true; }
Application::Application() : KApplication(), owner(screen_number) { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if(!config()->isImmutable() && args->isSet("lock")) { config()->setReadOnly(true); config()->reparseConfiguration(); } if(screen_number == -1) screen_number = DefaultScreen(qt_xdisplay()); if(!owner.claim(args->isSet("replace"), true)) { fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr); ::exit(1); } connect(&owner, SIGNAL(lostOwnership()), SLOT(lostSelection())); // if there was already kwin running, it saved its configuration after loosing the selection -> reread config()->reparseConfiguration(); initting = TRUE; // startup.... // install X11 error handler XSetErrorHandler(x11ErrorHandler); // check whether another windowmanager is running XSelectInput(qt_xdisplay(), qt_xrootwin(), SubstructureRedirectMask); syncX(); // trigger error now options = new Options; atoms = new Atoms; // create workspace. (void)new Workspace(isSessionRestored()); syncX(); // trigger possible errors, there's still a chance to abort DCOPRef ref("kded", "kded"); ref.send("unloadModule", QCString("kdetrayproxy")); initting = FALSE; // startup done, we are up and running now. dcopClient()->send("ksplash", "", "upAndRunning(QString)", QString("wm started")); XEvent e; e.xclient.type = ClientMessage; e.xclient.message_type = XInternAtom(qt_xdisplay(), "_KDE_SPLASH_PROGRESS", False); e.xclient.display = qt_xdisplay(); e.xclient.window = qt_xrootwin(); e.xclient.format = 8; strcpy(e.xclient.data.b, "wm started"); XSendEvent(qt_xdisplay(), qt_xrootwin(), False, SubstructureNotifyMask, &e); }
void TaskManager::windowAdded(WId w ) { NETWinInfo info(qt_xdisplay(), w, qt_xrootwin(), NET::WMWindowType | NET::WMPid | NET::WMState ); #ifdef KDE_3_2 NET::WindowType windowType = info.windowType(NET_ALL_TYPES_MASK); #else NET::WindowType windowType = info.windowType(); #endif // ignore NET::Tool and other special window types if (windowType != NET::Normal && windowType != NET::Override && windowType != NET::Unknown && windowType != NET::Dialog) return; // ignore windows that want to be ignored by the taskbar if ((info.state() & NET::SkipTaskbar) != 0) { _skiptaskbar_windows.push_front( w ); // remember them though return; } Window transient_for_tmp; if (XGetTransientForHint(qt_xdisplay(), (Window) w, &transient_for_tmp)) { WId transient_for = (WId) transient_for_tmp; // check if it's transient for a skiptaskbar window if (_skiptaskbar_windows.contains(transient_for)) return; // lets see if this is a transient for an existing task if (transient_for != qt_xrootwin() && transient_for != 0 ) { Task* t = findTask(transient_for); if (t) { if (t->window() != w) { t->addTransient(w); // kdDebug() << "TM: Transient " << w << " added for Task: " << t->window() << endl; } return; } } } Task* t = new Task(w, this); _tasks.append(t); // kdDebug() << "TM: Task added for WId: " << w << endl; emit taskAdded(t); }
void winlist::hidden_win(void) { Window w1,w2,*wins; uint nwins; if(XQueryTree(qt_xdisplay(), qt_xrootwin(), &w1, &w2, &wins, &nwins) == 0 || ! nwins) return; xwindow *win; int dwidth = QApplication::desktop()->width(); for(win = clients.first(); win != NULL; win = clients.next()) { if(win->isVisible() && win->x() <= dwidth && win->x() >= 0 && isobscured(win, wins, nwins)) { win->raise(); XFree(wins); return; } } if(qapp::is_tileddesk()) { for(win = clients.first(); win != NULL; win = clients.next()) { if(win->isVisible() && win->x() <= dwidth && win->x() >= 0 && ! win->is_tiled() && isbottom(win, wins, nwins)) { win->raise(); XFree(wins); return; } } } XFree(wins); }
void getrunprocs(void) // get already running clients { Window w,w1,w2,*wins; uint nwins,cwin; XWindowAttributes attr; if(XQueryTree(qt_xdisplay(), qt_xrootwin(), &w1, &w2, &wins, &nwins) == 0 || ! nwins) return; bool surgent = defaults::starturgent; defaults::starturgent = FALSE; for(cwin=0; cwin < nwins; cwin++) { w = wins[cwin]; if(w == qapp::tb->winId()) continue; XGetWindowAttributes(qt_xdisplay(), w, &attr); if(attr.map_state == IsViewable && ! attr.override_redirect) qapp::run_client(w); } XSync(qt_xdisplay(), FALSE); defaults::starturgent = surgent; }
void KTheme::addPreview() { QString file = m_kgd->saveLocation( "themes", m_name + "/" ) + m_name + ".preview.png"; kdDebug() << "Adding preview: " << file << endl; QPixmap snapshot = QPixmap::grabWindow( qt_xrootwin() ); snapshot.save( file, "PNG" ); }
void ShowDesktop::slotWindowAdded(WId w) { if(!m_showingDesktop) { return; } NETWinInfo inf(qt_xdisplay(), w, qt_xrootwin(), NET::XAWMState | NET::WMWindowType); NET::WindowType windowType = inf.windowType(NET::AllTypesMask); if((windowType == NET::Normal || windowType == NET::Unknown) && inf.mappingState() == NET::Visible) { KConfig kwincfg("kwinrc", true); // see in kwin kwincfg.setGroup("Windows"); if(kwincfg.readBoolEntry("ShowDesktopIsMinimizeAll", false)) { m_iconifiedList.clear(); m_showingDesktop = false; emit desktopShown(false); } else { m_activeWindow = w; showDesktop(false); } } }
GlobalKey::GlobalKey(CommandDef *cmd) { m_key = QAccel::stringToKey(cmd->accel); m_state = 0; if (m_key & Qt::SHIFT) { m_key &= ~Qt::SHIFT; m_state |= 1; } if (m_key & Qt::CTRL) { m_key &= ~Qt::CTRL; m_state |= 4; } if (m_key & Qt::ALT) { m_key &= ~Qt::ALT; m_state |= 8; } m_key &= ~Qt::UNICODE_ACCEL; for (const TransKey *t = g_rgQtToSymX; t->x_key; t++) { if (t->qt_key == m_key) { m_key = t->x_key; break; } } m_key = XKeysymToKeycode( qt_xdisplay(), m_key); XSync( qt_xdisplay(), 0 ); XErrorHandler savedErrorHandler = XSetErrorHandler(XGrabErrorHandler); XGrabKey( qt_xdisplay(), m_key, m_state, qt_xrootwin(), True, GrabModeAsync, GrabModeSync); XSync( qt_xdisplay(), 0 ); XSetErrorHandler( savedErrorHandler ); }
void Task::toDesktop(int desk) { NETWinInfo ni(qt_xdisplay(), _win, qt_xrootwin(), NET::WMDesktop); if (desk == 0) { #ifdef KDE_3_2 if (_info.onAllDesktops()) { ni.setDesktop(kwin_module->currentDesktop()); KWin::forceActiveWindow(_win); } #else if (_info.onAllDesktops) { ni.setDesktop(kwin_module->currentDesktop()); KWin::setActiveWindow(_win); } #endif else ni.setDesktop(NETWinInfo::OnAllDesktops); return; } ni.setDesktop(desk); if (desk == kwin_module->currentDesktop()) #ifdef KDE_3_2 KWin::forceActiveWindow(_win); #else KWin::setActiveWindow(_win); #endif }
void servercontroller::saveSessionConfig() { QDictIterator<KSircProcess> ksp(proc_list); for (; ksp.current(); ++ksp ) { ChannelSessionInfoList channels; QDictIterator<KSircMessageReceiver> ksm(ksp.current()->getWindowList()); for (; ksm.current(); ++ksm ) if(ksm.currentKey()[0] != '!') { // Ignore !ksm's (system created) ChannelSessionInfo sessionInfo; sessionInfo.name = ksm.currentKey(); sessionInfo.port = ksp.current()->serverPort(); KSircTopLevel *topLev = dynamic_cast<KSircTopLevel *>( ksm.current() ); if ( topLev && topLev->isTopLevel() ) { #ifdef Q_WS_X11 NETWinInfo winInfo( qt_xdisplay(), topLev->winId(), qt_xrootwin(), NET::WMDesktop ); sessionInfo.desktop = winInfo.desktop(); #endif } channels << sessionInfo; } if ( !channels.isEmpty() ) m_sessionConfig[ ksp.currentKey() ] = channels; } }
bool RKWardApplication::x11EventFilter (XEvent *e) { if (detect_x11_creations) { if (e->type == CreateNotify) { if (e->xcreatewindow.parent == qt_xrootwin ()) { KWin::WindowInfo info = KWin::windowInfo (e->xcreatewindow.window); // at this point, we used to check, whether this window has some name or another. This heuristic allowed to sieve out helper windows of the window manager. However, since R 2.8.0, sometimes the window is mapped, before it has been give a name. // Now we rely on the fact (we hope it *is* a fact), that the device window is always the first one created. if ((info.windowType (0xFFFF) != 0) && (!created_window)) { created_window = e->xcreatewindow.window; return true; } } else { RK_ASSERT (false); } } } if (e->type == PropertyNotify) { if (e->xproperty.atom == wm_name_property) { if (name_watchers_list.contains (e->xproperty.window)) { KWin::WindowInfo wininfo = KWin::windowInfo (e->xproperty.window); name_watchers_list[e->xproperty.window]->setCaption (wininfo.name ()); return true; } } } return KApplication::x11EventFilter (e); }
QRect KWM::geometry(Window w, bool including_frame){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_WIN_FRAME_GEOMETRY", False); QRect result; if (including_frame){ if (getQRectProperty(w, a, result)) return result; } XWindowAttributes attr; if (XGetWindowAttributes(qt_xdisplay(), w, &attr)){ if (getQRectProperty(w, a, result)){ result.setWidth(attr.width); result.setHeight(attr.height); } else{ int x, y; Window child; XTranslateCoordinates(qt_xdisplay(), w, qt_xrootwin(), 0, 0, &x, &y, &child); result.setRect(x, y, attr.width, attr.height); } } return result; }
void KWM::setKWMDockModule(Window w){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_MODULE", False); setSimpleProperty(w, a, 2); sendClientMessage(qt_xrootwin(), a, (long) w); }
void Task::setAlwaysOnTop(bool stay) { NETWinInfo ni( qt_xdisplay(), _win, qt_xrootwin(), NET::WMState); if(stay) ni.setState( NET::StaysOnTop, NET::StaysOnTop ); else ni.setState( 0, NET::StaysOnTop ); }
void Task::setShaded(bool shade) { NETWinInfo ni( qt_xdisplay(), _win, qt_xrootwin(), NET::WMState); if(shade) ni.setState( NET::Shaded, NET::Shaded ); else ni.setState( 0, NET::Shaded ); }
int KWM::numberOfDesktops(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_NUMBER_OF_DESKTOPS", False); long result = 1; getSimpleProperty(qt_xrootwin(), a, result); return (int) result; }
Window KWM::activeWindow(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_ACTIVE_WINDOW", False); long result = 0; getSimpleProperty(qt_xrootwin(), a, result); return (Window) result; }
bool KWM::isKWMInitialized(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_RUNNING", False); long result = 0; getSimpleProperty(qt_xrootwin(), a, result); return result != 0; }
void RegionGrabber::initGrabber() { pixmap = QPixmap::grabWindow( qt_xrootwin() ); setPaletteBackgroundPixmap( pixmap ); QDesktopWidget desktopWidget; QRect desktopSize; if ( desktopWidget.isVirtualDesktop() ) desktopSize = desktopWidget.geometry(); else desktopSize = desktopWidget.screenGeometry( qt_xrootwin() ); setGeometry( desktopSize ); showFullScreen(); QApplication::setOverrideCursor( crossCursor ); }
QString KWM::getOntoCurrentDesktopString(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_STRING_ONTOCURRENTDESKTOP", False); QString result; getQStringProperty(qt_xrootwin(), a, result); return result; }
QString KWM::getCloseString(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_STRING_CLOSE", False); QString result; getQStringProperty(qt_xrootwin(), a, result); return result; }
QString KWM::getUnStickyString(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_STRING_UNSTICKY", False); QString result; getQStringProperty(qt_xrootwin(), a, result); return result; }
QString KWM::getIconifyString(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_STRING_ICONIFY", False); QString result; getQStringProperty(qt_xrootwin(), a, result); return result; }
QString KWM::getUnMaximizeString(){ static Atom a = 0; if (!a) a = XInternAtom(qt_xdisplay(), "KWM_STRING_UNMAXIMIZE", False); QString result; getQStringProperty(qt_xrootwin(), a, result); return result; }